From nobody Fri Sep 20 01:03:22 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F169C636D3 for ; Fri, 3 Feb 2023 03:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbjBCDCf (ORCPT ); Thu, 2 Feb 2023 22:02:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbjBCDCL (ORCPT ); Thu, 2 Feb 2023 22:02:11 -0500 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5213A879; Thu, 2 Feb 2023 19:01:54 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VamyBaS_1675393311; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VamyBaS_1675393311) by smtp.aliyun-inc.com; Fri, 03 Feb 2023 11:01:52 +0800 From: Jingbo Xu 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 Message-Id: <20230203030143.73105-10-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20230203030143.73105-1-jefflexu@linux.alibaba.com> References: <20230203030143.73105-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce 'sharecache' mount option to enable page cache sharing in fscache mode. Signed-off-by: Jingbo Xu --- 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/filesystem= s/erofs.rst index a43aacf1494e..1478c4d168e2 100644 --- a/Documentation/filesystems/erofs.rst +++ b/Documentation/filesystems/erofs.rst @@ -122,6 +122,8 @@ device=3D%s Specify a path to an extra dev= ice to be used together. fsid=3D%s Specify a filesystem image ID for Fscache back-en= d. domain_id=3D%s Specify a domain ID in fscache mode so that diffe= rent images with the same blobs under a given domain ID can sha= re storage. +(no)sharecache Enable page cache sharing among different images in= the + same domain. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =20 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 =3D &erofs_generic_iops; if (erofs_inode_is_data_compressed(vi->datalayout)) inode->i_fop =3D &generic_ro_fops; +#ifdef CONFIG_EROFS_FS_ONDEMAND + else if (erofs_can_share_page(inode)) + inode->i_fop =3D &erofs_fscache_share_file_fops; +#endif else inode->i_fop =3D &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 *i= node) struct erofs_inode *vi =3D EROFS_I(inode); struct erofs_sb_info *sbi =3D EROFS_SB(inode->i_sb); =20 + 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 }; =20 @@ -482,6 +483,7 @@ static const struct fs_parameter_spec erofs_fs_paramete= rs[] =3D { fsparam_string("device", Opt_device), fsparam_string("fsid", Opt_fsid), fsparam_string("domain_id", Opt_domain_id), + fsparam_flag_no("sharecache", Opt_sharecache), {} }; =20 @@ -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=3D%s", sbi->fsid); if (sbi->domain_id) seq_printf(seq, ",domain_id=3D%s", sbi->domain_id); + if (test_opt(opt, SHARE_CACHE)) + seq_puts(seq, ",sharecache"); + else + seq_puts(seq, ",nosharecache"); #endif return 0; } --=20 2.19.1.6.gb485710b