summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjxiong <[email protected]>2017-05-02 10:06:18 -0700
committerBrian Behlendorf <[email protected]>2017-05-02 10:06:18 -0700
commit2b91b5119c16539a074ae08e0998e2b527a976b4 (patch)
treef9dc427e2f7b5af5bd3b4d499b70accd9ab3c35f
parent24fa20340dda244270a1382bfdb8d94f579ae7df (diff)
minor improvement to abd_free_pages()
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Jinshan Xiong <[email protected]> Closes #6057
-rw-r--r--module/zfs/abd.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/module/zfs/abd.c b/module/zfs/abd.c
index 6d0a3b503..765ac7fb7 100644
--- a/module/zfs/abd.c
+++ b/module/zfs/abd.c
@@ -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);
@@ -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;