From 65687870ee849f333e55c2a022005ece6de32300 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Mon, 1 Jul 2024 14:56:24 -0700 Subject: [PATCH] ANDROID: fuse: Keep attributes consistent with Passthrough If writeback cache is enabled, and we attempt to use fuse passthrough, fuse will invalidate attributes on write, but will then ignore when the server attempts to update those attributes. Since the kernel is the arbiter of truth with writeback cache, passthrough holds the responsibility to keep these values updated. Signed-off-by: Daniel Rosenberg Bug: 333497409 Test: atest android.scopedstorage.cts.general.ScopedStorageDeviceTest Change-Id: I1ebc0d06f3d2b41a9cfb2af35f27989d25d96032 --- fs/fuse/passthrough.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c index acb469b2125f..ff46a11802e0 100644 --- a/fs/fuse/passthrough.c +++ b/fs/fuse/passthrough.c @@ -21,8 +21,19 @@ static void fuse_file_accessed(struct file *file) static void fuse_file_modified(struct file *file) { struct inode *inode = file_inode(file); + struct fuse_conn *fc = get_fuse_conn(inode); + struct fuse_file *ff = file->private_data; + struct file *backing_file = fuse_file_passthrough(ff); + struct inode *backing_inode = file_inode(backing_file); - fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE); + if (!fc->writeback_cache) { + fuse_invalidate_attr_mask(inode, FUSE_STATX_MODSIZE); + } else { + inode_set_mtime_to_ts(inode, inode_get_mtime(backing_inode)); + inode_set_ctime_to_ts(inode, inode_get_ctime(backing_inode)); + inode->i_blocks = backing_inode->i_blocks; + i_size_write(inode, i_size_read(backing_inode)); + } } ssize_t fuse_passthrough_read_iter(struct kiocb *iocb, struct iov_iter *iter)