Skip to content

Commit

Permalink
minor improvement to abd_free_pages()
Browse files Browse the repository at this point in the history
It doesn't need to have a loop to free page in a single scatterlist
entry because it should be single or compound page. The pages can be
freed in one invocation to __free_pages() for both cases.

Reviewed-by: Gvozden Neskovic <neskovic@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Closes #6057
  • Loading branch information
jxiong authored and behlendorf committed May 2, 2017
1 parent 24fa203 commit 2b91b51
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions module/zfs/abd.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ abd_free_pages(abd_t *abd)
struct sg_table table;
struct page *page;
int nr_pages = ABD_SCATTER(abd).abd_nents;
int order, i, j;
int order, i;

if (abd->abd_flags & ABD_FLAG_MULTI_ZONE)
ABDSTAT_BUMPDOWN(abdstat_scatter_page_multi_zone);
Expand All @@ -383,13 +383,11 @@ abd_free_pages(abd_t *abd)
ABDSTAT_BUMPDOWN(abdstat_scatter_page_multi_chunk);

abd_for_each_sg(abd, sg, nr_pages, i) {
for (j = 0; j < sg->length; ) {
page = nth_page(sg_page(sg), j >> PAGE_SHIFT);
order = compound_order(page);
__free_pages(page, order);
j += (PAGESIZE << order);
ABDSTAT_BUMPDOWN(abdstat_scatter_orders[order]);
}
page = sg_page(sg);
order = compound_order(page);
__free_pages(page, order);
ASSERT3U(sg->length, <=, PAGE_SIZE << order);
ABDSTAT_BUMPDOWN(abdstat_scatter_orders[order]);
}

table.sgl = ABD_SCATTER(abd).abd_sgl;
Expand Down

0 comments on commit 2b91b51

Please sign in to comment.