linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/6] Btrfs: fix off-by-one error of the same page check in btrfs_punch_hole()
@ 2012-12-05 10:53 Miao Xie
  0 siblings, 0 replies; only message in thread
From: Miao Xie @ 2012-12-05 10:53 UTC (permalink / raw)
  To: Linux Btrfs

(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>
---
 fs/btrfs/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index bd5afcc..b477da2 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1881,8 +1881,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 	unsigned long nr;
 	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);
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-05 10:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-05 10:53 [PATCH 3/6] Btrfs: fix off-by-one error of the same page check in btrfs_punch_hole() Miao Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).