Skip to content

Commit 8b044e1

Browse files
committed
btrfs: use struct btrfs_inode inside btrfs_remap_file_range()
Use a struct btrfs_inode to btrfs_remap_file_range() as it's an internal helper, allowing to remove some use of BTRFS_I. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 61dbdeb commit 8b044e1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

fs/btrfs/reflink.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -865,19 +865,19 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
865865
struct file *dst_file, loff_t destoff, loff_t len,
866866
unsigned int remap_flags)
867867
{
868-
struct inode *src_inode = file_inode(src_file);
869-
struct inode *dst_inode = file_inode(dst_file);
868+
struct btrfs_inode *src_inode = BTRFS_I(file_inode(src_file));
869+
struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
870870
bool same_inode = dst_inode == src_inode;
871871
int ret;
872872

873873
if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
874874
return -EINVAL;
875875

876876
if (same_inode) {
877-
btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
877+
btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP);
878878
} else {
879-
lock_two_nondirectories(src_inode, dst_inode);
880-
btrfs_double_mmap_lock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
879+
lock_two_nondirectories(&src_inode->vfs_inode, &dst_inode->vfs_inode);
880+
btrfs_double_mmap_lock(src_inode, dst_inode);
881881
}
882882

883883
ret = btrfs_remap_file_range_prep(src_file, off, dst_file, destoff,
@@ -886,16 +886,18 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
886886
goto out_unlock;
887887

888888
if (remap_flags & REMAP_FILE_DEDUP)
889-
ret = btrfs_extent_same(src_inode, off, len, dst_inode, destoff);
889+
ret = btrfs_extent_same(&src_inode->vfs_inode, off, len,
890+
&dst_inode->vfs_inode, destoff);
890891
else
891892
ret = btrfs_clone_files(dst_file, src_file, off, len, destoff);
892893

893894
out_unlock:
894895
if (same_inode) {
895-
btrfs_inode_unlock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
896+
btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
896897
} else {
897-
btrfs_double_mmap_unlock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
898-
unlock_two_nondirectories(src_inode, dst_inode);
898+
btrfs_double_mmap_unlock(src_inode, dst_inode);
899+
unlock_two_nondirectories(&src_inode->vfs_inode,
900+
&dst_inode->vfs_inode);
899901
}
900902

901903
/*

0 commit comments

Comments
 (0)