[PATCH v2 0/7] nfsd/vfs: fix handling of delegated timestamp updates

Jeff Layton
2025-07-26T14:32:01Z

After my last posting, Trond pointed out that my interpretation of RFC
9754 was wrong. The "original time" as mentioned in the spec is the time
of the grant of the delegation, and not the current timestamp in the
inode before the update.

Given that, there is no longer a need to do any sort of complicated
handling of delegated timestamps at the VFS layer, so this set removes
inode_set_ctime_deleg(). We do however need a way to set a ctime that
isn't current_time() via notify_change(). This patchset adds an
ATTR_CTIME_SET flag, which mirrors ATTR_ATIME_SET and ATTR_MTIME_SET
semantics. The rest of the patchset reworks nfsd to properly vet
timestamp updates on its own and just call down into the OS to do a
normal notify_change().

With this patchset in place I haven't seen any git regression suite
failures yet (4 passes so far under kdevops in the "stress"
configuration).

I should point out that there is at least one potential problem with
this implementation:

The kernel does not block getattr operations when there is a delegation
outstanding. When the client issues read and write ops to the server,
while holding the delegation, the timestamps on the file get updated to
the server's time as usual. Later, the client will send a SETATTR (or a
CB_GETTTR reply) that may have times that are earlier than the
timestamps currently on the inode.

This means that userland applications running on the NFS server can
observe timestamps going backward. This applies even for the ctime. NFS
clients should be fine, as the server will do a CB_GETATTR to satisfy
them. Server-side applications can't do much else with the inode without
recalling the delegation, so my thinking is that the effect should be
"mostly harmless".

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Changes in v2:
- add ATTR_CTIME_SET and remove inode_set_ctime_deleg()
- track original timestamps in struct nfs4_delegation
- fix delegated timestamp updates to respect saved timestamps
- Link to v1: https://lore.kernel.org/r/20250722-nfsd-testing-v1-0-31321c7fc97f@kernel.org

---
Jeff Layton (7):
vfs: add ATTR_CTIME_SET flag
nfsd: ignore ATTR_DELEG when checking ia_valid before notify_change()
nfsd: use ATTR_CTIME_SET for delegated ctime updates
nfsd: track original timestamps in nfs4_delegation
nfsd: fix SETATTR updates for delegated timestamps
nfsd: fix timestamp updates in CB_GETATTR
vfs: remove inode_set_ctime_deleg()

fs/attr.c | 34 ++++++++++---------------
fs/inode.c | 73 -----------------------------------------------------
fs/nfsd/nfs4proc.c | 31 ++++++++++++++++++++++-
fs/nfsd/nfs4state.c | 44 +++++++++++++++++---------------
fs/nfsd/nfs4xdr.c | 5 ++--
fs/nfsd/state.h | 8 ++++++
fs/nfsd/vfs.c | 2 +-
include/linux/fs.h | 3 +--
8 files changed, 79 insertions(+), 121 deletions(-)
---
base-commit: b05f077b59098b4760e3f675b00a4e6a1ad4b0ad
change-id: 20250722-nfsd-testing-5e861a3cf3a0

Best regards,
--
Jeff Layton <jlayton@kernel.org>