[PATCH v2 04/11] nfsd: don't grant write delegations to NFSv4.0 clients on CLAIM_PREVIOUS

From: Jeff Layton

Date: Mon Nov 23 2026 - 07:59:30 EST


nfs4_open_delegation() refuses delegations for NFSv4.0 write opens on
CLAIM_NULL and CLAIM_FH, as its comment explains, but CLAIM_PREVIOUS
skips the check. An NFSv4.0 client reclaiming a write open during grace
can therefore get a write delegation, and NFSD can never complete a
GETATTR that the client sends before DELEGRETURN in the same compound.

Apply the same check to CLAIM_PREVIOUS.

Fixes: 1d3dd1d56ce8 ("NFSD: Enable write delegation support")
Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
fs/nfsd/nfs4state.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 5c2151b329c4..4b28553efc8d 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -7533,6 +7533,9 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open,
open->op_recall = false;
switch (open->op_claim_type) {
case NFS4_OPEN_CLAIM_PREVIOUS:
+ if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE &&
+ clp->cl_minorversion == 0)
+ goto out_no_deleg;
if (!cb_up)
open->op_recall = true;
break;

--
2.56.1