Skip to contentSkip to conversation

btrfs/extent_io.c: fix btrfs_release_extent_buffer_page with the right usage of num_extent_pages

PATCH New Wang Sheng-Hui 1 participant 1 message Apr 1, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs/extent_io.c: fix btrfs_release_extent_buffer_page with the right usage of num_extent_pages

num_extent_pages returns the number of pages in the specific range, not the index of the last page in the eb range. btrfs_release_extent_buffer_page is called with start_idx set 0 in current codes, so it's not a problem yet. But the logic is indeed wrong. Fix it with this patch.

---
 fs/btrfs/extent_io.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
fs/btrfs/extent_io.c +3 -1
index 6099261..941f0ea 100644
@@ -3976,11 +3976,13 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb,
 						unsigned long start_idx)
 {
 	unsigned long index;
+	unsigned long num_pages;
 	struct page *page;
 
 	BUG_ON(extent_buffer_under_io(eb));
 
-	index = num_extent_pages(eb->start, eb->len);
+	num_pages = num_extent_pages(eb->start, eb->len);
+	index = start_idx + num_pages;
 	if (start_idx >= index)
 		return;
 
Signature · 1 line
1.7.1