summary refs log tree commit diff
path: root/fs/fuse/inode.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2021-10-22 17:03:03 +0200
committerMiklos Szeredi <mszeredi@redhat.com>2021-10-28 09:45:32 +0200
commit04d82db0c557e074a5d898b43de81fe659b9cc5a (patch)
treeca73a400aeb8336e7cc47f26ab4dc9e760ed2c0f /fs/fuse/inode.c
parentc15016b7ae1caf77f80ae87a71745368ef651ba6 (diff)
downloadlinux-04d82db0c557e074a5d898b43de81fe659b9cc5a.tar.gz
fuse: move reverting attributes to fuse_change_attributes()
In case of writeback_cache fuse_fillattr() would revert the queried
attributes to the cached version.

Move this to fuse_change_attributes() in order to manage the writeback
logic in a central helper.  This will be necessary for patches that follow.

Only fuse_do_getattr() -> fuse_fillattr() uses the attributes after calling
fuse_change_attributes(), so this should not change behavior.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse/inode.c')
-rw-r--r--fs/fuse/inode.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index db33f2050f74..1ecc46dff93e 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -228,6 +228,19 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
 	struct timespec64 old_mtime;
 
 	spin_lock(&fi->lock);
+	/*
+	 * In case of writeback_cache enabled, writes update mtime, ctime and
+	 * may update i_size.  In these cases trust the cached value in the
+	 * inode.
+	 */
+	if (is_wb) {
+		attr->size = i_size_read(inode);
+		attr->mtime = inode->i_mtime.tv_sec;
+		attr->mtimensec = inode->i_mtime.tv_nsec;
+		attr->ctime = inode->i_ctime.tv_sec;
+		attr->ctimensec = inode->i_ctime.tv_nsec;
+	}
+
 	if ((attr_version != 0 && fi->attr_version > attr_version) ||
 	    test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) {
 		spin_unlock(&fi->lock);