Skip to contentSkip to conversation

NFS: honor UTIME_NOW atime with explicit mtime

PATCH New Avi Weiss 1 participant 1 message Oct 18

Subsystems (2)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 NFS: honor UTIME_NOW atime with explicit mtime

When utimensat() requests UTIME_NOW for atime and an explicit mtime, the VFS sets ATTR_ATIME but not ATTR_ATIME_SET (as it should). The delegated explicit-mtime path calls nfs_set_timestamps_to_ts(), which skips atime, but nfs_setattr() then clears ATTR_ATIME, allowing the syscall to succeed without updating atime.

The delegated explicit-mtime path already updates ctime locally. The VFS also supplies the requested atime value in ia_atime, even when ATTR_ATIME_SET is absent.

Check ATTR_ATIME instead of ATTR_ATIME_SET to also apply the UTIME_NOW atime value supplied by the VFS.

Fixes aba41e90aade ("NFSv4.2: fix setattr caching of TIME_[MODIFY|ACCESS]_SET when timestamps are delegated")

---
Reproduced on 7.0.0-38-generic with an NFSv4.2 wa delegation:
utimensat() returned success but left atime unchanged.

Tested the fix on 7.3.0-rc7+ also with a wa delegation. The same operation updated both atime and mtime correctly. A kprobe confirmed nfs_setattr() received flags including:
ATTR_ATIME, ATTR_MTIME, ATTR_CTIME, ATTR_MTIME_SET and ATTR_TIMES_SET; (0x10170) and returned 0.

 fs/nfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/inode.c +1 -1
index 3022454f7698..4fa6c5547ab8 100644
@@ -644,7 +644,7 @@ static void nfs_set_timestamps_to_ts(struct inode *inode, struct iattr *attr)
 		inode_maybe_inc_iversion(inode, updated);
 		cache_flags |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME;
 	}
-	if (attr->ia_valid & ATTR_ATIME_SET) {
+	if (attr->ia_valid & ATTR_ATIME) {
 		inode_set_atime_to_ts(inode, attr->ia_atime);
 		cache_flags |= NFS_INO_INVALID_ATIME;
 	}

base-commit: 32c52ec87d6245ee2d12ed5dd509e40062939b50

Signature · 1 line
2.43.0