From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <xiang@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Matthew Wilcox <willy@infradead.org>
Subject: [RFC PATCH 2/2] erofs: directly traverse pages in z_erofs_readahead()
Date: Tue, 6 Jul 2021 02:32:53 +0800 [thread overview]
Message-ID: <20210705183253.14833-2-xiang@kernel.org> (raw)
In-Reply-To: <20210705183253.14833-1-xiang@kernel.org>
In that way, pages can be accessed directly with xarray.
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
Just an open-coded PoC one, since that is what EROFS actually needs but
without the iteration API (see [PATCH 1/2] as well.)
fs/erofs/zdata.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 054b9839e9db..210b2965ecc4 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1416,7 +1416,8 @@ static void z_erofs_readahead(struct readahead_control *rac)
bool sync = (sbi->ctx.readahead_sync_decompress &&
nr_pages <= sbi->ctx.max_sync_decompress_pages);
struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
- struct page *page, *head = NULL;
+ struct page *page;
+ pgoff_t index;
LIST_HEAD(pagepool);
trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
@@ -1434,26 +1435,19 @@ static void z_erofs_readahead(struct readahead_control *rac)
* 2) submission chain can be then in the forward order since
* pclusters are all inserted at head.
*/
- while ((page = readahead_page(rac))) {
- prefetchw(&page->flags);
-
- /*
- * A pure asynchronous readahead is indicated if
- * a PG_readahead marked page is hitted at first.
- * Let's also do asynchronous decompression for this case.
- */
- sync &= !(PageReadahead(page) && !head);
-
- set_page_private(page, (unsigned long)head);
- head = page;
- }
-
- while (head) {
- struct page *page = head;
+ index = rac->_index + rac->_nr_pages;
+ while (rac->_nr_pages) {
+ struct page *head;
int err;
- /* traversal in reverse order */
- head = (void *)page_private(page);
+ --rac->_nr_pages;
+ page = xa_load(&rac->mapping->i_pages, --index);
+ /* XXX: very incomplete thp support */
+ head = thp_head(page);
+ if (head != page) {
+ index -= page->index - head->index;
+ page = head;
+ }
err = z_erofs_do_read_page(&f, page, &pagepool);
if (err)
--
2.20.1
next prev parent reply other threads:[~2021-07-05 18:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 18:32 [PATCH 1/2] erofs: better comment z_erofs_readahead() Gao Xiang
2021-07-05 18:32 ` Gao Xiang [this message]
2021-07-05 20:15 ` [RFC PATCH 2/2] erofs: directly traverse pages in z_erofs_readahead() Matthew Wilcox
2021-07-05 22:48 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210705183253.14833-2-xiang@kernel.org \
--to=xiang@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).