Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp59321imu; Thu, 8 Nov 2018 14:47:00 -0800 (PST) X-Google-Smtp-Source: AJdET5fkWEC1VoSvnkCF5b/U6vinzH9AePP3gI/PbdozQte6pzF1XK77gj4zsAnV7/GCzgtgOFgT X-Received: by 2002:a17:902:bb89:: with SMTP id m9-v6mr3002023pls.245.1541717220068; Thu, 08 Nov 2018 14:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541717220; cv=none; d=google.com; s=arc-20160816; b=CZruk26TCxK7qAFYZrmWU0JAzDz90x9qE9/pMvI+t4y4fp6z5XeJPU8VXiL+X1bzPD OBb8ufGZeW8DARnNwt632pPvbXb+mpGplQmXbzuhuMROLKrsbZVQOyNiPjl4GgMjcoi0 4s10MvHhjFXbFtGEQXtV+TWWIscJrW7USr2fwSS2LsuXzIEXLaDA/TMZdwbHXQi3hWAs CRmGzFMiaNp/rR49yNmlCgXJWIc3+lRTcbXKuzf1fKiyoNhTK7BUEQsqG5hmVGPGUEjg BbrxejaG5MQc25AayRbxqgpunE3MqPaFbnC4CFn5VCTrUL0CWEGwj1HWqP8wn9xwT44b y+aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cfBhupD4u8NLbmRAVDLIrD7XwttDhjj/M2ahm3L6xvU=; b=XK8TQ5FQKGB48hne4fPIlwjpe1TQrqOXO7hajMw0ft92AkpNZFGrDTfzKx/HkCbHWm QCjtLL2IKbr3GoVkQOk1OTNFbOJ1UomcrEddGZyelK2/VCDMAZ6en0Bxmr3bRWifJ6wQ fnJJDXtTsUDOq0A5lcnveDBzSXlC0GEKc0ADGVZGoshR9l9vNf0JiDTjcJ/H6xf8vAOB 3wiNOTH2vqrGgz4V7iUoVUTAj6+vnOo5+VcyfNX9w2yUd9sV2yoP9+ip1jKMevrwDK2G AvRhfZVJi9bKU7hPN72Bm5k8crXDSrH1PSHJlkgmt9XY2tRlcp1epazum43n6KE7mifc 916g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VOy+9aP8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u30si5054210pgn.170.2018.11.08.14.46.44; Thu, 08 Nov 2018 14:47:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VOy+9aP8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728218AbeKIHcD (ORCPT + 99 others); Fri, 9 Nov 2018 02:32:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:46888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbeKIHcC (ORCPT ); Fri, 9 Nov 2018 02:32:02 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EEFF620857; Thu, 8 Nov 2018 21:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714075; bh=O6wCBmRH3Y+Qh5shot7GVZU6ZOQAXbD7djWTYiSuMYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VOy+9aP8dTGyxJbDJk8jaLfRqU5bW2BmCTt5EjbNrqGrTdZUTSRVQAs/64qeVXTgX i1WT1xXlwR6sAVW+K9NYTQeuXdtW1yRNfT7cuQoo0Muct+BKld9k5XJmpH8bgORRS1 UIXWDfdDMqRDVzpfkbCiJSpcyEEEE8Zssh1IKzUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Chen , Joseph Qi , Joel Becker , Mark Fasheh , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 3.18 033/144] ocfs2: fix journal commit deadlock in ocfs2_convert_inline_data_to_extents Date: Thu, 8 Nov 2018 13:50:04 -0800 Message-Id: <20181108215057.265594456@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 15eba0fe3eeaeb1b80489c1ebb9d47d6d7003f57 ] Similar to ocfs2_write_end_nolock() which is metioned at commit 136f49b91710 ("ocfs2: fix journal commit deadlock"), we should unlock pages before ocfs2_commit_trans() in ocfs2_convert_inline_data_to_extents. Otherwise, it will cause a deadlock with journal commit threads. Signed-off-by: Alex Chen Reviewed-by: Joseph Qi Cc: Joel Becker Cc: Mark Fasheh Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/alloc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index d9db90446c9d..3564b896a92e 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c @@ -6871,7 +6871,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, if (IS_ERR(handle)) { ret = PTR_ERR(handle); mlog_errno(ret); - goto out_unlock; + goto out; } ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh, @@ -6929,7 +6929,7 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, if (ret) { mlog_errno(ret); need_free = 1; - goto out_commit; + goto out_unlock; } page_end = PAGE_CACHE_SIZE; @@ -6962,12 +6962,16 @@ int ocfs2_convert_inline_data_to_extents(struct inode *inode, if (ret) { mlog_errno(ret); need_free = 1; - goto out_commit; + goto out_unlock; } inode->i_blocks = ocfs2_inode_sector_count(inode); } +out_unlock: + if (pages) + ocfs2_unlock_and_free_pages(pages, num_pages); + out_commit: if (ret < 0 && did_quota) dquot_free_space_nodirty(inode, @@ -6987,15 +6991,11 @@ out_commit: ocfs2_commit_trans(osb, handle); -out_unlock: +out: if (data_ac) ocfs2_free_alloc_context(data_ac); - -out: - if (pages) { - ocfs2_unlock_and_free_pages(pages, num_pages); + if (pages) kfree(pages); - } return ret; } -- 2.17.1