Skip to content

Commit 2c4656d

Browse files
author
Miklos Szeredi
committed
fuse: fix copy_file_range cache issues
a) Dirty cache needs to be written back not just in the writeback_cache case, since the dirty pages may come from memory maps. b) The fuse_writeback_range() helper takes an inclusive interval, so the end position needs to be pos+len-1 instead of pos+len. Fixes: 88bc7d5 ("fuse: add support for copy_file_range()") Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 6b2fb79 commit 2c4656d

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

fs/fuse/file.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,25 +3325,21 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
33253325
if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb)
33263326
return -EXDEV;
33273327

3328-
if (fc->writeback_cache) {
3329-
inode_lock(inode_in);
3330-
err = fuse_writeback_range(inode_in, pos_in, pos_in + len);
3331-
inode_unlock(inode_in);
3332-
if (err)
3333-
return err;
3334-
}
3328+
inode_lock(inode_in);
3329+
err = fuse_writeback_range(inode_in, pos_in, pos_in + len - 1);
3330+
inode_unlock(inode_in);
3331+
if (err)
3332+
return err;
33353333

33363334
inode_lock(inode_out);
33373335

33383336
err = file_modified(file_out);
33393337
if (err)
33403338
goto out;
33413339

3342-
if (fc->writeback_cache) {
3343-
err = fuse_writeback_range(inode_out, pos_out, pos_out + len);
3344-
if (err)
3345-
goto out;
3346-
}
3340+
err = fuse_writeback_range(inode_out, pos_out, pos_out + len - 1);
3341+
if (err)
3342+
goto out;
33473343

33483344
if (is_unstable)
33493345
set_bit(FUSE_I_SIZE_UNSTABLE, &fi_out->state);

0 commit comments

Comments
 (0)