From: Mark Fasheh Date: Tue, 30 Jun 2015 21:42:04 +0000 (-0700) Subject: btrfs: pass unaligned length to btrfs_cmp_data() X-Git-Tag: v4.1.12-110.0.20170822_0730~26 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e08fe6d0fac9ea5729a75ac396600c7582434c2d;p=users%2Fjedix%2Flinux-maple.git btrfs: pass unaligned length to btrfs_cmp_data() 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 Reviewed-by: David Sterba Signed-off-by: Chris Mason (Cherry picked from commit 207910ddeeda38fd54544d94f8c8ca5a9632cc25) Orabug: 26251039 Signed-off-by: Shan Hai Acked-by: Shannon Nelson Acked-by: John Haxby --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 111d14d2ec657..ca6af45f6c433 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -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);