[PATCH 05/11] nfsd: set ctime when a SETATTR with delegated times changes other attributes
From: Jeff Layton
Date: Fri Nov 20 2026 - 11:42:10 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 failed vetting now gets ctime = now instead
of no ctime update.
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 4f3e480a3981..c0d10c263a93 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -514,10 +514,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