diff options
author | Gao Xiang <hsiangkao@linux.alibaba.com> | 2022-07-15 18:41:50 +0300 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2022-07-21 17:53:53 +0300 |
commit | 42fec235f122cb1ae3bf20d91f14e9df0005848c (patch) | |
tree | 468146948d439a107f7dfe3f54de026ae8fe17b7 /fs/erofs | |
parent | 0d823b424f1b74831f05fedb6700b5c69f5ecf6a (diff) | |
download | linux-42fec235f122cb1ae3bf20d91f14e9df0005848c.tar.xz |
erofs: introduce `z_erofs_parse_out_bvecs()'
`z_erofs_decompress_pcluster()' is too long therefore it'd be better
to introduce another helper to parse decompressed pages (or laterly,
decompressed bvecs.)
BTW, since `decompressed_bvecs' is too long as a part of the function
name, `out_bvecs' is used instead.
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Acked-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220715154203.48093-4-hsiangkao@linux.alibaba.com
Diffstat (limited to 'fs/erofs')
-rw-r--r-- | fs/erofs/zdata.c | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index c7be447ac64d..c183cd0bc42b 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -778,18 +778,58 @@ static bool z_erofs_page_is_invalidated(struct page *page) return !page->mapping && !z_erofs_is_shortlived_page(page); } +static int z_erofs_parse_out_bvecs(struct z_erofs_pcluster *pcl, + struct page **pages, struct page **pagepool) +{ + struct z_erofs_pagevec_ctor ctor; + enum z_erofs_page_type page_type; + int i, err = 0; + + z_erofs_pagevec_ctor_init(&ctor, Z_EROFS_NR_INLINE_PAGEVECS, + pcl->pagevec, 0); + for (i = 0; i < pcl->vcnt; ++i) { + struct page *page = z_erofs_pagevec_dequeue(&ctor, &page_type); + unsigned int pagenr; + + /* all pages in pagevec ought to be valid */ + DBG_BUGON(!page); + DBG_BUGON(z_erofs_page_is_invalidated(page)); + + if (z_erofs_put_shortlivedpage(pagepool, page)) + continue; + + if (page_type == Z_EROFS_VLE_PAGE_TYPE_HEAD) + pagenr = 0; + else + pagenr = z_erofs_onlinepage_index(page); + + DBG_BUGON(pagenr >= pcl->nr_pages); + /* + * currently EROFS doesn't support multiref(dedup), + * so here erroring out one multiref page. + */ + if (pages[pagenr]) { + DBG_BUGON(1); + SetPageError(pages[pagenr]); + z_erofs_onlinepage_endio(pages[pagenr]); + err = -EFSCORRUPTED; + } + pages[pagenr] = page; + } + z_erofs_pagevec_ctor_exit(&ctor, true); + return err; +} + static int z_erofs_decompress_pcluster(struct super_block *sb, struct z_erofs_pcluster *pcl, struct page **pagepool) { struct erofs_sb_info *const sbi = EROFS_SB(sb); unsigned int pclusterpages = z_erofs_pclusterpages(pcl); - struct z_erofs_pagevec_ctor ctor; unsigned int i, inputsize, outputsize, llen, nr_pages; struct page *pages_onstack[Z_EROFS_VMAP_ONSTACK_PAGES]; struct page **pages, **compressed_pages, *page; - enum z_erofs_page_type page_type; bool overlapped, partial; int err; @@ -823,42 +863,7 @@ static int z_erofs_decompress_pcluster(struct super_block *sb, for (i = 0; i < nr_pages; ++i) pages[i] = NULL; - err = 0; - z_erofs_pagevec_ctor_init(&ctor, Z_EROFS_NR_INLINE_PAGEVECS, - pcl->pagevec, 0); - - for (i = 0; i < pcl->vcnt; ++i) { - unsigned int pagenr; - - page = z_erofs_pagevec_dequeue(&ctor, &page_type); - - /* all pages in pagevec ought to be valid */ - DBG_BUGON(!page); - DBG_BUGON(z_erofs_page_is_invalidated(page)); - - if (z_erofs_put_shortlivedpage(pagepool, page)) - continue; - - if (page_type == Z_EROFS_VLE_PAGE_TYPE_HEAD) - pagenr = 0; - else - pagenr = z_erofs_onlinepage_index(page); - - DBG_BUGON(pagenr >= nr_pages); - - /* - * currently EROFS doesn't support multiref(dedup), - * so here erroring out one multiref page. - */ - if (pages[pagenr]) { - DBG_BUGON(1); - SetPageError(pages[pagenr]); - z_erofs_onlinepage_endio(pages[pagenr]); - err = -EFSCORRUPTED; - } - pages[pagenr] = page; - } - z_erofs_pagevec_ctor_exit(&ctor, true); + err = z_erofs_parse_out_bvecs(pcl, pages, pagepool); overlapped = false; compressed_pages = pcl->compressed_pages; |