btrfs: pass unaligned length to btrfs_cmp_data()
authorMark Fasheh <mfasheh@suse.de>
Tue, 30 Jun 2015 21:42:04 +0000 (14:42 -0700)
committerChris Mason <clm@fb.com>
Thu, 2 Jul 2015 00:17:13 +0000 (17:17 -0700)
In the case that we dedupe the tail of a file, we might expand the dedupe
len out to the end of our last block. We don't want to compare data past
i_size however, so pass the original length to btrfs_cmp_data().

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ioctl.c

index c86b835da7a8739ec16396d589ccb651278ab44d..55504338491d8e5a4989ff98e5bd5572ecf61946 100644 (file)
@@ -2943,7 +2943,8 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
                goto out_unlock;
        }
 
-       ret = btrfs_cmp_data(src, loff, dst, dst_loff, len);
+       /* pass original length for comparison so we stay within i_size */
+       ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen);
        if (ret == 0)
                ret = btrfs_clone(src, dst, loff, olen, len, dst_loff);