Skip to content

Commit 5b545a5

Browse files
author
Frantisek Hrbata
committed
Merge: fs: allow cross-vfsmount reflink/dedupe
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1373 Bugzilla: http://bugzilla.redhat.com/2088133 Tested: fstests generic/373 commit 9f5710b Author: Josef Bacik <josef@toxicpanda.com> Date: Fri Feb 18 09:38:14 2022 -0500 fs: allow cross-vfsmount reflink/dedupe Currently we disallow reflink and dedupe if the two files aren't on the same vfsmount. However we really only need to disallow it if they're not on the same super block. It is very common for btrfs to have a main subvolume that is mounted and then different subvolumes mounted at different locations. It's allowed to reflink between these volumes, but the vfsmount check disallows this. Instead fix dedupe to check for the same superblock, and simply remove the vfsmount check for reflink as it already does the superblock check. Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org> Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com> Signed-off-by: Josef Bacik's avatarJosef Bacik <josef@toxicpanda.com> Reviewed-by: default avatarDavid Sterba <dsterba@suse.com> Signed-off-by: default avatarDavid Sterba <dsterba@suse.com> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com> Approved-by: Bill O'Donnell <bodonnel@redhat.com> Approved-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
2 parents c4bec8f + e6c16bc commit 5b545a5

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

fs/ioctl.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd,
236236

237237
if (!src_file.file)
238238
return -EBADF;
239-
ret = -EXDEV;
240-
if (src_file.file->f_path.mnt != dst_file->f_path.mnt)
241-
goto fdput;
242239
cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff,
243240
olen, 0);
244241
if (cloned < 0)
@@ -247,7 +244,6 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd,
247244
ret = -EINVAL;
248245
else
249246
ret = 0;
250-
fdput:
251247
fdput(src_file);
252248
return ret;
253249
}

fs/remap_range.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,6 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in,
362362

363363
WARN_ON_ONCE(remap_flags & REMAP_FILE_DEDUP);
364364

365-
/*
366-
* FICLONE/FICLONERANGE ioctls enforce that src and dest files are on
367-
* the same mount. Practically, they only need to be on the same file
368-
* system.
369-
*/
370365
if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb)
371366
return -EXDEV;
372367

@@ -458,7 +453,7 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
458453
goto out_drop_write;
459454

460455
ret = -EXDEV;
461-
if (src_file->f_path.mnt != dst_file->f_path.mnt)
456+
if (file_inode(src_file)->i_sb != file_inode(dst_file)->i_sb)
462457
goto out_drop_write;
463458

464459
ret = -EISDIR;

0 commit comments

Comments
 (0)