[PATCH v2 05/11] nfsd: set ctime when a SETATTR with delegated times changes other attributes
From: Jeff Layton
Date: Mon Nov 23 2026 - 07:59:40 EST
__nfsd_setattr() adds ATTR_CTIME only when ATTR_DELEG is clear, to keep
a delegated atime-only update from moving ctime. But ATTR_DELEG is set
for the whole iattr, so a holder's chmod or chown sent along with a
delegated atime changes the mode or owner without updating ctime.
Add ATTR_CTIME unless the request is a delegated atime-only update. A
delegated mtime whose ctime fails vetting now moves ctime to the current
time instead of leaving ctime alone.
Fixes: f9a348e0de19 ("nfsd: don't set the ctime on delegated atime updates")
Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
fs/nfsd/vfs.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 4a5674e583cc..7bc251d55c3c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -513,10 +513,12 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
/*
* If ATTR_DELEG is set, then this is an update from a client that
* holds a delegation. If this is an update for only the atime, the
- * ctime should not be changed. If the update contains the mtime
- * too, then ATTR_CTIME should already be set.
+ * ctime should not be changed. Any other attribute change, such as
+ * a mode or owner change sent along with a delegated atime, must
+ * update the ctime.
*/
- if (!(iap->ia_valid & ATTR_DELEG))
+ if (!(iap->ia_valid & ATTR_DELEG) ||
+ (iap->ia_valid & ~(ATTR_DELEG | ATTR_ATIME | ATTR_ATIME_SET)))
iap->ia_valid |= ATTR_CTIME;
return notify_change(&nop_mnt_idmap, dentry, iap, NULL);
--
2.56.1