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>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: Tom Haynes <loghyr@gmail.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH v3 8/8] nfsd: raise delegated time floors after a size-changing SETATTR
Date: Mon, 09 Nov 2026 15:36:49 -0500 [thread overview]
Message-ID: <20261109-deleg-cb-getattr-times-v3-8-710c7244a6ea@kernel.org> (raw)
In-Reply-To: <20261109-deleg-cb-getattr-times-v3-0-710c7244a6ea@kernel.org>
A size-changing SETATTR stamps c/mtime on the server
(__nfsd_setattr(), RFC 8881 section 18.30.4), but dl_mtime and dl_ctime
stay at their earlier values. A holder mtime from before the truncate
still passes vetting and moves mtime back past the truncate. The Linux
client can send one: if a delegation return starts while
nfs_vmtruncate() has i_lock dropped, DELEGRETURN carries the
pre-truncate mtime.
When the SETATTR uses a timestamp delegation's stateid, have
nfsd_setattr() record the c/mtime the size change set in dl_mtime and
dl_ctime. A holder time at or before the server's own stamp is stale.
Fixes: 6ae30d6eb26b ("nfsd: add support for delegated timestamps")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfsd/nfs4proc.c | 4 ++++
fs/nfsd/nfs4state.c | 10 +++++++---
fs/nfsd/vfs.h | 2 +-
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index a65e13f0f77a..7fef904c3366 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1379,6 +1379,10 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
status = nfs_ok;
}
}
+ } else if (st && (st->sc_type & SC_TYPE_DELEG) &&
+ deleg_attrs_deleg(delegstateid(st)->dl_type)) {
+ /* Have nfsd_setattr() record the c/mtime the size change sets */
+ attrs.na_deleg = delegstateid(st);
}
if (status)
goto out_err;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 03e694f635db..606c4b469728 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -10812,8 +10812,9 @@ void nfsd4_vet_deleg_attrs(struct iattr *iattr, struct nfs4_delegation *dp,
* @iattr: vetted attributes, not the copy notify_change() altered
* @dp: timestamp delegation whose holder supplied the times
*
- * Set dl_*time to the times applied, so a stale holder time can't move
- * them backward and a repeated CB_GETATTR reply isn't reapplied.
+ * Set dl_*time to the times applied, or to the c/mtime a size change
+ * stamped, so a stale holder time can't move them backward and a repeated
+ * CB_GETATTR reply isn't reapplied.
*
* Context: Caller holds the inode_lock.
*/
@@ -10830,9 +10831,12 @@ void nfsd4_record_deleg_attrs(const struct iattr *iattr,
dp->dl_mtime = iattr->ia_mtime;
/* Don't let DELEGRETURN stamp over the holder's mtime */
dp->dl_setattr = true;
+ } else if (iattr->ia_valid & ATTR_SIZE) {
+ /* RFC 8881 section 18.30.4: a size change sets mtime */
+ dp->dl_mtime = inode_get_mtime(inode);
}
/* Ctime may be "now", or inode_set_ctime_deleg() kept a later one */
- if (iattr->ia_valid & ATTR_CTIME)
+ if (iattr->ia_valid & (ATTR_CTIME | ATTR_SIZE))
dp->dl_ctime = inode_get_ctime(inode);
}
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 78cfa0dcaf5c..34ec8293e7b8 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -103,7 +103,7 @@ struct nfsd_attrs {
struct posix_acl *na_pacl; /* input */
struct posix_acl *na_dpacl; /* input */
- /* input: vet and record these FATTR4_WORD2_TIME_DELEG_* times */
+ /* input: timestamp delegation to vet and record times against */
struct nfs4_delegation *na_deleg;
u32 na_deleg_attrs;
--
2.56.0
prev parent reply other threads:[~2026-11-09 20:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 20:36 [PATCH v3 0/8] nfsd: more delegated timestamp fixes Jeff Layton
2026-11-09 20:36 ` [PATCH v3 1/8] nfsd: Report vetted delegated timestamps in GETATTR replies Jeff Layton
2026-11-09 20:36 ` [PATCH v3 2/8] nfsd: Honor delegated timestamps when change and size match Jeff Layton
2026-11-09 20:36 ` [PATCH v3 3/8] nfsd: don't stamp over an applied delegated mtime at DELEGRETURN Jeff Layton
2026-11-09 20:36 ` [PATCH v3 4/8] nfsd: don't vet delegated times against an exclusive-create verifier Jeff Layton
2026-11-09 20:36 ` [PATCH v3 5/8] nfsd: mark the delegation written on COPY/CLONE instead of stamping c/mtime Jeff Layton
2026-11-09 20:36 ` [PATCH v3 6/8] fs: check a fine-grained time before clamping a delegated ctime Jeff Layton
2026-11-09 20:36 ` [PATCH v3 7/8] nfsd: check a fine-grained time before clamping a delegated mtime Jeff Layton
2026-11-09 20:36 ` Jeff Layton [this message]
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=20261109-deleg-cb-getattr-times-v3-8-710c7244a6ea@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=loghyr@gmail.com \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®