From 87eb5eb2423213ac0e7315ce5d275f1ff80e0263 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jul 2018 23:57:03 +0200 Subject: [PATCH] vfs: dedupe: rationalize args Clean up f_op->dedupe_file_range() interface. 1) Use loff_t for offsets and length instead of u64 2) Order the arguments the same way as {copy|clone}_file_range(). Signed-off-by: Miklos Szeredi Reviewed-by: Darrick J. Wong --- fs/btrfs/ctree.h | 5 +++-- fs/btrfs/ioctl.c | 7 ++++--- fs/ocfs2/file.c | 12 ++++++------ fs/read_write.c | 4 ++-- fs/xfs/xfs_file.c | 12 ++++++------ include/linux/fs.h | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 1c7c13334423..d9d924017dfb 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3247,8 +3247,9 @@ void btrfs_get_block_group_info(struct list_head *groups_list, struct btrfs_ioctl_space_info *space); void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info, struct btrfs_ioctl_balance_args *bargs); -int btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, - struct file *dst_file, u64 dst_loff); +int btrfs_dedupe_file_range(struct file *src_file, loff_t src_loff, + struct file *dst_file, loff_t dst_loff, + u64 olen); /* file.c */ int __init btrfs_auto_defrag_init(void); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 94dc8e6c44ce..755c9a306321 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3600,8 +3600,9 @@ out_free: return ret; } -int btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, - struct file *dst_file, u64 dst_loff) +int btrfs_dedupe_file_range(struct file *src_file, loff_t src_loff, + struct file *dst_file, loff_t dst_loff, + u64 olen) { struct inode *src = file_inode(src_file); struct inode *dst = file_inode(dst_file); @@ -3616,7 +3617,7 @@ int btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, return -EINVAL; } - return btrfs_extent_same(src, loff, olen, dst, dst_loff); + return btrfs_extent_same(src, src_loff, olen, dst, dst_loff); } static int clone_finish_inode_update(struct btrfs_trans_handle *trans, diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index f96f018463f7..9fa35cb6f6e0 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2537,13 +2537,13 @@ static int ocfs2_file_clone_range(struct file *file_in, len, false); } -static int ocfs2_file_dedupe_range(struct file *src_file, - u64 loff, - u64 len, - struct file *dst_file, - u64 dst_loff) +static int ocfs2_file_dedupe_range(struct file *file_in, + loff_t pos_in, + struct file *file_out, + loff_t pos_out, + u64 len) { - return ocfs2_reflink_remap_range(src_file, loff, dst_file, dst_loff, + return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, len, true); } diff --git a/fs/read_write.c b/fs/read_write.c index fa64e51ef4cf..c31794f92c2c 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -2049,8 +2049,8 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) info->status = -EINVAL; } else { deduped = dst_file->f_op->dedupe_file_range(file, off, - len, dst_file, - info->dest_offset); + dst_file, + info->dest_offset, len); if (deduped == -EBADE) info->status = FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 547ef7e8aec1..0f40ba54d83f 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -935,13 +935,13 @@ xfs_file_clone_range( STATIC int xfs_file_dedupe_range( - struct file *src_file, - u64 loff, - u64 len, - struct file *dst_file, - u64 dst_loff) + struct file *file_in, + loff_t pos_in, + struct file *file_out, + loff_t pos_out, + u64 len) { - return xfs_reflink_remap_range(src_file, loff, dst_file, dst_loff, + return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, len, true); } diff --git a/include/linux/fs.h b/include/linux/fs.h index b81c4b7e339f..a8fee2f44981 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1749,7 +1749,7 @@ struct file_operations { loff_t, size_t, unsigned int); int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); - int (*dedupe_file_range)(struct file *, u64, u64, struct file *, + int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); } __randomize_layout; -- 2.30.2