]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Btrfs: move duplicated nodatasum check into common reflink/dedupe helper
authorFilipe Manana <fdmanana@suse.com>
Wed, 12 Dec 2018 18:05:56 +0000 (18:05 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Feb 2019 13:13:21 +0000 (14:13 +0100)
Move the check that verifies if both inodes have checksums disabled or
both have them enabled, from the clone and deduplication functions into
the new common helper btrfs_remap_file_range_prep().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c

index c21cc408556d2c31c535e4be9e2e96336aab2c2d..72b2b2de62933302979a23d3a752af42a1bca9de 100644 (file)
@@ -3280,11 +3280,6 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
        int ret;
        u64 i, tail_len, chunk_count;
 
-       /* don't make the dst file partly checksummed */
-       if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
-           (BTRFS_I(dst)->flags & BTRFS_INODE_NODATASUM))
-               return -EINVAL;
-
        tail_len = olen % BTRFS_MAX_DEDUPE_LEN;
        chunk_count = div_u64(olen, BTRFS_MAX_DEDUPE_LEN);
 
@@ -3902,11 +3897,6 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
         *   be either compressed or non-compressed.
         */
 
-       /* don't make the dst file partly checksummed */
-       if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) !=
-           (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM))
-               return -EINVAL;
-
        /*
         * VFS's generic_remap_file_range_prep() protects us from cloning the
         * eof block into the middle of a file, which would result in corruption
@@ -3982,6 +3972,13 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
        else
                btrfs_double_inode_lock(inode_in, inode_out);
 
+       /* don't make the dst file partly checksummed */
+       if ((BTRFS_I(inode_in)->flags & BTRFS_INODE_NODATASUM) !=
+           (BTRFS_I(inode_out)->flags & BTRFS_INODE_NODATASUM)) {
+               ret = -EINVAL;
+               goto out_unlock;
+       }
+
        /*
         * Now that the inodes are locked, we need to start writeback ourselves
         * and can not rely on the writeback from the VFS's generic helper