[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230203030143.73105-2-jefflexu@linux.alibaba.com>
Date: Fri, 3 Feb 2023 11:01:35 +0800
From: Jingbo Xu <jefflexu@...ux.alibaba.com>
To: xiang@...nel.org, chao@...nel.org, linux-erofs@...ts.ozlabs.org
Cc: huyue2@...lpad.com, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: [PATCH v3 1/9] erofs: support readahead in meta routine
In prep for the following support for readahead for page cache sharing,
add support for readahead in meta routine.
Signed-off-by: Jingbo Xu <jefflexu@...ux.alibaba.com>
---
fs/erofs/fscache.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 014e20962376..e2ebe8f7dbe9 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -193,6 +193,30 @@ static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
return ret;
}
+static void erofs_fscache_meta_readahead(struct readahead_control *rac)
+{
+ int ret;
+ struct erofs_fscache *ctx = rac->mapping->host->i_private;
+ struct erofs_fscache_request *req;
+
+ if (!readahead_count(rac))
+ return;
+
+ req = erofs_fscache_req_alloc(rac->mapping,
+ readahead_pos(rac), readahead_length(rac));
+ if (IS_ERR(req))
+ return;
+
+ /* The request completion will drop refs on the folios. */
+ while (readahead_folio(rac))
+ ;
+
+ ret = erofs_fscache_read_folios_async(ctx->cookie, req, req->start, req->len);
+ if (ret)
+ req->error = ret;
+ erofs_fscache_req_put(req);
+}
+
static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary)
{
struct address_space *mapping = primary->mapping;
@@ -319,6 +343,7 @@ static void erofs_fscache_readahead(struct readahead_control *rac)
static const struct address_space_operations erofs_fscache_meta_aops = {
.read_folio = erofs_fscache_meta_read_folio,
+ .readahead = erofs_fscache_meta_readahead,
};
const struct address_space_operations erofs_fscache_access_aops = {
--
2.19.1.6.gb485710b
Powered by blists - more mailing lists