summaryrefslogtreecommitdiffstats
path: root/fs/read_write.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-10-29 19:41:21 -0400
committerDave Chinner <david@fromorbit.com>2018-10-29 19:41:21 -0400
commit2e5dfc99f2e61c42083ba742395e7a7b353513d1 (patch)
tree48bc800424405b56153ed8c8997847c8ed9aaf14 /fs/read_write.c
parent6095028b455d775e369ae27875f698ff0f6fdeb8 (diff)
vfs: combine the clone and dedupe into a single remap_file_range
Combine the clone_file_range and dedupe_file_range operations into a single remap_file_range file operation dispatch since they're fundamentally the same operation. The differences between the two can be made in the prep functions. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r--fs/read_write.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 734c5661fb69..766bdcb381f3 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1588,9 +1588,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in,
1588 * Try cloning first, this is supported by more file systems, and 1588 * Try cloning first, this is supported by more file systems, and
1589 * more efficient if both clone and copy are supported (e.g. NFS). 1589 * more efficient if both clone and copy are supported (e.g. NFS).
1590 */ 1590 */
1591 if (file_in->f_op->clone_file_range) { 1591 if (file_in->f_op->remap_file_range) {
1592 ret = file_in->f_op->clone_file_range(file_in, pos_in, 1592 ret = file_in->f_op->remap_file_range(file_in, pos_in,
1593 file_out, pos_out, len); 1593 file_out, pos_out, len, 0);
1594 if (ret == 0) { 1594 if (ret == 0) {
1595 ret = len; 1595 ret = len;
1596 goto done; 1596 goto done;
@@ -1849,7 +1849,7 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in,
1849 (file_out->f_flags & O_APPEND)) 1849 (file_out->f_flags & O_APPEND))
1850 return -EBADF; 1850 return -EBADF;
1851 1851
1852 if (!file_in->f_op->clone_file_range) 1852 if (!file_in->f_op->remap_file_range)
1853 return -EOPNOTSUPP; 1853 return -EOPNOTSUPP;
1854 1854
1855 ret = remap_verify_area(file_in, pos_in, len, false); 1855 ret = remap_verify_area(file_in, pos_in, len, false);
@@ -1860,8 +1860,8 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in,
1860 if (ret) 1860 if (ret)
1861 return ret; 1861 return ret;
1862 1862
1863 ret = file_in->f_op->clone_file_range(file_in, pos_in, 1863 ret = file_in->f_op->remap_file_range(file_in, pos_in,
1864 file_out, pos_out, len); 1864 file_out, pos_out, len, 0);
1865 if (!ret) { 1865 if (!ret) {
1866 fsnotify_access(file_in); 1866 fsnotify_access(file_in);
1867 fsnotify_modify(file_out); 1867 fsnotify_modify(file_out);
@@ -2006,7 +2006,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
2006 goto out_drop_write; 2006 goto out_drop_write;
2007 2007
2008 ret = -EINVAL; 2008 ret = -EINVAL;
2009 if (!dst_file->f_op->dedupe_file_range) 2009 if (!dst_file->f_op->remap_file_range)
2010 goto out_drop_write; 2010 goto out_drop_write;
2011 2011
2012 if (len == 0) { 2012 if (len == 0) {
@@ -2014,8 +2014,8 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
2014 goto out_drop_write; 2014 goto out_drop_write;
2015 } 2015 }
2016 2016
2017 ret = dst_file->f_op->dedupe_file_range(src_file, src_pos, 2017 ret = dst_file->f_op->remap_file_range(src_file, src_pos, dst_file,
2018 dst_file, dst_pos, len); 2018 dst_pos, len, REMAP_FILE_DEDUP);
2019out_drop_write: 2019out_drop_write:
2020 mnt_drop_write_file(dst_file); 2020 mnt_drop_write_file(dst_file);
2021 2021