From: Hongzhen Luo <hongzhen@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, Hongzhen Luo <hongzhen@linux.alibaba.com>
Subject: [RFC PATCH v6 6/7] erofs: support compressed inodes for page cache share
Date: Sat, 1 Mar 2025 22:49:43 +0800 [thread overview]
Message-ID: <20250301145002.2420830-7-hongzhen@linux.alibaba.com> (raw)
In-Reply-To: <20250301145002.2420830-1-hongzhen@linux.alibaba.com>
This patch adds page cache sharing functionality for compressed inodes.
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
---
fs/erofs/zdata.c | 57 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index aff09f94afb2..b6383cb26acb 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -5,6 +5,7 @@
* Copyright (C) 2022 Alibaba Cloud
*/
#include "compress.h"
+#include "ishare.h"
#include <linux/psi.h>
#include <linux/cpuhotplug.h>
#include <trace/events/erofs.h>
@@ -474,7 +475,7 @@ enum z_erofs_pclustermode {
};
struct z_erofs_frontend {
- struct inode *const inode;
+ struct inode *inode;
struct erofs_map_blocks map;
struct z_erofs_bvec_iter biter;
@@ -1835,11 +1836,24 @@ static void z_erofs_pcluster_readmore(struct z_erofs_frontend *f,
static int z_erofs_read_folio(struct file *file, struct folio *folio)
{
- struct inode *const inode = folio->mapping->host;
- Z_EROFS_DEFINE_FRONTEND(f, inode, folio_pos(folio));
+ struct inode *const inode = folio->mapping->host, *realinode;
+ Z_EROFS_DEFINE_FRONTEND(f, NULL, folio_pos(folio));
+ struct erofs_read_ctx rdctx = {
+ .file = file,
+ .inode = inode,
+ };
int err;
trace_erofs_read_folio(folio, false);
+
+ erofs_read_begin(&rdctx);
+
+ if (erofs_is_ishare_inode(inode))
+ realinode = erofs_ishare_iget(inode);
+ else
+ realinode = inode;
+
+ f.inode = realinode;
z_erofs_pcluster_readmore(&f, NULL, true);
err = z_erofs_scan_folio(&f, folio, false);
z_erofs_pcluster_readmore(&f, NULL, false);
@@ -1848,25 +1862,43 @@ static int z_erofs_read_folio(struct file *file, struct folio *folio)
/* if some pclusters are ready, need submit them anyway */
err = z_erofs_runqueue(&f, 0) ?: err;
if (err && err != -EINTR)
- erofs_err(inode->i_sb, "read error %d @ %lu of nid %llu",
- err, folio->index, EROFS_I(inode)->nid);
+ erofs_err(realinode->i_sb, "read error %d @ %lu of nid %llu",
+ err, folio->index, EROFS_I(realinode)->nid);
erofs_put_metabuf(&f.map.buf);
erofs_release_pages(&f.pagepool);
+
+ if (erofs_is_ishare_inode(inode))
+ erofs_ishare_iput(realinode);
+
+ erofs_read_end(&rdctx);
+
return err;
}
static void z_erofs_readahead(struct readahead_control *rac)
{
- struct inode *const inode = rac->mapping->host;
- Z_EROFS_DEFINE_FRONTEND(f, inode, readahead_pos(rac));
+ struct inode *const inode = rac->mapping->host, *realinode;
+ Z_EROFS_DEFINE_FRONTEND(f, NULL, readahead_pos(rac));
struct folio *head = NULL, *folio;
unsigned int nrpages = readahead_count(rac);
+ struct erofs_read_ctx rdctx = {
+ .file = rac->file,
+ .inode = inode,
+ };
int err;
+ erofs_read_begin(&rdctx);
+
+ if (erofs_is_ishare_inode(inode))
+ realinode = erofs_ishare_iget(inode);
+ else
+ realinode = inode;
+
+ f.inode = realinode;
z_erofs_pcluster_readmore(&f, rac, true);
nrpages = readahead_count(rac);
- trace_erofs_readpages(inode, readahead_index(rac), nrpages, false);
+ trace_erofs_readpages(realinode, readahead_index(rac), nrpages, false);
while ((folio = readahead_folio(rac))) {
folio->private = head;
head = folio;
@@ -1879,8 +1911,8 @@ static void z_erofs_readahead(struct readahead_control *rac)
err = z_erofs_scan_folio(&f, folio, true);
if (err && err != -EINTR)
- erofs_err(inode->i_sb, "readahead error at folio %lu @ nid %llu",
- folio->index, EROFS_I(inode)->nid);
+ erofs_err(realinode->i_sb, "readahead error at folio %lu @ nid %llu",
+ folio->index, EROFS_I(realinode)->nid);
}
z_erofs_pcluster_readmore(&f, rac, false);
z_erofs_pcluster_end(&f);
@@ -1888,6 +1920,11 @@ static void z_erofs_readahead(struct readahead_control *rac)
(void)z_erofs_runqueue(&f, nrpages);
erofs_put_metabuf(&f.map.buf);
erofs_release_pages(&f.pagepool);
+
+ if (erofs_is_ishare_inode(inode))
+ erofs_ishare_iput(realinode);
+
+ erofs_read_end(&rdctx);
}
const struct address_space_operations z_erofs_aops = {
--
2.43.5
next prev parent reply other threads:[~2025-03-01 14:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 14:49 [RFC PATCH v6 0/7] erofs: inode page cache share feature Hongzhen Luo
2025-03-01 14:49 ` [RFC PATCH v6 1/7] erofs: move `struct erofs_anon_fs_type` to super.c Hongzhen Luo
2025-03-22 0:54 ` Hongbo Li
2025-03-01 14:49 ` [RFC PATCH v6 2/7] erofs: support user-defined fingerprint name Hongzhen Luo
2025-03-01 14:49 ` [RFC PATCH v6 3/7] erofs: support domain-specific page cache share Hongzhen Luo
2025-03-01 14:49 ` [RFC PATCH v6 4/7] erofs: introduce the page cache share feature Hongzhen Luo
2025-03-01 14:49 ` [RFC PATCH v6 5/7] erofs: support unencoded inodes for page cache share Hongzhen Luo
2025-03-01 14:49 ` Hongzhen Luo [this message]
2025-03-01 14:49 ` [RFC PATCH v6 7/7] erofs: implement .fadvise " Hongzhen Luo
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=20250301145002.2420830-7-hongzhen@linux.alibaba.com \
--to=hongzhen@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®