]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
Btrfs: fix off-by-one error of the same page check in btrfs_punch_hole()
authorMiao Xie <miaox@cn.fujitsu.com>
Wed, 5 Dec 2012 10:53:45 +0000 (10:53 +0000)
committerChris Mason <chris.mason@fusionio.com>
Mon, 17 Dec 2012 01:46:19 +0000 (20:46 -0500)
(start + len) is the start of the adjacent extent, not the end of the current
extent, so we should not use it to check the hole is on the same page or not.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/file.c

index 8e3d6788d6dd09e29fe444393661d9a8e532d3d0..d75412bf7c4a4f94ac913009a37d0002c9071750 100644 (file)
@@ -1867,8 +1867,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
        u64 drop_end;
        int ret = 0;
        int err = 0;
-       bool same_page = (offset >> PAGE_CACHE_SHIFT) ==
-               ((offset + len) >> PAGE_CACHE_SHIFT);
+       bool same_page = ((offset >> PAGE_CACHE_SHIFT) ==
+                         ((offset + len - 1) >> PAGE_CACHE_SHIFT));
 
        btrfs_wait_ordered_range(inode, offset, len);