Commit 652cdaa8 authored by Yue Hu's avatar Yue Hu Committed by Gao Xiang

erofs: allow partially filled compressed bvecs

In order to reduce memory footprints even further, let's allow
partially filled compressed bvecs for readahead to bail out later.
Signed-off-by: default avatarYue Hu <huyue2@coolpad.com>
Reviewed-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231221062341.23901-1-zbestahu@gmail.comSigned-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
parent 0ee3a0d5
...@@ -1202,34 +1202,27 @@ static int z_erofs_parse_in_bvecs(struct z_erofs_decompress_backend *be, ...@@ -1202,34 +1202,27 @@ static int z_erofs_parse_in_bvecs(struct z_erofs_decompress_backend *be,
struct z_erofs_bvec *bvec = &pcl->compressed_bvecs[i]; struct z_erofs_bvec *bvec = &pcl->compressed_bvecs[i];
struct page *page = bvec->page; struct page *page = bvec->page;
/* compressed pages ought to be present before decompressing */ /* compressed data ought to be valid before decompressing */
if (!page) { if (!page) {
DBG_BUGON(1); err = -EIO;
continue; continue;
} }
be->compressed_pages[i] = page; be->compressed_pages[i] = page;
if (z_erofs_is_inline_pcluster(pcl)) { if (z_erofs_is_inline_pcluster(pcl) ||
erofs_page_is_managed(EROFS_SB(be->sb), page)) {
if (!PageUptodate(page)) if (!PageUptodate(page))
err = -EIO; err = -EIO;
continue; continue;
} }
DBG_BUGON(z_erofs_page_is_invalidated(page)); DBG_BUGON(z_erofs_page_is_invalidated(page));
if (!z_erofs_is_shortlived_page(page)) { if (z_erofs_is_shortlived_page(page))
if (erofs_page_is_managed(EROFS_SB(be->sb), page)) { continue;
if (!PageUptodate(page)) z_erofs_do_decompressed_bvec(be, bvec);
err = -EIO; *overlapped = true;
continue;
}
z_erofs_do_decompressed_bvec(be, bvec);
*overlapped = true;
}
} }
return err;
if (err)
return err;
return 0;
} }
static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
...@@ -1238,7 +1231,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, ...@@ -1238,7 +1231,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
struct erofs_sb_info *const sbi = EROFS_SB(be->sb); struct erofs_sb_info *const sbi = EROFS_SB(be->sb);
struct z_erofs_pcluster *pcl = be->pcl; struct z_erofs_pcluster *pcl = be->pcl;
unsigned int pclusterpages = z_erofs_pclusterpages(pcl); unsigned int pclusterpages = z_erofs_pclusterpages(pcl);
const struct z_erofs_decompressor *decompressor = const struct z_erofs_decompressor *decomp =
&erofs_decompressors[pcl->algorithmformat]; &erofs_decompressors[pcl->algorithmformat];
int i, err2; int i, err2;
struct page *page; struct page *page;
...@@ -1274,10 +1267,8 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, ...@@ -1274,10 +1267,8 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
err2 = z_erofs_parse_in_bvecs(be, &overlapped); err2 = z_erofs_parse_in_bvecs(be, &overlapped);
if (err2) if (err2)
err = err2; err = err2;
if (err) if (!err)
goto out; err = decomp->decompress(&(struct z_erofs_decompress_req) {
err = decompressor->decompress(&(struct z_erofs_decompress_req) {
.sb = be->sb, .sb = be->sb,
.in = be->compressed_pages, .in = be->compressed_pages,
.out = be->decompressed_pages, .out = be->decompressed_pages,
...@@ -1291,7 +1282,6 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, ...@@ -1291,7 +1282,6 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
.fillgaps = pcl->multibases, .fillgaps = pcl->multibases,
}, be->pagepool); }, be->pagepool);
out:
/* must handle all compressed pages before actual file pages */ /* must handle all compressed pages before actual file pages */
if (z_erofs_is_inline_pcluster(pcl)) { if (z_erofs_is_inline_pcluster(pcl)) {
page = pcl->compressed_bvecs[0].page; page = pcl->compressed_bvecs[0].page;
...@@ -1302,7 +1292,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, ...@@ -1302,7 +1292,7 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
/* consider shortlived pages added when decompressing */ /* consider shortlived pages added when decompressing */
page = be->compressed_pages[i]; page = be->compressed_pages[i];
if (erofs_page_is_managed(sbi, page)) if (!page || erofs_page_is_managed(sbi, page))
continue; continue;
(void)z_erofs_put_shortlivedpage(be->pagepool, page); (void)z_erofs_put_shortlivedpage(be->pagepool, page);
WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL); WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);
......
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