Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp452751pxj; Tue, 18 May 2021 07:07:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmt/kWfsyo1BcAJJR9gEDChn9+KDIVBy2DRPEoozRZGeKkCXGIAguq0mgR6wB2OatotEtJ X-Received: by 2002:a05:6e02:1488:: with SMTP id n8mr4870633ilk.158.1621346833077; Tue, 18 May 2021 07:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621346833; cv=none; d=google.com; s=arc-20160816; b=Uo2MlCNr1TKIIKcPsKiznllOyPeP3EJ3qhfYmyrfCTj64hHXADZ+oZTmk2hE7Wsx1k tlDndY1nqcHnjn+R++Ct72Z7lY2uorjhI2RBnz6MB2Co6mgbqCdPTfMZ3doEgr+C2F3h aNtBBMFnWKkUJfT9uJzdMAplXZE25ZauPKLEkWhUuDJhgg2lw1ksxAuUBvDzK/30R8kl VHHZOe95on0AC1JhAwS/y5Od4WNMfSLS8/4uBU/Xb2RkP8qqsZsWXTi+vN9Z9uJrJDHp +DOH53sxox4PbhHS24MBxe7vRiVgegn9dhj1LDA/OelHcnTK2yDElr+HBQBQY5WedWfv OW8g== 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=VLgXxfa2kuOMNHjizrw0w2HQUd6fbZphd9ppP01eRq4=; b=tLXGMI9vMtJE4mJ+4/udxV4GdMXCeo24bafZdD5rARL2EBCOaS4P5xqUrn2PAtMkkE eXK1f+dx2wR6PJ+MenS+3N7PDlBOuvST6eXHqPOCjNXVqGXV7pHkQ1/qXSXe82xcHpSu /sHEiohJBReMXo2SDhpCEItrj4a1zj7vcwQcWSwkwRzBP8NcbxSudqODlFvfSTmzS/TF eCXh7M3avVTupQmAl4AXjCD3pJCd+kH5xLpnyuEINRmoNiqD6Fj8fwG8z/4VUpAeQed/ YgGL4wzM14+4nHD+Q563Pr1+Dk2n0jkVHkXUxSSLSkV7zmS7wXurZZDgZo1w+GShTls4 os+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zvX465ug; 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 x11si12907236ilp.53.2021.05.18.07.07.00; Tue, 18 May 2021 07:07:13 -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=zvX465ug; 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 S245125AbhEQPlK (ORCPT + 99 others); Mon, 17 May 2021 11:41:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:40800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243712AbhEQP0V (ORCPT ); Mon, 17 May 2021 11:26:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE5F36192D; Mon, 17 May 2021 14:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262182; bh=733M+gTPxvhRf4lI+v/Y3Y2ZT0Zb7pcf7r5FlUDrX/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zvX465ugisFc7HXSLOaHVVE9pWhoM9mK5JO8awi5FRFePhD49eK2H/P1lROgLNqa0 5IgqzoI/lRqGSXWsdEw12AmFMS42mDxY8qoY8/AjmHZR8G3wuzzpnwMIjRvBppTJ1A qH7z1hP+akQSB+WEa9F37PVU498v0xZa19hsCsLQ= 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.10 128/289] nfsd: ensure new clients break delegations Date: Mon, 17 May 2021 16:00:53 +0200 Message-Id: <20210517140309.466992515@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 55cf60b71cde..ac20f79bbedd 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