summaryrefslogtreecommitdiff
path: root/fs/erofs
diff options
context:
space:
mode:
authorGao Xiang <hsiangkao@linux.alibaba.com>2022-07-15 23:42:01 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2022-07-21 22:55:37 +0800
commit3fe96ee0f96d0b2117b0ef438e28c26655b370f8 (patch)
treefdbcacae77e8896a0ac32aec0ee6a63c11cb3941 /fs/erofs
parentfe3e5914e6dc8db743fa587748ce1d9ecd4a5dba (diff)
erofs: introduce z_erofs_do_decompressed_bvec()
Both out_bvecs and in_bvecs share the common logic for decompressed buffers. So let's make a helper for this. Acked-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20220715154203.48093-15-hsiangkao@linux.alibaba.com
Diffstat (limited to 'fs/erofs')
-rw-r--r--fs/erofs/zdata.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index d93ba0adcf9e..d4db2c1d53a6 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -861,6 +861,26 @@ struct z_erofs_decompress_backend {
unsigned int onstack_used;
};
+static int z_erofs_do_decompressed_bvec(struct z_erofs_decompress_backend *be,
+ struct z_erofs_bvec *bvec)
+{
+ unsigned int pgnr = (bvec->offset + be->pcl->pageofs_out) >> PAGE_SHIFT;
+ struct page *oldpage;
+
+ DBG_BUGON(pgnr >= be->pcl->nr_pages);
+ oldpage = be->decompressed_pages[pgnr];
+ be->decompressed_pages[pgnr] = bvec->page;
+
+ /* error out if one pcluster is refenenced multiple times. */
+ if (oldpage) {
+ DBG_BUGON(1);
+ z_erofs_page_mark_eio(oldpage);
+ z_erofs_onlinepage_endio(oldpage);
+ return -EFSCORRUPTED;
+ }
+ return 0;
+}
+
static int z_erofs_parse_out_bvecs(struct z_erofs_decompress_backend *be)
{
struct z_erofs_pcluster *pcl = be->pcl;
@@ -871,27 +891,14 @@ static int z_erofs_parse_out_bvecs(struct z_erofs_decompress_backend *be)
z_erofs_bvec_iter_begin(&biter, &pcl->bvset, Z_EROFS_INLINE_BVECS, 0);
for (i = 0; i < pcl->vcnt; ++i) {
struct z_erofs_bvec bvec;
- unsigned int pgnr;
z_erofs_bvec_dequeue(&biter, &bvec, &old_bvpage);
if (old_bvpage)
z_erofs_put_shortlivedpage(be->pagepool, old_bvpage);
- pgnr = (bvec.offset + pcl->pageofs_out) >> PAGE_SHIFT;
- DBG_BUGON(pgnr >= pcl->nr_pages);
DBG_BUGON(z_erofs_page_is_invalidated(bvec.page));
- /*
- * currently EROFS doesn't support multiref(dedup),
- * so here erroring out one multiref page.
- */
- if (be->decompressed_pages[pgnr]) {
- DBG_BUGON(1);
- z_erofs_page_mark_eio(be->decompressed_pages[pgnr]);
- z_erofs_onlinepage_endio(be->decompressed_pages[pgnr]);
- err = -EFSCORRUPTED;
- }
- be->decompressed_pages[pgnr] = bvec.page;
+ err = z_erofs_do_decompressed_bvec(be, &bvec);
}
old_bvpage = z_erofs_bvec_iter_end(&biter);
@@ -911,7 +918,6 @@ static int z_erofs_parse_in_bvecs(struct z_erofs_decompress_backend *be,
for (i = 0; i < pclusterpages; ++i) {
struct z_erofs_bvec *bvec = &pcl->compressed_bvecs[i];
struct page *page = bvec->page;
- unsigned int pgnr;
/* compressed pages ought to be present before decompressing */
if (!page) {
@@ -933,18 +939,7 @@ static int z_erofs_parse_in_bvecs(struct z_erofs_decompress_backend *be,
err = -EIO;
continue;
}
-
- pgnr = (bvec->offset + pcl->pageofs_out) >> PAGE_SHIFT;
- DBG_BUGON(pgnr >= pcl->nr_pages);
- if (be->decompressed_pages[pgnr]) {
- DBG_BUGON(1);
- z_erofs_page_mark_eio(
- be->decompressed_pages[pgnr]);
- z_erofs_onlinepage_endio(
- be->decompressed_pages[pgnr]);
- err = -EFSCORRUPTED;
- }
- be->decompressed_pages[pgnr] = page;
+ err = z_erofs_do_decompressed_bvec(be, bvec);
*overlapped = true;
}
}