Re: [PATCH v2] fuse: use newer inode info when writeback cache is enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Miklos:

Thank you for the information, I have been able to reproduce the problem.

The new version of the patch as below. Previous fsx test is pass now. Need do more test, Can you help to test new patch? or send me your test case, I will test this.

Here is my test case, and is the problem this patch is trying to solve.
Case A:
mkdir /tmp/test
passthrough_ll -ocache=always,writeback /mnt/test/
echo "11111" > /tmp/test/fsx
ls -l /mnt/test/tmp/test/
echo "2222" >> /tmp/test/fsx
ls -l /mnt/test/tmp/test/

Case B:
mkdir /tmp/test
passthrough_ll -ocache=always,writeback /mnt/test/
passthrough_ll -ocache=always,writeback /mnt/test2/
echo "11111" > /tmp/test/fsx
ls -l /mnt/test/tmp/test/
ls -l /mnt/test2/tmp/test/
echo "222" >> /mnt/test/tmp/test/fsx
ls -l /mnt/test/tmp/test/
ls -l /mnt/test2/tmp/test/


diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index b9beb39a4a18..8e22a31b55c4 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -60,6 +60,10 @@ MODULE_PARM_DESC(max_user_congthresh,
 /** Congestion starts at 75% of maximum */
#define FUSE_DEFAULT_CONGESTION_THRESHOLD (FUSE_DEFAULT_MAX_BACKGROUND * 3 / 4)

+static inline bool attr_newer_than_local(struct fuse_attr *attr, struct inode *inode) {
+    return (attr->mtime > inode->i_mtime.tv_sec)
+ || ((attr->mtime == inode->i_mtime.tv_sec) && (attr->mtimensec > inode->i_mtime.tv_nsec));
+}
 #ifdef CONFIG_BLOCK
 static struct file_system_type fuseblk_fs_type;
 #endif
@@ -241,8 +245,10 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, * extend local i_size without keeping userspace server in sync. So,
         * attr->size coming from server can be stale. We cannot trust it.
         */
-       if (!is_wb || !S_ISREG(inode->i_mode))
+       if (!is_wb || !S_ISREG(inode->i_mode)
+ || (attr_newer_than_local(attr, inode) && !inode_is_open_for_write(inode))) {
                i_size_write(inode, attr->size);
+       }
        spin_unlock(&fi->lock);

        if (!is_wb && S_ISREG(inode->i_mode)) {

On 2021/6/22 23:19, Miklos Szeredi wrote:
On Tue, 22 Jun 2021 at 14:25, Fengnan Chang <changfengnan@xxxxxxxx> wrote:

Unh, it seems i_writecount not work.
If we modify file through lowerfs, i_writecount won't change, but the
size already changed.
For example:
echo "111" > /lowerfs/test
ls -l /upper/test
echo "2222" >> /lowerfs/test
ls -l /upper/test

So, can you describe your test enviroment? including kernel version and
fsx parameters, I will check it.

linux-5.13-rc5 + patch
mkdir /tmp/test
libfuse/example/passthrough_ll -ocache=always,writeback /mnt/fuse/
fsx-linux -N 1000000 /mnt/fuse/tmp/test/fsx

Thanks,
Miklos




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux