mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fuse: force sync attr when inode is invalidated
@ 2022-06-21 12:56 wubo
  2022-06-23 18:38 ` Vivek Goyal
  0 siblings, 1 reply; 5+ messages in thread
From: wubo @ 2022-06-21 12:56 UTC (permalink / raw)
  To: miklos; +Cc: linux-fsdevel, linux-kernel, Wu Bo

From: Wu Bo <bo.wu@vivo.com>

Now the fuse driver only trust it's local inode size when
writeback_cache is enabled. Even the userspace server tell the driver
the inode cache is invalidated, the size attrabute will not update. And
will keep it's out-of-date size till the inode cache is dropped. This is
not reasonable.

Signed-off-by: Wu Bo <bo.wu@vivo.com>
---
 fs/fuse/inode.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 8c0665c5dff8..a4e62c7f2b83 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -162,6 +162,11 @@ static ino_t fuse_squash_ino(u64 ino64)
 	return ino;
 }
 
+static bool fuse_force_sync(struct fuse_inode *fi)
+{
+	return fi->i_time == 0;
+}
+
 void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
 				   u64 attr_valid, u32 cache_mask)
 {
@@ -222,8 +227,10 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
 u32 fuse_get_cache_mask(struct inode *inode)
 {
 	struct fuse_conn *fc = get_fuse_conn(inode);
+	struct fuse_inode *fi = get_fuse_inode(inode);
+	bool is_force_sync = fuse_force_sync(fi);
 
-	if (!fc->writeback_cache || !S_ISREG(inode->i_mode))
+	if (!fc->writeback_cache || !S_ISREG(inode->i_mode) || is_force_sync)
 		return 0;
 
 	return STATX_MTIME | STATX_CTIME | STATX_SIZE;
@@ -437,6 +444,7 @@ int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid,
 	fi = get_fuse_inode(inode);
 	spin_lock(&fi->lock);
 	fi->attr_version = atomic64_inc_return(&fc->attr_version);
+	fi->i_time = 0;
 	spin_unlock(&fi->lock);
 
 	fuse_invalidate_attr(inode);
-- 
2.35.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-28  4:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 12:56 [PATCH] fuse: force sync attr when inode is invalidated wubo
2022-06-23 18:38 ` Vivek Goyal
2022-06-24  2:27   ` [External] " Jiachen Zhang
2022-06-24  6:24     ` Jiachen Zhang
2022-06-28  4:20       ` Wu Bo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®