mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 05:39:54 -04:00
UPSTREAM: fuse: invalidate inode attr in writeback cache mode
Under writeback mode, inode->i_blocks is not updated, making utils du read st.blocks as 0. For example, when using virtiofs (cache=always & nondax mode) with writeback_cache enabled, writing a new file and check its disk usage with du, du reports 0 usage. # uname -r 5.6.0-rc6+ # mount -t virtiofs virtiofs /mnt/virtiofs # rm -f /mnt/virtiofs/testfile # create new file and do extend write # xfs_io -fc "pwrite 0 4k" /mnt/virtiofs/testfile wrote 4096/4096 bytes at offset 0 4 KiB, 1 ops; 0.0001 sec (28.103 MiB/sec and 7194.2446 ops/sec) # du -k /mnt/virtiofs/testfile 0 <==== disk usage is 0 # stat -c %s,%b /mnt/virtiofs/testfile 4096,0 <==== i_size is correct, but st_blocks is 0 Fix it by invalidating attr in fuse_flush(), so we get up-to-date attr from server on next getattr. Change-Id: I524134d71b0b304ce7998604f8263c0462b6c4de Signed-off-by: Eryu Guan <eguan@linux.alibaba.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
1766a0200b
commit
f849366aac
1 changed files with 10 additions and 1 deletions
|
|
@ -454,8 +454,9 @@ static int fuse_flush(struct file *file, fl_owner_t id)
|
|||
if (fuse_is_bad(inode))
|
||||
return -EIO;
|
||||
|
||||
err = 0;
|
||||
if (fc->no_flush)
|
||||
return 0;
|
||||
goto inval_attr_out;
|
||||
|
||||
err = write_inode_now(inode, 1);
|
||||
if (err)
|
||||
|
|
@ -484,6 +485,14 @@ static int fuse_flush(struct file *file, fl_owner_t id)
|
|||
fc->no_flush = 1;
|
||||
err = 0;
|
||||
}
|
||||
|
||||
inval_attr_out:
|
||||
/*
|
||||
* In memory i_blocks is not maintained by fuse, if writeback cache is
|
||||
* enabled, i_blocks from cached attr may not be accurate.
|
||||
*/
|
||||
if (!err && fc->writeback_cache)
|
||||
fuse_invalidate_attr(inode);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue