Commit 05b63d2b authored by Gao Xiang's avatar Gao Xiang

erofs: allocate extra bvec pages directly instead of retrying

If non-bootstrap bvecs cannot be kept in place (very rarely), an extra
short-lived page is allocated.

Let's just allocate it immediately rather than do unnecessary -EAGAIN
return first and retry as a cleanup.  Also it's unnecessary to use
__GFP_NOFAIL here since we could gracefully fail out this case instead.
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: default avatarYue Hu <huyue2@coolpad.com>
Link: https://lore.kernel.org/r/20230526201459.128169-2-hsiangkao@linux.alibaba.com
parent 796e9149
...@@ -242,12 +242,17 @@ static int z_erofs_bvec_enqueue(struct z_erofs_bvec_iter *iter, ...@@ -242,12 +242,17 @@ static int z_erofs_bvec_enqueue(struct z_erofs_bvec_iter *iter,
struct z_erofs_bvec *bvec, struct z_erofs_bvec *bvec,
struct page **candidate_bvpage) struct page **candidate_bvpage)
{ {
if (iter->cur == iter->nr) { if (iter->cur >= iter->nr) {
if (!*candidate_bvpage) struct page *nextpage = *candidate_bvpage;
return -EAGAIN;
if (!nextpage) {
nextpage = alloc_page(GFP_NOFS);
if (!nextpage)
return -ENOMEM;
set_page_private(nextpage, Z_EROFS_SHORTLIVED_PAGE);
}
DBG_BUGON(iter->bvset->nextpage); DBG_BUGON(iter->bvset->nextpage);
iter->bvset->nextpage = *candidate_bvpage; iter->bvset->nextpage = nextpage;
z_erofs_bvset_flip(iter); z_erofs_bvset_flip(iter);
iter->bvset->nextpage = NULL; iter->bvset->nextpage = NULL;
...@@ -906,10 +911,8 @@ static bool z_erofs_collector_end(struct z_erofs_decompress_frontend *fe) ...@@ -906,10 +911,8 @@ static bool z_erofs_collector_end(struct z_erofs_decompress_frontend *fe)
z_erofs_bvec_iter_end(&fe->biter); z_erofs_bvec_iter_end(&fe->biter);
mutex_unlock(&pcl->lock); mutex_unlock(&pcl->lock);
if (fe->candidate_bvpage) { if (fe->candidate_bvpage)
DBG_BUGON(z_erofs_is_shortlived_page(fe->candidate_bvpage));
fe->candidate_bvpage = NULL; fe->candidate_bvpage = NULL;
}
/* /*
* if all pending pages are added, don't hold its reference * if all pending pages are added, don't hold its reference
...@@ -1054,24 +1057,13 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, ...@@ -1054,24 +1057,13 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
if (cur) if (cur)
tight &= (fe->mode >= Z_EROFS_PCLUSTER_FOLLOWED); tight &= (fe->mode >= Z_EROFS_PCLUSTER_FOLLOWED);
retry:
err = z_erofs_attach_page(fe, &((struct z_erofs_bvec) { err = z_erofs_attach_page(fe, &((struct z_erofs_bvec) {
.page = page, .page = page,
.offset = offset - map->m_la, .offset = offset - map->m_la,
.end = end, .end = end,
}), exclusive); }), exclusive);
/* should allocate an additional short-lived page for bvset */ if (err)
if (err == -EAGAIN && !fe->candidate_bvpage) {
fe->candidate_bvpage = alloc_page(GFP_NOFS | __GFP_NOFAIL);
set_page_private(fe->candidate_bvpage,
Z_EROFS_SHORTLIVED_PAGE);
goto retry;
}
if (err) {
DBG_BUGON(err == -EAGAIN && fe->candidate_bvpage);
goto out; goto out;
}
z_erofs_onlinepage_split(page); z_erofs_onlinepage_split(page);
/* bump up the number of spiltted parts of a page */ /* bump up the number of spiltted parts of a page */
......
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