[PATCH v2 09/11] nfsd: grant a plain read delegation when timestamps are wanted on a read open

From: Jeff Layton

Date: Mon Nov 23 2026 - 08:00:13 EST


A read open that wants delegated timestamps gets
OPEN_DELEGATE_READ_ATTRS_DELEG. Several clients can hold read
delegations at once, so delegating atime correctly would need exclusive
authority over atime or a merge of every read holder's times. NFSD
supports neither exclusive atime authority nor such a merge.

Grant OPEN_DELEGATE_READ instead. The want flag is a request, so
declining the attribute delegation complies with RFC 9754 section 5. The
XDR cases for OPEN_DELEGATE_READ_ATTRS_DELEG stay, since
open_delegation_type4 is on the wire.

Fixes: 6ae30d6eb26b ("nfsd: add support for delegated timestamps")
Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
fs/nfsd/nfs4state.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 645ad916d2ef..466416708072 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -7329,10 +7329,14 @@ nfs4_set_delegation(struct nfsd4_open *open,
* A read delegation can go to a client that holds a write open
* of the file: nfsd_breaker_owns_lease() keeps the holder's own
* opens from breaking it.
+ *
+ * Never OPEN_DELEGATE_READ_ATTRS_DELEG: delegating atime correctly
+ * would need exclusive authority over it, or merging the times of
+ * several read holders. The want flag is only a request.
*/
if (!nf && (open->op_share_access & NFS4_SHARE_ACCESS_READ)) {
nf = find_readable_file(fp);
- dl_type = deleg_ts ? OPEN_DELEGATE_READ_ATTRS_DELEG : OPEN_DELEGATE_READ;
+ dl_type = OPEN_DELEGATE_READ;
}

if (!nf)
@@ -7630,9 +7634,7 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open,
spin_unlock(&f->f_lock);
trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid);
} else {
- open->op_delegate_type = deleg_ts && nfs4_delegation_stat(dp, currentfh, &stat) ?
- OPEN_DELEGATE_READ_ATTRS_DELEG : OPEN_DELEGATE_READ;
- dp->dl_atime = stat.atime;
+ open->op_delegate_type = OPEN_DELEGATE_READ;
trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid);
}
nfs4_put_stid(&dp->dl_stid);

--
2.56.1