]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: pass unaligned length to btrfs_cmp_data()
authorMark Fasheh <mfasheh@suse.de>
Tue, 30 Jun 2015 21:42:04 +0000 (14:42 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Tue, 22 Aug 2017 15:42:58 +0000 (08:42 -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>
(Cherry picked from commit 207910ddeeda38fd54544d94f8c8ca5a9632cc25)

Orabug: 26251039

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Acked-by: Shannon Nelson <shannon.nelson@oracle.com>
Acked-by: John Haxby <john.haxby@oracle.com>
fs/btrfs/ioctl.c

index 111d14d2ec657211c7f04d7786f064296c021bb0..ca6af45f6c43328d7227c526e88251232e06687f 100644 (file)
@@ -2992,7 +2992,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);