[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201022145724.27284-3-hsiangkao@aol.com>
Date: Thu, 22 Oct 2020 22:57:23 +0800
From: Gao Xiang <hsiangkao@....com>
To: linux-erofs@...ts.ozlabs.org
Cc: Chao Yu <yuchao0@...wei.com>, Chao Yu <chao@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Gao Xiang <hsiangkao@...hat.com>
Subject: [PATCH 3/4] erofs: insert to managed cache after adding to pcl
From: Gao Xiang <hsiangkao@...hat.com>
Previously, it could be some concern to call add_to_page_cache_lru()
with page->mapping == Z_EROFS_MAPPING_STAGING (!= NULL).
In contrast, page->private is used instead now, so partially revert
commit 5ddcee1f3a1c ("erofs: get rid of __stagingpage_alloc helper")
with some adaption for simplicity.
Signed-off-by: Gao Xiang <hsiangkao@...hat.com>
---
fs/erofs/zdata.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index afeadf413c2c..edd7325570e1 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1071,28 +1071,19 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl,
put_page(page);
out_allocpage:
page = erofs_allocpage(pagepool, gfp | __GFP_NOFAIL);
- if (!tocache || add_to_page_cache_lru(page, mc, index + nr, gfp)) {
- /* turn into temporary page if fails */
- set_page_private(page, Z_EROFS_SHORTLIVED_PAGE);
- tocache = false;
- }
-
if (oldpage != cmpxchg(&pcl->compressed_pages[nr], oldpage, page)) {
- if (tocache) {
- /* since it added to managed cache successfully */
- unlock_page(page);
- put_page(page);
- } else {
- list_add(&page->lru, pagepool);
- }
+ list_add(&page->lru, pagepool);
cond_resched();
goto repeat;
}
- if (tocache) {
- set_page_private(page, (unsigned long)pcl);
- SetPagePrivate(page);
+ if (!tocache || add_to_page_cache_lru(page, mc, index + nr, gfp)) {
+ /* turn into temporary page if fails */
+ set_page_private(page, Z_EROFS_SHORTLIVED_PAGE);
+ goto out;
}
+ set_page_private(page, (unsigned long)pcl);
+ SetPagePrivate(page);
out: /* the only exit (for tracing and debugging) */
return page;
}
--
2.24.0
Powered by blists - more mailing lists