Skip to content

Commit f9a348e

Browse files
jtlaytonchucklever
authored andcommitted
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: 7e13f4f ("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>
1 parent e339967 commit f9a348e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/nfsd/vfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,15 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
470470
if (!iap->ia_valid)
471471
return 0;
472472

473-
iap->ia_valid |= ATTR_CTIME;
473+
/*
474+
* If ATTR_DELEG is set, then this is an update from a client that
475+
* holds a delegation. If this is an update for only the atime, the
476+
* ctime should not be changed. If the update contains the mtime
477+
* too, then ATTR_CTIME should already be set.
478+
*/
479+
if (!(iap->ia_valid & ATTR_DELEG))
480+
iap->ia_valid |= ATTR_CTIME;
481+
474482
return notify_change(&nop_mnt_idmap, dentry, iap, NULL);
475483
}
476484

0 commit comments

Comments
 (0)