When erofs cache decompression is disabled (EROFS_ZIP_CACHE_DISABLED), pages allocated for compressed clusters are freed soon after decompression. This can reduce the page allocation time by first allocating pages from the reserved buffer pool [1].
[1] The reserved buffer pool and its benefits are detailed in commit 0f6273ab4637 ("erofs: add a reserved buffer pool for lz4 decompression"). Signed-off-by: Chunhai Guo <guochun...@vivo.com> --- fs/erofs/internal.h | 5 +++++ fs/erofs/zdata.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 45dc15ebd870..e768990bf20f 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -201,6 +201,11 @@ enum { EROFS_ZIP_CACHE_READAROUND }; +static inline bool erofs_is_cache_disabled(struct erofs_sb_info *sbi) +{ + return sbi->opt.cache_strategy == EROFS_ZIP_CACHE_DISABLED; +} + /* basic unit of the workstation of a super_block */ struct erofs_workgroup { pgoff_t index; diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 424f656cd765..b979529be5ed 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1496,7 +1496,8 @@ static void z_erofs_fill_bio_vec(struct bio_vec *bvec, folio_unlock(folio); folio_put(folio); out_allocfolio: - zbv.page = erofs_allocpage(&f->pagepool, gfp | __GFP_NOFAIL); + zbv.page = __erofs_allocpage(&f->pagepool, gfp | __GFP_NOFAIL, + erofs_is_cache_disabled(EROFS_I_SB(f->inode))); spin_lock(&pcl->obj.lockref.lock); if (pcl->compressed_bvecs[nr].page) { erofs_pagepool_add(&f->pagepool, zbv.page); -- 2.25.1