From: Miao Xie Date: Wed, 5 Dec 2012 10:53:45 +0000 (+0000) Subject: Btrfs: fix off-by-one error of the same page check in btrfs_punch_hole() X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=6347b3c433a4cff00eb2299c7f2c7d1d8b24c1fc;p=~shefty%2Frdma-dev.git Btrfs: fix off-by-one error of the same page check in btrfs_punch_hole() (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 Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 8e3d6788d6d..d75412bf7c4 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -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);