nfsd: don't set the ctime on delegated atime updates
authorJeff Layton <jlayton@kernel.org>
Wed, 16 Jul 2025 13:34:29 +0000 (09:34 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Tue, 5 Aug 2025 14:31:33 +0000 (10:31 -0400)
commitf9a348e0de19226fc3c7e81de7677d3fa2c4b2d8
tree81c5c704665d481c5d78e3649978664148e3a431
parente339967eecf1305557f7c697e1bc10b5cc495454
nfsd: don't set the ctime on delegated atime updates

Clients will typically precede a DELEGRETURN for a delegation with
delegated timestamp with a SETATTR to set the timestamps on the server
to match what the client has.

knfsd implements this by using the nfsd_setattr() infrastructure, which
will set ATTR_CTIME on any update that goes to notify_change(). This is
problematic as it means that the client will get a spurious ctime
update when updating the atime.

POSIX unfortunately doesn't phrase it succinctly, but updating the atime
due to reads should not update the ctime. In this case, the client is
sending a SETATTR to update the atime on the server to match its latest
value. The ctime should not be advanced in this case as that would
incorrectly indicate a change to the inode.

Fix this by not implicitly setting ATTR_CTIME when ATTR_DELEG is set in
__nfsd_setattr(). The decoder for FATTR4_WORD2_TIME_DELEG_MODIFY already
sets ATTR_CTIME, so this is sufficient to make it skip setting the ctime
on atime-only updates.

Fixes: 7e13f4f8d27d ("nfsd: handle delegated timestamps in SETATTR")
Cc: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/vfs.c