]> git.ipfire.org Git - thirdparty/linux.git/commit
nfsd: freeze c/mtime updates with outstanding WRITE_ATTRS delegation
authorJeff Layton <jlayton@kernel.org>
Wed, 30 Jul 2025 13:24:37 +0000 (09:24 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 21 Sep 2025 23:24:50 +0000 (19:24 -0400)
commite5e9b24ab8fa9e899d6627123d7d5ba0c317d267
treecf091d65bc964203e45a0fff098c668e357098a7
parentb40b1ba37ad5b6099c426765c4bc327c08b390b9
nfsd: freeze c/mtime updates with outstanding WRITE_ATTRS delegation

Instead of allowing the ctime to roll backward with a WRITE_ATTRS
delegation, set FMODE_NOCMTIME on the file and have it skip mtime and
ctime updates.

It is possible that the client will never send a SETATTR to set the
times before returning the delegation. Add two new bools to struct
nfs4_delegation:

dl_written: tracks whether the file has been written since the
delegation was granted. This is set in the WRITE and LAYOUTCOMMIT
handlers.

dl_setattr: tracks whether the client has sent at least one valid
mtime that can also update the ctime in a SETATTR.

When unlocking the lease for the delegation, clear FMODE_NOCMTIME. If
the file has been written, but no setattr for the delegated mtime and
ctime has been done, update the timestamps to current_time().

Suggested-by: NeilBrown <neil@brown.name>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nfsd/state.h