[PATCH 2/9] fuse: force a ctime update after a fileattr_set call when in iomap mode

Darrick J. Wong
2025-09-16T00:36:35Z

In iomap mode, the kernel is in charge of driving ctime updates to
the fuse server and ignores updates coming from the fuse server.
Therefore, when someone calls fileattr_set to change file attributes, we
must force a ctime update.

Found by generic/277.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/fuse/ioctl.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index 57032eadca6c27..f5f7d806262cdf 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -548,8 +548,13 @@ int fuse_fileattr_set(struct mnt_idmap *idmap,
struct fuse_file *ff;
unsigned int flags = fa->flags;
struct fsxattr xfa;
+ struct file_kattr old_ma = { };
+ bool is_wb = (fuse_get_cache_mask(inode) & STATX_CTIME);
int err;

+ if (is_wb)
+ vfs_fileattr_get(dentry, &old_ma);
+
ff = fuse_priv_ioctl_prepare(inode);
if (IS_ERR(ff))
return PTR_ERR(ff);
@@ -573,6 +578,12 @@ int fuse_fileattr_set(struct mnt_idmap *idmap,

cleanup:
fuse_priv_ioctl_cleanup(inode, ff);
+ /*
+ * If we cache ctime updates and the fileattr changed, then force a
+ * ctime update.
+ */
+ if (is_wb && memcmp(&old_ma, fa, sizeof(old_ma)))
+ fuse_update_ctime(inode);

if (err == -ENOTTY)
err = -EOPNOTSUPP;