Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, NeilBrown <neil@brown.name>,
	 Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>,
	Christian Brauner <brauner@kernel.org>
Cc: "Aurélien Couderc" <aurelien.couderc2002@gmail.com>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jeff Layton" <jlayton@kernel.org>
Subject: [PATCH v2 09/11] nfsd: grant a plain read delegation when timestamps are wanted on a read open
Date: Mon, 23 Nov 2026 04:59:12 -0800	[thread overview]
Message-ID: <20261123-delegts-fixes-v2-9-960ce0fb2fed@kernel.org> (raw)
In-Reply-To: <20261123-delegts-fixes-v2-0-960ce0fb2fed@kernel.org>

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@kernel.org>
---
 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


  parent reply	other threads:[~2026-11-23 12:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 12:59 [PATCH v2 00/11] nfsd: various delegated timestamp fixes Jeff Layton
2026-11-23 12:59 ` [PATCH v2 01/11] nfsd: don't hold inode_lock while waiting for a delegation in nfsd_setattr() Jeff Layton
2026-11-23 12:59 ` [PATCH v2 02/11] nfsd: take freeze protection before updating delegation timestamps Jeff Layton
2026-11-23 12:59 ` [PATCH v2 03/11] nfsd: count a delegation in cl_delegs_in_recall only once Jeff Layton
2026-11-23 12:59 ` [PATCH v2 04/11] nfsd: don't grant write delegations to NFSv4.0 clients on CLAIM_PREVIOUS Jeff Layton
2026-11-23 12:59 ` [PATCH v2 05/11] nfsd: set ctime when a SETATTR with delegated times changes other attributes Jeff Layton
2026-11-23 12:59 ` [PATCH v2 06/11] nfsd: pin the client while a GETATTR holds a conflicting delegation Jeff Layton
2026-11-23 12:59 ` [PATCH v2 07/11] nfsd: recall when a CB_GETATTR reply omits the size Jeff Layton
2026-11-23 12:59 ` [PATCH v2 08/11] nfsd: apply delegated times in a separate times-only setattr Jeff Layton
2026-11-23 12:59 ` Jeff Layton [this message]
2026-11-23 12:59 ` [PATCH v2 10/11] nfsd: check fi_had_conflict under deleg_lock before hashing a delegation Jeff Layton
2026-11-23 12:59 ` [PATCH v2 11/11] nfsd: take the write delegation grant stat before hashing Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123-delegts-fixes-v2-9-960ce0fb2fed@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=aurelien.couderc2002@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cel@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox