From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org
Cc: huyue2@coolpad.com, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 9/9] erofs: introduce 'sharecache' mount option
Date: Fri, 3 Feb 2023 11:01:43 +0800 [thread overview]
Message-ID: <20230203030143.73105-10-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20230203030143.73105-1-jefflexu@linux.alibaba.com>
Introduce 'sharecache' mount option to enable page cache sharing in
fscache mode.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
Documentation/filesystems/erofs.rst | 2 ++
fs/erofs/inode.c | 4 ++++
fs/erofs/internal.h | 3 +++
fs/erofs/super.c | 13 +++++++++++++
4 files changed, 22 insertions(+)
diff --git a/Documentation/filesystems/erofs.rst b/Documentation/filesystems/erofs.rst
index a43aacf1494e..1478c4d168e2 100644
--- a/Documentation/filesystems/erofs.rst
+++ b/Documentation/filesystems/erofs.rst
@@ -122,6 +122,8 @@ device=%s Specify a path to an extra device to be used together.
fsid=%s Specify a filesystem image ID for Fscache back-end.
domain_id=%s Specify a domain ID in fscache mode so that different images
with the same blobs under a given domain ID can share storage.
+(no)sharecache Enable page cache sharing among different images in the
+ same domain.
=================== =========================================================
Sysfs Entries
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index d3b8736fa124..31d3ab8443d1 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -262,6 +262,10 @@ static int erofs_fill_inode(struct inode *inode)
inode->i_op = &erofs_generic_iops;
if (erofs_inode_is_data_compressed(vi->datalayout))
inode->i_fop = &generic_ro_fops;
+#ifdef CONFIG_EROFS_FS_ONDEMAND
+ else if (erofs_can_share_page(inode))
+ inode->i_fop = &erofs_fscache_share_file_fops;
+#endif
else
inode->i_fop = &erofs_file_fops;
break;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 6019b076c625..c3ac6d613eb1 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -374,6 +374,9 @@ static inline bool erofs_can_share_page(struct inode *inode)
struct erofs_inode *vi = EROFS_I(inode);
struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb);
+ if (!test_opt(&sbi->opt, SHARE_CACHE))
+ return false;
+
/* enable page cache sharing only in share domain mode */
if (!erofs_is_fscache_mode(inode->i_sb) || !sbi->domain_id)
return false;
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 835b69c9511b..d05346d34ed8 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -456,6 +456,7 @@ enum {
Opt_device,
Opt_fsid,
Opt_domain_id,
+ Opt_sharecache,
Opt_err
};
@@ -482,6 +483,7 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = {
fsparam_string("device", Opt_device),
fsparam_string("fsid", Opt_fsid),
fsparam_string("domain_id", Opt_domain_id),
+ fsparam_flag_no("sharecache", Opt_sharecache),
{}
};
@@ -590,9 +592,16 @@ static int erofs_fc_parse_param(struct fs_context *fc,
if (!ctx->domain_id)
return -ENOMEM;
break;
+ case Opt_sharecache:
+ if (result.boolean)
+ set_opt(&ctx->opt, SHARE_CACHE);
+ else
+ clear_opt(&ctx->opt, SHARE_CACHE);
+ break;
#else
case Opt_fsid:
case Opt_domain_id:
+ case Opt_sharecache:
errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name);
break;
#endif
@@ -1108,6 +1117,10 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
seq_printf(seq, ",fsid=%s", sbi->fsid);
if (sbi->domain_id)
seq_printf(seq, ",domain_id=%s", sbi->domain_id);
+ if (test_opt(opt, SHARE_CACHE))
+ seq_puts(seq, ",sharecache");
+ else
+ seq_puts(seq, ",nosharecache");
#endif
return 0;
}
--
2.19.1.6.gb485710b
prev parent reply other threads:[~2023-02-03 3:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 3:01 [PATCH v3 0/9] erofs: support page cache sharing between EROFS images in fscache mode Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 1/9] erofs: support readahead in meta routine Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 2/9] erofs: remove unused device mapping in the " Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 3/9] erofs: unify anonymous inodes for blob Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 4/9] erofs: allocate anonymous file of blob for page cache sharing Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 5/9] erofs: set accurate anony inode size " Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 6/9] erofs: implement .read_iter " Jingbo Xu
2023-02-03 3:01 ` [PATCH v3 7/9] erofs: implement .mmap " Jingbo Xu
2023-02-03 15:12 ` kernel test robot
2023-02-03 3:01 ` [PATCH v3 8/9] erofs: add helper checking if page cache sharing shall be enabled Jingbo Xu
2023-02-03 3:01 ` Jingbo Xu [this message]
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=20230203030143.73105-10-jefflexu@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=chao@kernel.org \
--cc=huyue2@coolpad.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@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;
as well as URLs for NNTP newsgroup(s).