Skip to content

Commit c2c6d3c

Browse files
Luis Henriquesidryomov
authored andcommitted
ceph: add destination file data sync before doing any remote copy
If we try to copy into a file that was just written, any data that is remote copied will be overwritten by our buffered writes once they are flushed.  When this happens, the call to invalidate_inode_pages2_range will also return a -EBUSY error. This patch fixes this by also sync'ing the destination file before starting any copy. Fixes: 503f82a ("ceph: support copy_file_range file operation") Signed-off-by: Luis Henriques <lhenriques@suse.com> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 6510223 commit c2c6d3c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fs/ceph/file.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,10 +1931,17 @@ static ssize_t ceph_copy_file_range(struct file *src_file, loff_t src_off,
19311931
if (!prealloc_cf)
19321932
return -ENOMEM;
19331933

1934-
/* Start by sync'ing the source file */
1934+
/* Start by sync'ing the source and destination files */
19351935
ret = file_write_and_wait_range(src_file, src_off, (src_off + len));
1936-
if (ret < 0)
1936+
if (ret < 0) {
1937+
dout("failed to write src file (%zd)\n", ret);
1938+
goto out;
1939+
}
1940+
ret = file_write_and_wait_range(dst_file, dst_off, (dst_off + len));
1941+
if (ret < 0) {
1942+
dout("failed to write dst file (%zd)\n", ret);
19371943
goto out;
1944+
}
19381945

19391946
/*
19401947
* We need FILE_WR caps for dst_ci and FILE_RD for src_ci as other

0 commit comments

Comments
 (0)