]> git.hungrycats.org Git - linux/commitdiff
btrfs: pass unaligned length to btrfs_cmp_data()
authorMark Fasheh <mfasheh@suse.de>
Tue, 23 Jun 2015 21:28:36 +0000 (14:28 -0700)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Wed, 1 Jul 2015 00:00:10 +0000 (20:00 -0400)
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>
(cherry picked from commit 86fda42b26f2addc5ae3ceb56b216058cbaedc8a)

fs/btrfs/ioctl.c

index 2d24ff4652e042c0e01aa91aba38f9ba8bd8d935..2deea1fa79555ecbb54dc17390bcbe9e3e293c15 100644 (file)
@@ -2933,7 +2933,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);