Commit d64766fd authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Refactor loop in btrfs_release_extent_buffer_page

The purpose of the function is to free all the pages comprising an
extent buffer. This can be achieved with a simple for loop rather than
the slightly more involved 'do {} while' construct. So rewrite the
loop using a 'for' construct. Additionally we can never have an
extent_buffer that has 0 pages so remove the check for index == 0. No
functional changes.

The reversed order used to have a meaning in the past where the first
page served as a blocking point for several callers. See eg
4f2de97a ("Btrfs: set page->private to the eb").
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b16d011e
...@@ -4647,19 +4647,16 @@ int extent_buffer_under_io(struct extent_buffer *eb) ...@@ -4647,19 +4647,16 @@ int extent_buffer_under_io(struct extent_buffer *eb)
*/ */
static void btrfs_release_extent_buffer_page(struct extent_buffer *eb) static void btrfs_release_extent_buffer_page(struct extent_buffer *eb)
{ {
int index; int i;
struct page *page; int num_pages;
int mapped = !test_bit(EXTENT_BUFFER_DUMMY, &eb->bflags); int mapped = !test_bit(EXTENT_BUFFER_DUMMY, &eb->bflags);
BUG_ON(extent_buffer_under_io(eb)); BUG_ON(extent_buffer_under_io(eb));
index = num_extent_pages(eb); num_pages = num_extent_pages(eb);
if (index == 0) for (i = 0; i < num_pages; i++) {
return; struct page *page = eb->pages[i];
do {
index--;
page = eb->pages[index];
if (!page) if (!page)
continue; continue;
if (mapped) if (mapped)
...@@ -4691,7 +4688,7 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb) ...@@ -4691,7 +4688,7 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb)
/* One for when we allocated the page */ /* One for when we allocated the page */
put_page(page); put_page(page);
} while (index != 0); }
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment