Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp299839pxj; Tue, 18 May 2021 03:47:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0VanhSKQyJuZ4IYiGJMiqdy/D/y89tgUfjZ+jhNodbjEXG0LWL+molYqtCwhVPMWQ2KPk X-Received: by 2002:a17:906:c211:: with SMTP id d17mr5347986ejz.247.1621334867395; Tue, 18 May 2021 03:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621334867; cv=none; d=google.com; s=arc-20160816; b=p4hsDbI8cQ6QkzVm4YyYGsHQnqYid4uu+0HOnwVXc8dxiHCS/BM7uvtAqipa3vfcvz vTZ872GH+eCoJ1qQl9O+ci0KvWs4C+W6y+GNCQwL1EAoy42k7aES/vVSGaL0KJgEWnWR Y810CVHdFKuH6fS05AUv8oE8Hyy2RDJoEuqj6xC3j5gqWe6Okz+6CLi231d6+W89gnyq BqOcK2t2eSBrzD6xw890cMy7HWTlAc++4cG32cNcHsmwHJJlmy/DLU6cqatRPrww4+38 WZC4RzrjhhxpYBB8+MXaIzspdawy7zojJAkvy797cXPFmvkUkNqCrnoWD/Y4SIU/Tg3i hKWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0UwBPdmlDy1+dGy7fe6eyFjDwoR6htW5NxT1kxI7dpU=; b=xrK4KZ5+naUAiMslJi1BDwHhfZwAgWxkiyXMiZ1N1lnQNHwJglh/KbpAVR8S7eqjdY HaXKU/dmlJd90aJKZfoYpuf61PFBJ+3LPAcULtvgZmtWhAMCC6WgjINhdfkywrv9+KWA 7oCL0jMUCgNmgi9oeAV8hFo0N5eGXnBQaWO50xb2o5ypwiGh+fzp2wwD+OIyPuDhtwW7 o6RsOGA75LmSMLwuTgH3TnVM2DXYVtI1Cp3/B0+6qQzLhSwfGUQcWO5zEMUz/X0aftDq FxFJwaq073ag2L6cHIc+63pwFtiZsIt1DMpRACfLTn0k7ZUH2DsX6wpjVgRFhhMS5f2D s8tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="X69H8/fy"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd10si2287193edb.60.2021.05.18.03.47.09; Tue, 18 May 2021 03:47:47 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="X69H8/fy"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243721AbhEQPOh (ORCPT + 99 others); Mon, 17 May 2021 11:14:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:46224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242690AbhEQPEZ (ORCPT ); Mon, 17 May 2021 11:04:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D50F61A3E; Mon, 17 May 2021 14:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261699; bh=ndu9FePLXOefbmGDDiOmkTxihqTKEGCSW4XjpFD+QiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X69H8/fyYLnqDEiEYxFAhDU6IE2+cK3rce7265NWOdf0S6ncirpkifF2MI8BDKoQe psZCjU6X49Zy2Fng/TmWLltUU3t4tx7JtFbrYOyumEMOBOh+f4ML6f0vitizrQdiVu LEX0X60Eq8PsINPY5CyPxpFzX8xOXm5S59Uu52M0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "J. Bruce Fields" , Chuck Lever , Sasha Levin Subject: [PATCH 5.11 152/329] nfsd: ensure new clients break delegations Date: Mon, 17 May 2021 16:01:03 +0200 Message-Id: <20210517140307.253130105@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: J. Bruce Fields [ Upstream commit 217fd6f625af591e2866bebb8cda778cf85bea2e ] If nfsd already has an open file that it plans to use for IO from another, it may not need to do another vfs open, but it still may need to break any delegations in case the existing opens are for another client. Symptoms are that we may incorrectly fail to break a delegation on a write open from a different client, when the delegation-holding client already has a write open. Fixes: 28df3d1539de ("nfsd: clients don't need to break their own delegations") Signed-off-by: J. Bruce Fields Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4state.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a501bb9a2fac..eca36d804158 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4874,6 +4874,11 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, if (nf) nfsd_file_put(nf); + status = nfserrno(nfsd_open_break_lease(cur_fh->fh_dentry->d_inode, + access)); + if (status) + goto out_put_access; + status = nfsd4_truncate(rqstp, cur_fh, open); if (status) goto out_put_access; @@ -6856,11 +6861,20 @@ out: static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock) { struct nfsd_file *nf; - __be32 err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf); - if (!err) { - err = nfserrno(vfs_test_lock(nf->nf_file, lock)); - nfsd_file_put(nf); - } + __be32 err; + + err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_READ, &nf); + if (err) + return err; + fh_lock(fhp); /* to block new leases till after test_lock: */ + err = nfserrno(nfsd_open_break_lease(fhp->fh_dentry->d_inode, + NFSD_MAY_READ)); + if (err) + goto out; + err = nfserrno(vfs_test_lock(nf->nf_file, lock)); +out: + fh_unlock(fhp); + nfsd_file_put(nf); return err; } -- 2.30.2