Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1800947ybt; Thu, 2 Jul 2020 14:20:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWv/OILHTmYhTnvHkYQuXzRA+Ynq2VWxTtkJaLd8Kokf9V/1JxD45NMqfFbyregtbf0iQ7 X-Received: by 2002:a05:6402:128c:: with SMTP id w12mr26425656edv.65.1593724810844; Thu, 02 Jul 2020 14:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593724810; cv=none; d=google.com; s=arc-20160816; b=eVFlAuIWoy9kjZO+GUE0xmaY2GbVFPMMUPAObV+LwxPdl5IZxcAaFADunpH7yhMTle Ev6G251Q6dtXiq8/8s73bMhyqK25k0FWhfadtHLV9KcHIqepDJlNKwFZAbO942yttg4K g/W1C7uiGC66HBf//+kwFr1cw2rddkbkNOEYfXRI8Fz0Gzr7MteqntuUs48XvopeIRMw 76ESG23jI9mqus5nZm+/FWFLTz0AQFLbJsyO4LFcBfaYGXwFP6oGfPxQAtAPYJKy0oeb Yh3Hch33+sVWY5cGY5sxw0HIKUWHJh/kYSdNeI1z5HhRmKznD4JX6pN9YB9bD3IIZlAc 4LdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hT1bjIUsESieOmQ2gAqV0wF0uQf9mitDhHlnGxeSBqc=; b=Zme/NnmogZYM2xFEwUQOF/QNmYDukBx1mt9mj3CGB4vxcZD+g9Lq9O/81gJ0hnxSHM TJLfa+a6dl1/bhspyvAArqnlkJnCHO+LRtxuOpmXa8cXG4SY2xKxv9o+nR0gbqr5qpAb lbdL8JaWsrCtDmKkc2mPRjiKPbdt/3Xs1eg3I2LpnfA7EfEYp7pCZp6cHaLdBy4qbtQg J9WztXqm/6YDygIdGmx25YrWALVgKDbpQN63eTkY2wC/B8rQZE7Hq/+o5nrJ+AqrZeJz zaLNJZhCJtDsu+g0vACaRJfAgCKF01i4poitxOk0hu2MHOJGbyS/bic9MxMZ3pF370ja 6Yng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si6461396edy.595.2020.07.02.14.19.48; Thu, 02 Jul 2020 14:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726257AbgGBVRV (ORCPT + 99 others); Thu, 2 Jul 2020 17:17:21 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:41926 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgGBVRU (ORCPT ); Thu, 2 Jul 2020 17:17:20 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id B9B9E1C0BD2; Thu, 2 Jul 2020 23:17:18 +0200 (CEST) Date: Thu, 2 Jul 2020 23:17:17 +0200 From: Pavel Machek To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Junxiao Bi , Joseph Qi , Changwei Ge , Gang He , Joel Becker , Jun Piao , Mark Fasheh , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman Subject: Re: [PATCH 4.19 114/131] ocfs2: avoid inode removal while nfsd is accessing it Message-ID: <20200702211717.GC5787@amd> References: <20200629153502.2494656-1-sashal@kernel.org> <20200629153502.2494656-115-sashal@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="E13BgyNx05feLLmH" Content-Disposition: inline In-Reply-To: <20200629153502.2494656-115-sashal@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --E13BgyNx05feLLmH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > commit 4cd9973f9ff69e37dd0ba2bd6e6423f8179c329a upstream. >=20 > Patch series "ocfs2: fix nfsd over ocfs2 issues", v2. >=20 > This is a series of patches to fix issues on nfsd over ocfs2. patch 1 > is to avoid inode removed while nfsd access it patch 2 & 3 is to fix a > panic issue. >=20 > This patch (of 4): >=20 > When nfsd is getting file dentry using handle or parent dentry of some > dentry, one cluster lock is used to avoid inode removed from other node, > but it still could be removed from local node, so use a rw lock to avoid > this. This causes locking imbalance: > @@ -2851,6 +2857,11 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, i= nt ex) > if (ocfs2_is_hard_readonly(osb)) > return -EROFS; > =20 > + if (ex) > + down_write(&osb->nfs_sync_rwlock); > + else > + down_read(&osb->nfs_sync_rwlock); > + > if (ocfs2_mount_local(osb)) > return 0; > =2E.. status =3D ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE :LKM_PR= MODE, 0, 0); ... return status; } =09 When ocfs2_nfs_sync_lock() returns error, caller can not know if the lock was taken or not. ocfs2_get_dentry() for example will not call ocfs2_nfs_sync_unlock() if sync_lock() failed, resulting in lock imbalance if ocfs2_cluster_lock() fails. (Totally untested). Signed-off-by: Pavel Machek (CIP) Best regards, Pavel diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index c141b06811a6..8149fb6f1f0d 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2867,9 +2867,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int= ex) =20 status =3D ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE, 0, 0); - if (status < 0) + if (status < 0) { mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status); =20 + if (ex) + up_write(&osb->nfs_sync_rwlock); + else + up_read(&osb->nfs_sync_rwlock); + } + return status; } =20 Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --E13BgyNx05feLLmH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl7+Tt0ACgkQMOfwapXb+vLHKQCglu8bO4mSJD84VWxD5b0FwUQr XiEAoKfoGKNzQpQxO5wXIPTp0yT/IRZA =BuAt -----END PGP SIGNATURE----- --E13BgyNx05feLLmH--