Skip to content

Commit a2bc923

Browse files
author
Miklos Szeredi
committed
fuse: fix copy_file_range() in the writeback case
Prior to sending COPY_FILE_RANGE to userspace filesystem, we must flush all dirty pages in both the source and destination files. This patch adds the missing flush of the source file. Tested on libfuse-3.5.0 with: libfuse/example/passthrough_ll /mnt/fuse/ -o writeback libfuse/test/test_syscalls /mnt/fuse/tmp/test Fixes: 88bc7d5 ("fuse: add support for copy_file_range()") Cc: <stable@vger.kernel.org> # v4.20 Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 4a2abf9 commit a2bc923

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fs/fuse/file.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,6 +3110,7 @@ static ssize_t fuse_copy_file_range(struct file *file_in, loff_t pos_in,
31103110
{
31113111
struct fuse_file *ff_in = file_in->private_data;
31123112
struct fuse_file *ff_out = file_out->private_data;
3113+
struct inode *inode_in = file_inode(file_in);
31133114
struct inode *inode_out = file_inode(file_out);
31143115
struct fuse_inode *fi_out = get_fuse_inode(inode_out);
31153116
struct fuse_conn *fc = ff_in->fc;
@@ -3133,6 +3134,17 @@ static ssize_t fuse_copy_file_range(struct file *file_in, loff_t pos_in,
31333134
if (fc->no_copy_file_range)
31343135
return -EOPNOTSUPP;
31353136

3137+
if (fc->writeback_cache) {
3138+
inode_lock(inode_in);
3139+
err = filemap_write_and_wait_range(inode_in->i_mapping,
3140+
pos_in, pos_in + len);
3141+
if (!err)
3142+
fuse_sync_writes(inode_in);
3143+
inode_unlock(inode_in);
3144+
if (err)
3145+
return err;
3146+
}
3147+
31363148
inode_lock(inode_out);
31373149

31383150
if (fc->writeback_cache) {

0 commit comments

Comments
 (0)