Received: by 10.223.185.116 with SMTP id b49csp1354491wrg; Sun, 11 Feb 2018 10:02:49 -0800 (PST) X-Google-Smtp-Source: AH8x226GzQN/Dv/yWDRuf4czxuDGBdtSdVwaeuHIyXNv8nOnJKjQKA9eBTP5YY3PKwB1a3hW+4n1 X-Received: by 10.99.174.5 with SMTP id q5mr7433816pgf.3.1518372169156; Sun, 11 Feb 2018 10:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518372169; cv=none; d=google.com; s=arc-20160816; b=FYLU1mN5e9Qy0lHhc+8QSftVM+9zYa16Q+7pIA0lvGqMASZRbtSqVK3LftCMdhjOdI F2tOw8WE4+/FaADojaEfNVetIyG/U7LMBQ9MU35sqeMJ4+5vS2UsWqYhqTgGtvayNA93 Nd7pkyhU4W9ZNOKVpqHHqBAd25qGxB6Id8lL8cJ1YeHMtTawJXCwOLTxzgiuzUiZV9YS kchOPpSrF0WRluqOj4aQLwRVAVA3Ywfe8KDw9C1jLtjjgkPuY8gVj2AP9KIaN7BAtSlM zBtePirvgMJQkDjUQjFuVZVcggr0MSQ4Eoo+30mtrEyRB9eyVI1WNh8hLWnNZwbZ28Ky K+Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id:arc-authentication-results; bh=dr32kO+Fe7HXHhCsDjmC4KlK72Ze42SVHaizuiA6QuU=; b=lDNh7ZgZP4taBlQi4sylBhH2HcQu94suIs6MnKg1GvFhrcBMgD8KpsTIRtDXfKgZc3 jTJhzOIt/c4GML+SEPGtJplhRxsjROvWZl7w6YVoocmDYJOAjBYh2a+1CBmVe0Qd/2Un f8C7qA4G1MF6Tlb3hZLMbgYqUbB+euPzhtMRuYL4UDWe5BU1rbmeKsKGn4ppdiCtF0E+ 9ewRGBAmSZ6cQr+xeWMkKW8h5ous69ZsITRCQzWgLWSepfFM95kGl2gJkWpDvnhzEplE 2jb8brGcLzxvKpPPnEu4u2aNjGSmYzzojVJgLld1Cf3iYUaNeyenNKOYD3Ty+OyRTAcv EU8A== ARC-Authentication-Results: i=1; mx.google.com; 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 x12si2257099pgr.279.2018.02.11.10.02.35; Sun, 11 Feb 2018 10:02:49 -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; 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 S1753589AbeBKSB5 (ORCPT + 99 others); Sun, 11 Feb 2018 13:01:57 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:45904 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753520AbeBKSB4 (ORCPT ); Sun, 11 Feb 2018 13:01:56 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekvwl-0002gS-W8; Sun, 11 Feb 2018 18:01:52 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekvwg-0007Mr-A7; Sun, 11 Feb 2018 18:01:46 +0000 Message-ID: <1518372105.2617.22.camel@decadent.org.uk> Subject: Re: [PATCH 3.2 39/79] ocfs2: should wait dio before inode lock in ocfs2_setattr() From: Ben Hutchings To: alex chen Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, akpm@linux-foundation.org, Joel Becker , Joseph Qi , Jun Piao , Mark Fasheh , Changwei Ge , Junxiao Bi , Linus Torvalds Date: Sun, 11 Feb 2018 18:01:45 +0000 In-Reply-To: <5A7FF337.3000705@huawei.com> References: <5A7FF337.3000705@huawei.com> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-BNWVRJVxBCvZs5V5dgm3" X-Mailer: Evolution 3.26.3-1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-BNWVRJVxBCvZs5V5dgm3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2018-02-11 at 15:39 +0800, alex chen wrote: > Hi Ben, >=20 > ocfs2_dio_end_io_write() was introduced in 4.6 and the problem this patch > fixes is only exist in the kernel 4.6 and above 4.6. Thanks for the reminder. I'll drop this from the 3.2 and 3.16 patch queues. Ben. > Thanks, > Alex >=20 > On 2018/2/11 12:20, Ben Hutchings wrote: > > 3.2.99-rc1 review patch. If anyone has any objections, please let me k= now. > >=20 > > ------------------ > >=20 > > From: alex chen > >=20 > > commit 28f5a8a7c033cbf3e32277f4cc9c6afd74f05300 upstream. > >=20 > > we should wait dio requests to finish before inode lock in > > ocfs2_setattr(), otherwise the following deadlock will happen: > >=20 > > process 1 process 2 process 3 > > truncate file 'A' end_io of writing file 'A' receiving the b= ast messages > > ocfs2_setattr > > ocfs2_inode_lock_tracker > > ocfs2_inode_lock_full > > inode_dio_wait > > __inode_dio_wait > > -->waiting for all dio > > requests finish > > dlm_proxy_ast_h= andler > > dlm_do_local_b= ast > > ocfs2_blockin= g_ast > > ocfs2_generi= c_handle_bast > > set OCFS2_L= OCK_BLOCKED flag > > dio_end_io > > dio_bio_end_aio > > dio_complete > > ocfs2_dio_end_io > > ocfs2_dio_end_io_write > > ocfs2_inode_lock > > __ocfs2_cluster_lock > > ocfs2_wait_for_mask > > -->waiting for OCFS2_LOCK_BLOCKED > > flag to be cleared, that is waiting > > for 'process 1' unlocking the inode lock > > inode_dio_end > > -->here dec the i_dio_count, but will never > > be called, so a deadlock happened. > >=20 > > Link: http://lkml.kernel.org/r/59F81636.70508@huawei.com > > Signed-off-by: Alex Chen > > Reviewed-by: Jun Piao > > Reviewed-by: Joseph Qi > > Acked-by: Changwei Ge > > Cc: Mark Fasheh > > Cc: Joel Becker > > Cc: Junxiao Bi > > Signed-off-by: Andrew Morton > > Signed-off-by: Linus Torvalds > > Signed-off-by: Ben Hutchings > > --- > > fs/ocfs2/file.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > >=20 > > --- a/fs/ocfs2/file.c > > +++ b/fs/ocfs2/file.c > > @@ -1130,6 +1130,13 @@ int ocfs2_setattr(struct dentry *dentry, > > dquot_initialize(inode); > > size_change =3D S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE; > > if (size_change) { > > + /* > > + * Here we should wait dio to finish before inode lock > > + * to avoid a deadlock between ocfs2_setattr() and > > + * ocfs2_dio_end_io_write() > > + */ > > + inode_dio_wait(inode); > > + > > status =3D ocfs2_rw_lock(inode, 1); > > if (status < 0) { > > mlog_errno(status); > > @@ -1149,8 +1156,6 @@ int ocfs2_setattr(struct dentry *dentry, > > if (status) > > goto bail_unlock; > > =20 > > - inode_dio_wait(inode); > > - > > if (i_size_read(inode) >=3D attr->ia_size) { > > if (ocfs2_should_order_data(inode)) { > > status =3D ocfs2_begin_ordered_truncate(inode, > >=20 > >=20 > > . > >=20 >=20 >=20 --=20 Ben Hutchings Sturgeon's Law: Ninety percent of everything is crap. --=-BNWVRJVxBCvZs5V5dgm3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEErCspvTSmr92z9o8157/I7JWGEQkFAlqAhQoACgkQ57/I7JWG EQkyQxAAlfa6JRzVLG5YYqQuNBs/1FpiRvZkQzAk4Ke2P7De/FNTwd6rpTm1zm+v 2hNkykyV7BnzxmzC4HVK60klSUzPptYFAmQ+/3Rtwfg8IRtF+BgkRp9k5KqnHBYR z102yWzPsToul8kHPq0aMns41cQnQybu4NxWkygPkMJEFMA60QKiHyNPUXzBGroo 5WI5sBaY2mNTmAg/MtchTbL6l9m6wd4jr1e3Cx08hl63sNEudd+wMUrDV7lCnWg1 curOlso8oZqMDWnAyZMfQyBXfmF05J2PHjwAo74LoWbMOiqPFfIdJUNgbuC5W3VS FBZgQsiBf4I1kCbzV6FSin8ZloPXOtoZDCqKgWitwsw0PkRgT8x7/HuLLVCYLnkv 2KVoSkrTb08GOs8huxmG9ABr9fLLXeOpbk8v8mXgp318l5GAsn20NyqY3Klk8MzB bM8WkYjluNwG9fDveMbJIc0ZeL7PEqJEJZL8ok/ha45tf8QS88GhvxKuUWFMcUts KHKMzlB5EMw4LswM8L3O5kkQapnJbgeEAj55cX5L3k/fJf0FmI9WpQC78kY4/5l3 ETxlGs3QL7msb8tY7rIx3PBTMvqqbyAX9tR75zpp6WD7GdYepZopk3lQlcOIE43B DbgvdWAlj8ND9eYQJCIawEJ2bb80szyXa7cMRJ4Roxd2RMuV+Qg= =CiNz -----END PGP SIGNATURE----- --=-BNWVRJVxBCvZs5V5dgm3--