Skip to content

Commit

Permalink
Btrfs: fix btrfs_release_extent_buffer_page with the right usage of n…
Browse files Browse the repository at this point in the history
…um_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 here.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
  • Loading branch information
Wang Sheng-Hui authored and Josef Bacik committed May 11, 2012
1 parent 1b303fc commit 39bab87
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3981,11 +3981,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;

Expand Down

0 comments on commit 39bab87

Please sign in to comment.