From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99E0235FF55; Fri, 16 Jan 2026 10:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.224 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558129; cv=none; b=fLdNvjLNFjhHitQ0uWpGbPhxirIQsmT0RVYq1Ej4RXvxLFgSEghLp1huWffbXFJa1CTd189DOunzsn4F/A6YMuMokvaXZMYFS6laQFbw2XRPcISrYUSKxnmzLSve0a9TWeXv+W0+QvTnGn0RVmAStSHyqU6eFnWvOr/Stt3u5kA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558129; c=relaxed/simple; bh=/DOP628ou57Yld7gMP4kYmxmunqIn78QOq3XPXhRUAY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H2UwF8O6ijYynBF4qJuxhbgz0xZgtNy72M6Ub952LhCzHMPXYXtv8anrBHjyq7ARQ0KsnM3m6syyyxWurLvotF1gFLJ6FPL9FPymq6qe2YtlxYYwF5a9AJszQdqIUW/CNh9ZdXqhm6bp5ZRI310rTUFEUUaFFIJFRrKt/+jE6l4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=aViTVgKb; arc=none smtp.client-ip=113.46.200.224 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="aViTVgKb" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=IJqOVDMyH2cU6HZaQ6KGaq7L7r7sGB/NU+oSMo68sYk=; b=aViTVgKbU3p9F6fvfb/DRZ9GIhljQ3rKlHQMPA1II5YccTLm1l79Wl8RBcmkkhYNwMzHKxXz0 9YV1Y0ow6kq2fONT0jz7uycW8blnvYaMxZYGGACdFOLs9cXkvJ3tWcEIwXSiiP4I/798eIXtO+j kCdEQvGGYPkM65v8oi6/oqU= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4dswTC5Tc3z1cyq4; Fri, 16 Jan 2026 18:05:19 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 1137740539; Fri, 16 Jan 2026 18:08:40 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:39 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 1/9] fs: Export alloc_empty_backing_file Date: Fri, 16 Jan 2026 09:55:42 +0000 Message-ID: <20260116095550.627082-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" There is no need to open nonexistent real files if backing files couldn't be backed by real files (e.g., EROFS page cache sharing doesn't need typical real files to open again). Therefore, we export the alloc_empty_backing_file() helper, allowing filesystems to dynamically set the backing file without real file open. This is particularly useful for obtaining the correct @path and @inode when calling file_user_path() and file_user_inode(). Signed-off-by: Hongbo Li Reviewed-by: Gao Xiang Acked-by: Amir Goldstein --- fs/file_table.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/file_table.c b/fs/file_table.c index cd4a3db4659a..476edfe7d8f5 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -308,6 +308,7 @@ struct file *alloc_empty_backing_file(int flags, const = struct cred *cred) ff->file.f_mode |=3D FMODE_BACKING | FMODE_NOACCOUNT; return &ff->file; } +EXPORT_SYMBOL_GPL(alloc_empty_backing_file); =20 /** * file_init_path - initialize a 'struct file' based on path --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8A32361642; Fri, 16 Jan 2026 10:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558137; cv=none; b=JJObHoGw9tnlJsRDqTcbypd5Q4OAvIxyUrqh/oSABwVrTQIJoOl8Snv+CG8PUvYhGoEofiGfytiRkMoYepwK2aRSEeklDke47syHrupb/D2WP/1kgIBvFIn1Sslja+m+dC2WCeRi7/d3q99MgYcYTwZGaZkBdpKdPnmS3pU7QZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558137; c=relaxed/simple; bh=bLPyX55goz9UpKyTSsH/rsQVx9Lcd+68NmlbcIC2gHs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q12lORboghaWGFSFPreTqTs19oVbcocQ/hD10Cuhtv70YihmgVnM+X6UYCPNqYSMJMOWaUYh6EY/lHY5bvuu7jBXMQSmUWYtUdA5O/I0KClbZU/mNZ/NgyDub93yG6nNtIKOhFTL0rxZ1+WnsM5ZwjG38X0+jqNPHbfumMdfJw0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=oJbF4d0t; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="oJbF4d0t" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=otZzmT6rxktVNDVECk5mC06H07hAnwXYZ9UJTBeZ2EE=; b=oJbF4d0t5wRl+Q3D2MEG1XxQ46Sws4p95wCVOUDW01xFXaHTtZLIuDaU1CGP+FYnhHWI9gyc+ vl1DpAL3wOTCohN8rpHMh58gcD4/VUG36UAoqVqtLr4Wg1E8jI9n820W4N+o3Weae21OVDrRQCJ RiDve7yi5NEMgQAYQ4IAnOc= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4dswSv2rRjzpStd; Fri, 16 Jan 2026 18:05:03 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 81880201E9; Fri, 16 Jan 2026 18:08:40 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:39 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 2/9] erofs: decouple `struct erofs_anon_fs_type` Date: Fri, 16 Jan 2026 09:55:43 +0000 Message-ID: <20260116095550.627082-3-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" From: Gao Xiang - Move the `struct erofs_anon_fs_type` to super.c and expose it in preparation for the upcoming page cache share feature; - Remove the `.owner` field, as they are all internal mounts and fully managed by EROFS. Retaining `.owner` would unnecessarily increment module reference counts, preventing the EROFS kernel module from being unloaded. Signed-off-by: Gao Xiang --- fs/erofs/fscache.c | 13 ------------- fs/erofs/internal.h | 2 ++ fs/erofs/super.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 7a346e20f7b7..f4937b025038 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -3,7 +3,6 @@ * Copyright (C) 2022, Alibaba Cloud * Copyright (C) 2022, Bytedance Inc. All rights reserved. */ -#include #include #include "internal.h" =20 @@ -13,18 +12,6 @@ static LIST_HEAD(erofs_domain_list); static LIST_HEAD(erofs_domain_cookies_list); static struct vfsmount *erofs_pseudo_mnt; =20 -static int erofs_anon_init_fs_context(struct fs_context *fc) -{ - return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM; -} - -static struct file_system_type erofs_anon_fs_type =3D { - .owner =3D THIS_MODULE, - .name =3D "pseudo_erofs", - .init_fs_context =3D erofs_anon_init_fs_context, - .kill_sb =3D kill_anon_super, -}; - struct erofs_fscache_io { struct netfs_cache_resources cres; struct iov_iter iter; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index f7f622836198..98fe652aea33 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -188,6 +188,8 @@ static inline bool erofs_is_fileio_mode(struct erofs_sb= _info *sbi) return IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && sbi->dif0.file; } =20 +extern struct file_system_type erofs_anon_fs_type; + static inline bool erofs_is_fscache_mode(struct super_block *sb) { return IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 937a215f626c..f18f43b78fca 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "xattr.h" =20 #define CREATE_TRACE_POINTS @@ -936,6 +937,19 @@ static struct file_system_type erofs_fs_type =3D { }; MODULE_ALIAS_FS("erofs"); =20 +#if defined(CONFIG_EROFS_FS_ONDEMAND) +static int erofs_anon_init_fs_context(struct fs_context *fc) +{ + return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM; +} + +struct file_system_type erofs_anon_fs_type =3D { + .name =3D "pseudo_erofs", + .init_fs_context =3D erofs_anon_init_fs_context, + .kill_sb =3D kill_anon_super, +}; +#endif + static int __init erofs_module_init(void) { int err; --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C5813090DC; Fri, 16 Jan 2026 10:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558127; cv=none; b=gIo/nsgu9yc83xWGxDdfIYHdQM8Cvmby4etAT9aJ883pDK/EkHSzwoEceNvha1Zri2HmQu7zGq4VoZDxiAItHyPLyy4Q7iWeA2pMZSejmatTm8BXumRY7ZWH2ferPCiZmOpgtqCtYsmSCcXq/jVu1+RqWoQEsPi6BNC27/7h1pU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558127; c=relaxed/simple; bh=hjtjZM+/G2TpOF1N0I5N/LIijanDvM1LsENzKcdgQcE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qLq1C/zym6WTpi9XHlhJ0o5cfbKrXpliXo/3qmzbxmWE5SsMlovxsiHDtcsmfHJua70mxS+xK7FAB51O+wLwurR3TO70SPO/WmwvMM32XfBbG5bZmDeQiTQulwK5xXJk9B3e4lLzl/Ab/t+yk4xOINt9jXWfVRVdZFY/IX50uhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=VpLGGUGK; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="VpLGGUGK" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=R7ApHnfNiBchhGXf8a8E/bOiMkaOH3q7V/YSP7S/uow=; b=VpLGGUGK+sRa0H7ow0v8gH347fWJZpEHkyBZ3bykf3XfoVbM3NPW+A+CBiyS787GwG0uZeAsy ruololEhaWwkPw29RrTxowpDFgVzkkLk4xJ2sTZwI9Q4ua+/fGcOQsKa6W7kUNaxDZdizCESOW3 zJu9mBU9EfwJBzx/UWj/eLE= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4dswTC3zv9zmV8H; Fri, 16 Jan 2026 18:05:19 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id F366840538; Fri, 16 Jan 2026 18:08:40 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:40 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 3/9] erofs: support user-defined fingerprint name Date: Fri, 16 Jan 2026 09:55:44 +0000 Message-ID: <20260116095550.627082-4-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" From: Hongzhen Luo When creating the EROFS image, users can specify the fingerprint name. This is to prepare for the upcoming inode page cache share. Signed-off-by: Hongzhen Luo Signed-off-by: Hongbo Li Reviewed-by: Gao Xiang --- fs/erofs/Kconfig | 9 +++++++++ fs/erofs/erofs_fs.h | 5 +++-- fs/erofs/internal.h | 2 ++ fs/erofs/super.c | 9 +++++++++ fs/erofs/xattr.c | 13 +++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig index d81f3318417d..b71f2a8074fe 100644 --- a/fs/erofs/Kconfig +++ b/fs/erofs/Kconfig @@ -194,3 +194,12 @@ config EROFS_FS_PCPU_KTHREAD_HIPRI at higher priority. =20 If unsure, say N. + +config EROFS_FS_PAGE_CACHE_SHARE + bool "EROFS page cache share support (experimental)" + depends on EROFS_FS && EROFS_FS_XATTR && !EROFS_FS_ONDEMAND + help + This enables page cache sharing among inodes with identical + content fingerprints on the same machine. + + If unsure, say N. diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h index e24268acdd62..b30a74d307c5 100644 --- a/fs/erofs/erofs_fs.h +++ b/fs/erofs/erofs_fs.h @@ -17,7 +17,7 @@ #define EROFS_FEATURE_COMPAT_XATTR_FILTER 0x00000004 #define EROFS_FEATURE_COMPAT_SHARED_EA_IN_METABOX 0x00000008 #define EROFS_FEATURE_COMPAT_PLAIN_XATTR_PFX 0x00000010 - +#define EROFS_FEATURE_COMPAT_ISHARE_XATTRS 0x00000020 =20 /* * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should @@ -83,7 +83,8 @@ struct erofs_super_block { __le32 xattr_prefix_start; /* start of long xattr prefixes */ __le64 packed_nid; /* nid of the special packed inode */ __u8 xattr_filter_reserved; /* reserved for xattr name filter */ - __u8 reserved[3]; + __u8 ishare_xattr_prefix_id; + __u8 reserved[2]; __le32 build_time; /* seconds added to epoch for mkfs time */ __le64 rootnid_8b; /* (48BIT on) nid of root directory */ __le64 reserved2; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 98fe652aea33..ec79e8b44d3b 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -134,6 +134,7 @@ struct erofs_sb_info { u32 xattr_blkaddr; u32 xattr_prefix_start; u8 xattr_prefix_count; + u8 ishare_xattr_prefix_id; struct erofs_xattr_prefix_item *xattr_prefixes; unsigned int xattr_filter_reserved; #endif @@ -238,6 +239,7 @@ EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM) EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER) EROFS_FEATURE_FUNCS(shared_ea_in_metabox, compat, COMPAT_SHARED_EA_IN_META= BOX) EROFS_FEATURE_FUNCS(plain_xattr_pfx, compat, COMPAT_PLAIN_XATTR_PFX) +EROFS_FEATURE_FUNCS(ishare_xattrs, compat, COMPAT_ISHARE_XATTRS) =20 static inline u64 erofs_nid_to_ino64(struct erofs_sb_info *sbi, erofs_nid_= t nid) { diff --git a/fs/erofs/super.c b/fs/erofs/super.c index f18f43b78fca..dca1445f6c92 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -320,6 +320,15 @@ static int erofs_read_superblock(struct super_block *s= b) sbi->xattr_prefix_start =3D le32_to_cpu(dsb->xattr_prefix_start); sbi->xattr_prefix_count =3D dsb->xattr_prefix_count; sbi->xattr_filter_reserved =3D dsb->xattr_filter_reserved; + if (erofs_sb_has_ishare_xattrs(sbi)) { + if (dsb->ishare_xattr_prefix_id >=3D sbi->xattr_prefix_count) { + erofs_err(sb, "invalid ishare xattr prefix id %u", + dsb->ishare_xattr_prefix_id); + ret =3D -EFSCORRUPTED; + goto out; + } + sbi->ishare_xattr_prefix_id =3D dsb->ishare_xattr_prefix_id; + } #endif sbi->islotbits =3D ilog2(sizeof(struct erofs_inode_compact)); if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) { diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index 396536d9a862..ae61f20cb861 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -519,6 +519,19 @@ int erofs_xattr_prefixes_init(struct super_block *sb) } =20 erofs_put_metabuf(&buf); + if (!ret && erofs_sb_has_ishare_xattrs(sbi)) { + struct erofs_xattr_prefix_item *pf =3D pfs + sbi->ishare_xattr_prefix_id; + struct erofs_xattr_long_prefix *newpfx; + + newpfx =3D krealloc(pf->prefix, + sizeof(*newpfx) + pf->infix_len + 1, GFP_KERNEL); + if (newpfx) { + newpfx->infix[pf->infix_len] =3D '\0'; + pf->prefix =3D newpfx; + } else { + ret =3D -ENOMEM; + } + } sbi->xattr_prefixes =3D pfs; if (ret) erofs_xattr_prefixes_cleanup(sb); --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E364A31D393; Fri, 16 Jan 2026 10:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558126; cv=none; b=fykteLkMLIOKL2RQI748pUja9p7CkMhV+XtY9DKi8XavGQ/lDUJ43e73lz3s2c/6VrG7wR4aDjyGmrA/KJPT9g8fZI77h3/++3gpIh/JhVN+XDeY4XkgJNPWaj7GPEWmmSA5Y1k1wMb9mlHKXyBisQM7MHXUFz2k+Arx//NYnRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558126; c=relaxed/simple; bh=S7RjyECHRDHNXIL1Al8k3RPWxT6vjUtdtCg4YK41Swo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aZSHh8MbHQuQeyX9nzE2tDLBVBXCFogHgYO+IxPA1f8ID4B1V7gMTiV50IQjPO3iLwE/V9ir9ULg0Z2m5ijFom0e80Z6B6LVs0MdzQPaVpK5qKT1Qm4xDF6iiJWoERoqcDZG7tA/+9tFtJitFgEp/L9RBPqogqW1E9nXvHmMjvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=6vbCpnyS; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="6vbCpnyS" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Ii4OAViqYCm/sgHCVWzYCGvcDaSOgZiGOYibBrZpOYU=; b=6vbCpnySXkmEqQBj+K55ndCgfd4lrG6flgNfy05ERumm6g/PuPxdBMSEG46fc1SwIvzqG7gg+ 1+WQ3JCBdt0XUhX2EChxqn0BVx0dlMHswwEPUz0SaTu0tPTlwDgXoNAw249+FBw+UlUxb7wWNZW cBSMB8miZLhswOMENMspOgk= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4dswTf34yDz12LrW; Fri, 16 Jan 2026 18:05:42 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 798AE405A2; Fri, 16 Jan 2026 18:08:41 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:40 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 4/9] erofs: support domain-specific page cache share Date: Fri, 16 Jan 2026 09:55:45 +0000 Message-ID: <20260116095550.627082-5-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" From: Hongzhen Luo Only files in the same domain will share the page cache. Also modify the sysfs related content in preparation for the upcoming page cache share feature. Signed-off-by: Hongzhen Luo Signed-off-by: Hongbo Li Reviewed-by: Gao Xiang --- fs/erofs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index dca1445f6c92..960da62636ad 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -524,6 +524,8 @@ static int erofs_fc_parse_param(struct fs_context *fc, if (!sbi->fsid) return -ENOMEM; break; +#endif +#if defined(CONFIG_EROFS_FS_ONDEMAND) || defined(CONFIG_EROFS_FS_PAGE_CACH= E_SHARE) case Opt_domain_id: kfree(sbi->domain_id); sbi->domain_id =3D kstrdup(param->string, GFP_KERNEL); @@ -624,7 +626,7 @@ static void erofs_set_sysfs_name(struct super_block *sb) { struct erofs_sb_info *sbi =3D EROFS_SB(sb); =20 - if (sbi->domain_id) + if (sbi->domain_id && !erofs_sb_has_ishare_xattrs(sbi)) super_set_sysfs_name_generic(sb, "%s,%s", sbi->domain_id, sbi->fsid); else if (sbi->fsid) @@ -1054,12 +1056,10 @@ static int erofs_show_options(struct seq_file *seq,= struct dentry *root) seq_puts(seq, ",dax=3Dnever"); if (erofs_is_fileio_mode(sbi) && test_opt(opt, DIRECT_IO)) seq_puts(seq, ",directio"); -#ifdef CONFIG_EROFS_FS_ONDEMAND if (sbi->fsid) seq_printf(seq, ",fsid=3D%s", sbi->fsid); if (sbi->domain_id) seq_printf(seq, ",domain_id=3D%s", sbi->domain_id); -#endif if (sbi->dif0.fsoff) seq_printf(seq, ",fsoffset=3D%llu", sbi->dif0.fsoff); return 0; --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5501E35F8CE; Fri, 16 Jan 2026 10:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558144; cv=none; b=HY9C2foSvHn3e1BkOdzA4xfA953Kc1P6lwIVS+WNxkxrXACbmi462sR1dYN4+/M2FMt6hcPOUFReXNZkH3cza2XcUiheLki8nkX+wyeni/ktko8g3/Nb8R8AI29WJSbWnc0Hvttd7pgqtSCR11lqoD7oUZQcYIozMuJkv8GpucU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558144; c=relaxed/simple; bh=HdQNdX4zT6y6DAZpe69iHPcGyqOVEb8iEwd+I6bjlpI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AmRGhzpb4ir3h6AI+/b2Pz86PdF66eGU438sdMNpGKF1yekGJBaGLMotv7nqrXea/08GcCjy3B2e0onWfs3f2UofWX6N8UqBZjQuxPXx+xR+FEzSdyrxgCYuvvE4bQqMZDxFNaCQBRzxpsZtfnTNqpKQ1EkpIPg15F/ViGdw4Bk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=AOm8y1/q; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="AOm8y1/q" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=oaXMnHMsTgclV2eFpMcItrz4JdnJ98d1KbPe1/xinww=; b=AOm8y1/qFheYv7n3fhMyN5xD2G+CW1uJtKs0H4toLIoqoGklCUim2WoG5su1GNyvj4273jjgW knyIJrjtPjvbwViHGF3QTAp1t75GL40LPM1Uy0mg4fYH0Owp3U7MT/o2fJxaIMCL72TPGnVu9zS 6CTLRcHENvAKG8vaL/w17gM= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4dswTD3ZcdzKm4j; Fri, 16 Jan 2026 18:05:20 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id F35A840538; Fri, 16 Jan 2026 18:08:41 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:41 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 5/9] erofs: introduce the page cache share feature Date: Fri, 16 Jan 2026 09:55:46 +0000 Message-ID: <20260116095550.627082-6-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" From: Hongzhen Luo Currently, reading files with different paths (or names) but the same content will consume multiple copies of the page cache, even if the content of these page caches is the same. For example, reading identical files (e.g., *.so files) from two different minor versions of container images will cost multiple copies of the same page cache, since different containers have different mount points. Therefore, sharing the page cache for files with the same content can save memory. This introduces the page cache share feature in erofs. It allocate a deduplicated inode and use its page cache as shared. Reads for files with identical content will ultimately be routed to the page cache of the deduplicated inode. In this way, a single page cache satisfies multiple read requests for different files with the same contents. We introduce inode_share mount option to enable the page sharing mode during mounting. Signed-off-by: Hongzhen Luo Signed-off-by: Hongbo Li --- Documentation/filesystems/erofs.rst | 5 + fs/erofs/Makefile | 1 + fs/erofs/inode.c | 24 +---- fs/erofs/internal.h | 57 ++++++++++ fs/erofs/ishare.c | 161 ++++++++++++++++++++++++++++ fs/erofs/super.c | 56 +++++++++- fs/erofs/xattr.c | 34 ++++++ fs/erofs/xattr.h | 3 + 8 files changed, 316 insertions(+), 25 deletions(-) create mode 100644 fs/erofs/ishare.c diff --git a/Documentation/filesystems/erofs.rst b/Documentation/filesystem= s/erofs.rst index 08194f194b94..27d3caa3c73c 100644 --- a/Documentation/filesystems/erofs.rst +++ b/Documentation/filesystems/erofs.rst @@ -128,7 +128,12 @@ device=3D%s Specify a path to an extra de= vice 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. + Also used for inode page sharing mode which defines= a sharing + domain. fsoffset=3D%llu Specify block-aligned filesystem offset for the p= rimary device. +inode_share Enable inode page sharing for this filesystem. Ino= des with + identical content within the same domain ID can sha= re the + page cache. =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/Makefile b/fs/erofs/Makefile index 549abc424763..a80e1762b607 100644 --- a/fs/erofs/Makefile +++ b/fs/erofs/Makefile @@ -10,3 +10,4 @@ erofs-$(CONFIG_EROFS_FS_ZIP_ZSTD) +=3D decompressor_zstd.o erofs-$(CONFIG_EROFS_FS_ZIP_ACCEL) +=3D decompressor_crypto.o erofs-$(CONFIG_EROFS_FS_BACKED_BY_FILE) +=3D fileio.o erofs-$(CONFIG_EROFS_FS_ONDEMAND) +=3D fscache.o +erofs-$(CONFIG_EROFS_FS_PAGE_CACHE_SHARE) +=3D ishare.o diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index bce98c845a18..202cbbb4eada 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -203,7 +203,6 @@ static int erofs_read_inode(struct inode *inode) =20 static int erofs_fill_inode(struct inode *inode) { - struct erofs_inode *vi =3D EROFS_I(inode); int err; =20 trace_erofs_fill_inode(inode); @@ -235,28 +234,7 @@ static int erofs_fill_inode(struct inode *inode) } =20 mapping_set_large_folios(inode->i_mapping); - if (erofs_inode_is_data_compressed(vi->datalayout)) { -#ifdef CONFIG_EROFS_FS_ZIP - DO_ONCE_LITE_IF(inode->i_blkbits !=3D PAGE_SHIFT, - erofs_info, inode->i_sb, - "EXPERIMENTAL EROFS subpage compressed block support in use. Use at y= our own risk!"); - inode->i_mapping->a_ops =3D &z_erofs_aops; -#else - err =3D -EOPNOTSUPP; -#endif - } else { - inode->i_mapping->a_ops =3D &erofs_aops; -#ifdef CONFIG_EROFS_FS_ONDEMAND - if (erofs_is_fscache_mode(inode->i_sb)) - inode->i_mapping->a_ops =3D &erofs_fscache_access_aops; -#endif -#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE - if (erofs_is_fileio_mode(EROFS_SB(inode->i_sb))) - inode->i_mapping->a_ops =3D &erofs_fileio_aops; -#endif - } - - return err; + return erofs_inode_set_aops(inode, inode, false); } =20 /* diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index ec79e8b44d3b..15945e3308b8 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -179,6 +179,7 @@ struct erofs_sb_info { #define EROFS_MOUNT_DAX_ALWAYS 0x00000040 #define EROFS_MOUNT_DAX_NEVER 0x00000080 #define EROFS_MOUNT_DIRECT_IO 0x00000100 +#define EROFS_MOUNT_INODE_SHARE 0x00000200 =20 #define clear_opt(opt, option) ((opt)->mount_opt &=3D ~EROFS_MOUNT_##optio= n) #define set_opt(opt, option) ((opt)->mount_opt |=3D EROFS_MOUNT_##option) @@ -269,6 +270,11 @@ static inline u64 erofs_nid_to_ino64(struct erofs_sb_i= nfo *sbi, erofs_nid_t nid) /* default readahead size of directories */ #define EROFS_DIR_RA_BYTES 16384 =20 +struct erofs_inode_fingerprint { + u8 *opaque; + int size; +}; + struct erofs_inode { erofs_nid_t nid; =20 @@ -304,6 +310,18 @@ struct erofs_inode { }; #endif /* CONFIG_EROFS_FS_ZIP */ }; +#ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE + struct list_head ishare_list; + union { + /* for each anon shared inode */ + struct { + struct erofs_inode_fingerprint fingerprint; + spinlock_t ishare_lock; + }; + /* for each real inode */ + struct inode *sharedinode; + }; +#endif /* the corresponding vfs inode */ struct inode vfs_inode; }; @@ -410,6 +428,7 @@ extern const struct inode_operations erofs_dir_iops; =20 extern const struct file_operations erofs_file_fops; extern const struct file_operations erofs_dir_fops; +extern const struct file_operations erofs_ishare_fops; =20 extern const struct iomap_ops z_erofs_iomap_report_ops; =20 @@ -455,6 +474,32 @@ static inline void *erofs_vm_map_ram(struct page **pag= es, unsigned int count) return NULL; } =20 +static inline int erofs_inode_set_aops(struct inode *inode, + struct inode *realinode, bool no_fscache) +{ + if (erofs_inode_is_data_compressed(EROFS_I(realinode)->datalayout)) { +#ifdef CONFIG_EROFS_FS_ZIP + DO_ONCE_LITE_IF(realinode->i_blkbits !=3D PAGE_SHIFT, + erofs_info, realinode->i_sb, + "EXPERIMENTAL EROFS subpage compressed block support in use. Use at y= our own risk!"); + inode->i_mapping->a_ops =3D &z_erofs_aops; +#else + return -EOPNOTSUPP; +#endif + } else { + inode->i_mapping->a_ops =3D &erofs_aops; +#ifdef CONFIG_EROFS_FS_ONDEMAND + if (!no_fscache && erofs_is_fscache_mode(realinode->i_sb)) + inode->i_mapping->a_ops =3D &erofs_fscache_access_aops; +#endif +#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE + if (erofs_is_fileio_mode(EROFS_SB(realinode->i_sb))) + inode->i_mapping->a_ops =3D &erofs_fileio_aops; +#endif + } + return 0; +} + int erofs_register_sysfs(struct super_block *sb); void erofs_unregister_sysfs(struct super_block *sb); int __init erofs_init_sysfs(void); @@ -541,6 +586,18 @@ static inline struct bio *erofs_fscache_bio_alloc(stru= ct erofs_map_dev *mdev) { static inline void erofs_fscache_submit_bio(struct bio *bio) {} #endif =20 +#ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE +int __init erofs_init_ishare(void); +void erofs_exit_ishare(void); +bool erofs_ishare_fill_inode(struct inode *inode); +void erofs_ishare_free_inode(struct inode *inode); +#else +static inline int erofs_init_ishare(void) { return 0; } +static inline void erofs_exit_ishare(void) {} +static inline bool erofs_ishare_fill_inode(struct inode *inode) { return f= alse; } +static inline void erofs_ishare_free_inode(struct inode *inode) {} +#endif + long erofs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); long erofs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c new file mode 100644 index 000000000000..6b710c935afb --- /dev/null +++ b/fs/erofs/ishare.c @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024, Alibaba Cloud + */ +#include +#include +#include "internal.h" +#include "xattr.h" + +#include "../internal.h" + +static struct vfsmount *erofs_ishare_mnt; + +static int erofs_ishare_iget5_eq(struct inode *inode, void *data) +{ + struct erofs_inode_fingerprint *fp1 =3D &EROFS_I(inode)->fingerprint; + struct erofs_inode_fingerprint *fp2 =3D data; + + return fp1->size =3D=3D fp2->size && + !memcmp(fp1->opaque, fp2->opaque, fp2->size); +} + +static int erofs_ishare_iget5_set(struct inode *inode, void *data) +{ + struct erofs_inode *vi =3D EROFS_I(inode); + + vi->fingerprint =3D *(struct erofs_inode_fingerprint *)data; + INIT_LIST_HEAD(&vi->ishare_list); + spin_lock_init(&vi->ishare_lock); + return 0; +} + +bool erofs_ishare_fill_inode(struct inode *inode) +{ + struct erofs_sb_info *sbi =3D EROFS_SB(inode->i_sb); + struct erofs_inode *vi =3D EROFS_I(inode); + struct erofs_inode_fingerprint fp; + struct inode *sharedinode; + unsigned long hash; + + if (erofs_xattr_fill_inode_fingerprint(&fp, inode, sbi->domain_id)) + return false; + hash =3D xxh32(fp.opaque, fp.size, 0); + sharedinode =3D iget5_locked(erofs_ishare_mnt->mnt_sb, hash, + erofs_ishare_iget5_eq, erofs_ishare_iget5_set, + &fp); + if (!sharedinode) { + kfree(fp.opaque); + return false; + } + + if (inode_state_read_once(sharedinode) & I_NEW) { + if (erofs_inode_set_aops(sharedinode, inode, true)) { + iget_failed(sharedinode); + kfree(fp.opaque); + return false; + } + sharedinode->i_mode =3D vi->vfs_inode.i_mode; + sharedinode->i_size =3D vi->vfs_inode.i_size; + unlock_new_inode(sharedinode); + } else { + kfree(fp.opaque); + } + vi->sharedinode =3D sharedinode; + INIT_LIST_HEAD(&vi->ishare_list); + spin_lock(&EROFS_I(sharedinode)->ishare_lock); + list_add(&vi->ishare_list, &EROFS_I(sharedinode)->ishare_list); + spin_unlock(&EROFS_I(sharedinode)->ishare_lock); + return true; +} + +void erofs_ishare_free_inode(struct inode *inode) +{ + struct erofs_inode *vi =3D EROFS_I(inode); + struct inode *sharedinode =3D vi->sharedinode; + + if (!sharedinode) + return; + spin_lock(&EROFS_I(sharedinode)->ishare_lock); + list_del(&vi->ishare_list); + spin_unlock(&EROFS_I(sharedinode)->ishare_lock); + iput(sharedinode); + vi->sharedinode =3D NULL; +} + +static int erofs_ishare_file_open(struct inode *inode, struct file *file) +{ + struct inode *sharedinode =3D EROFS_I(inode)->sharedinode; + struct file *realfile; + + if (file->f_flags & O_DIRECT) + return -EINVAL; + realfile =3D alloc_empty_backing_file(O_RDONLY|O_NOATIME, current_cred()); + if (IS_ERR(realfile)) + return PTR_ERR(realfile); + ihold(sharedinode); + realfile->f_op =3D &erofs_file_fops; + realfile->f_inode =3D sharedinode; + realfile->f_mapping =3D sharedinode->i_mapping; + path_get(&file->f_path); + backing_file_set_user_path(realfile, &file->f_path); + + file_ra_state_init(&realfile->f_ra, file->f_mapping); + realfile->private_data =3D EROFS_I(inode); + file->private_data =3D realfile; + return 0; +} + +static int erofs_ishare_file_release(struct inode *inode, struct file *fil= e) +{ + struct file *realfile =3D file->private_data; + + iput(realfile->f_inode); + fput(realfile); + file->private_data =3D NULL; + return 0; +} + +static ssize_t erofs_ishare_file_read_iter(struct kiocb *iocb, + struct iov_iter *to) +{ + struct file *realfile =3D iocb->ki_filp->private_data; + struct kiocb dedup_iocb; + ssize_t nread; + + if (!iov_iter_count(to)) + return 0; + kiocb_clone(&dedup_iocb, iocb, realfile); + nread =3D filemap_read(&dedup_iocb, to, 0); + iocb->ki_pos =3D dedup_iocb.ki_pos; + return nread; +} + +static int erofs_ishare_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct file *realfile =3D file->private_data; + + vma_set_file(vma, realfile); + return generic_file_readonly_mmap(file, vma); +} + +const struct file_operations erofs_ishare_fops =3D { + .open =3D erofs_ishare_file_open, + .llseek =3D generic_file_llseek, + .read_iter =3D erofs_ishare_file_read_iter, + .mmap =3D erofs_ishare_mmap, + .release =3D erofs_ishare_file_release, + .get_unmapped_area =3D thp_get_unmapped_area, + .splice_read =3D filemap_splice_read, +}; + +int __init erofs_init_ishare(void) +{ + erofs_ishare_mnt =3D kern_mount(&erofs_anon_fs_type); + return PTR_ERR_OR_ZERO(erofs_ishare_mnt); +} + +void erofs_exit_ishare(void) +{ + kern_unmount(erofs_ishare_mnt); +} diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 960da62636ad..1f2b8732b29e 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -396,6 +396,7 @@ static void erofs_default_options(struct erofs_sb_info = *sbi) enum { Opt_user_xattr, Opt_acl, Opt_cache_strategy, Opt_dax, Opt_dax_enum, Opt_device, Opt_fsid, Opt_domain_id, Opt_directio, Opt_fsoffset, + Opt_inode_share, }; =20 static const struct constant_table erofs_param_cache_strategy[] =3D { @@ -423,6 +424,7 @@ static const struct fs_parameter_spec erofs_fs_paramete= rs[] =3D { fsparam_string("domain_id", Opt_domain_id), fsparam_flag_no("directio", Opt_directio), fsparam_u64("fsoffset", Opt_fsoffset), + fsparam_flag("inode_share", Opt_inode_share), {} }; =20 @@ -551,6 +553,13 @@ static int erofs_fc_parse_param(struct fs_context *fc, case Opt_fsoffset: sbi->dif0.fsoff =3D result.uint_64; break; + case Opt_inode_share: +#if defined(CONFIG_EROFS_FS_PAGE_CACHE_SHARE) + set_opt(&sbi->opt, INODE_SHARE); +#else + errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name); +#endif + break; } return 0; } @@ -649,6 +658,11 @@ static int erofs_fc_fill_super(struct super_block *sb,= struct fs_context *fc) sb->s_maxbytes =3D MAX_LFS_FILESIZE; sb->s_op =3D &erofs_sops; =20 + if (test_opt(&sbi->opt, DAX_ALWAYS) && test_opt(&sbi->opt, INODE_SHARE)) { + errorfc(fc, "FSDAX is not allowed when inode_ishare is on"); + return -EINVAL; + } + sbi->blkszbits =3D PAGE_SHIFT; if (!sb->s_bdev) { /* @@ -719,6 +733,12 @@ static int erofs_fc_fill_super(struct super_block *sb,= struct fs_context *fc) erofs_info(sb, "unsupported blocksize for DAX"); clear_opt(&sbi->opt, DAX_ALWAYS); } + if (test_opt(&sbi->opt, INODE_SHARE) && !erofs_sb_has_ishare_xattrs(sbi))= { + erofs_info(sb, "on-disk ishare xattrs not found. Turning off inode_share= ."); + clear_opt(&sbi->opt, INODE_SHARE); + } + if (test_opt(&sbi->opt, INODE_SHARE)) + erofs_info(sb, "EXPERIMENTAL EROFS page cache share support in use. Use = at your own risk!"); =20 sb->s_time_gran =3D 1; sb->s_xattr =3D erofs_xattr_handlers; @@ -948,10 +968,32 @@ static struct file_system_type erofs_fs_type =3D { }; MODULE_ALIAS_FS("erofs"); =20 -#if defined(CONFIG_EROFS_FS_ONDEMAND) +#if defined(CONFIG_EROFS_FS_ONDEMAND) || defined(CONFIG_EROFS_FS_PAGE_CACH= E_SHARE) +static void erofs_free_anon_inode(struct inode *inode) +{ + struct erofs_inode *vi =3D EROFS_I(inode); + +#ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE + kfree(vi->fingerprint.opaque); +#endif + kmem_cache_free(erofs_inode_cachep, vi); +} + +static const struct super_operations erofs_anon_sops =3D { + .alloc_inode =3D erofs_alloc_inode, + .drop_inode =3D inode_just_drop, + .free_inode =3D erofs_free_anon_inode, +}; + static int erofs_anon_init_fs_context(struct fs_context *fc) { - return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM; + struct pseudo_fs_context *ctx; + + ctx =3D init_pseudo(fc, EROFS_SUPER_MAGIC); + if (!ctx) + return -ENOMEM; + ctx->ops =3D &erofs_anon_sops; + return 0; } =20 struct file_system_type erofs_anon_fs_type =3D { @@ -986,6 +1028,10 @@ static int __init erofs_module_init(void) if (err) goto sysfs_err; =20 + err =3D erofs_init_ishare(); + if (err) + goto ishare_err; + err =3D register_filesystem(&erofs_fs_type); if (err) goto fs_err; @@ -993,6 +1039,8 @@ static int __init erofs_module_init(void) return 0; =20 fs_err: + erofs_exit_ishare(); +ishare_err: erofs_exit_sysfs(); sysfs_err: z_erofs_exit_subsystem(); @@ -1010,6 +1058,7 @@ static void __exit erofs_module_exit(void) /* Ensure all RCU free inodes / pclusters are safe to be destroyed. */ rcu_barrier(); =20 + erofs_exit_ishare(); erofs_exit_sysfs(); z_erofs_exit_subsystem(); erofs_exit_shrinker(); @@ -1062,6 +1111,8 @@ static int erofs_show_options(struct seq_file *seq, s= truct dentry *root) seq_printf(seq, ",domain_id=3D%s", sbi->domain_id); if (sbi->dif0.fsoff) seq_printf(seq, ",fsoffset=3D%llu", sbi->dif0.fsoff); + if (test_opt(opt, INODE_SHARE)) + seq_puts(seq, ",inode_share"); return 0; } =20 @@ -1072,6 +1123,7 @@ static void erofs_evict_inode(struct inode *inode) dax_break_layout_final(inode); #endif =20 + erofs_ishare_free_inode(inode); truncate_inode_pages_final(&inode->i_data); clear_inode(inode); } diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index ae61f20cb861..e1709059d3cc 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -577,3 +577,37 @@ struct posix_acl *erofs_get_acl(struct inode *inode, i= nt type, bool rcu) return acl; } #endif + +#ifdef CONFIG_EROFS_FS_PAGE_CACHE_SHARE +int erofs_xattr_fill_inode_fingerprint(struct erofs_inode_fingerprint *fp, + struct inode *inode, const char *domain_id) +{ + struct erofs_sb_info *sbi =3D EROFS_SB(inode->i_sb); + struct erofs_xattr_prefix_item *prefix; + const char *infix; + int valuelen, base_index; + + if (!test_opt(&sbi->opt, INODE_SHARE)) + return -EOPNOTSUPP; + if (!sbi->xattr_prefixes) + return -EINVAL; + prefix =3D sbi->xattr_prefixes + sbi->ishare_xattr_prefix_id; + infix =3D prefix->prefix->infix; + base_index =3D prefix->prefix->base_index; + valuelen =3D erofs_getxattr(inode, base_index, infix, NULL, 0); + if (valuelen <=3D 0 || valuelen > (1 << sbi->blkszbits)) + return -EFSCORRUPTED; + fp->size =3D valuelen + (domain_id ? strlen(domain_id) : 0); + fp->opaque =3D kmalloc(fp->size, GFP_KERNEL); + if (!fp->opaque) + return -ENOMEM; + if (valuelen !=3D erofs_getxattr(inode, base_index, infix, + fp->opaque, valuelen)) { + kfree(fp->opaque); + fp->opaque =3D NULL; + return -EFSCORRUPTED; + } + memcpy(fp->opaque + valuelen, domain_id, fp->size - valuelen); + return 0; +} +#endif diff --git a/fs/erofs/xattr.h b/fs/erofs/xattr.h index 6317caa8413e..bf75a580b8f1 100644 --- a/fs/erofs/xattr.h +++ b/fs/erofs/xattr.h @@ -67,4 +67,7 @@ struct posix_acl *erofs_get_acl(struct inode *inode, int = type, bool rcu); #define erofs_get_acl (NULL) #endif =20 +int erofs_xattr_fill_inode_fingerprint(struct erofs_inode_fingerprint *fp, + struct inode *inode, const char *domain_id); + #endif --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 414DF35F8CD; Fri, 16 Jan 2026 10:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558136; cv=none; b=ishYqfkaZePh+IzGIRsqV+iK0j3Ow/6gD2vNjIdFTe0bzkKHX83t3Jr5teoj6B2VL4BNK2PrN0WaRXpjnk9nb1R/DOxaJBwOZlcgVJFMogJeTDoYfRCxzmOQ11nT5o6BebcdTWpkhl1uq2reQ3zymCPPBi9jYQMPVdXufEaa7mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558136; c=relaxed/simple; bh=X6rXmXUNuGdvzSdhj0LAFCXxZeuar96dp93fQeER5A8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iMNy1CZQ5pH2mIqZakih+dqeaCjjXUMuzZyFNAknUr+WXBh9K0pIUjV4ogcM/iufocIK0Mwv9EOt70TIVtFf8ajyViNAg+q2PS54TV8WZsISGP/vHiEcsfZrhTUh2U2Rg2v1k7rJTixVUgK70sSCKCJQkUixq1hfVV5cKvyTLB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=KapezA4+; arc=none smtp.client-ip=113.46.200.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="KapezA4+" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=8/z4J+w1iCPMn7FID9xjzFXXRGhz3sBJzrnlY03colw=; b=KapezA4+MCeSj48QqqVvPW7LPUYp4jPdBukSP5ooqAFz01Ftxgpi75y/Zhe5UGZ/VSty9Vagc P0a9tkuDKZJeisET9D/JJZV1MFx4eK5Kb5sOW9B9yIcyw9K/myBKx1XOMqor0+DmFtqp3b+2oCt XyCYJDNR1AaQnDQRFg8QCe4= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4dswTg3ShKznTVZ; Fri, 16 Jan 2026 18:05:43 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 822D540539; Fri, 16 Jan 2026 18:08:42 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:41 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 6/9] erofs: pass inode to trace_erofs_read_folio Date: Fri, 16 Jan 2026 09:55:47 +0000 Message-ID: <20260116095550.627082-7-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" The trace_erofs_read_folio accesses inode information through folio, but this method fails if the real inode is not associated with the folio(such as for the uncomping page cache sharing case). Therefore, we pass the real inode to it so that the inode information can be printed out in that case. Signed-off-by: Hongbo Li --- fs/erofs/data.c | 6 ++---- fs/erofs/fileio.c | 2 +- fs/erofs/zdata.c | 2 +- include/trace/events/erofs.h | 10 +++++----- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 71e23d91123d..ea198defb531 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -385,8 +385,7 @@ static int erofs_read_folio(struct file *file, struct f= olio *folio) }; struct erofs_iomap_iter_ctx iter_ctx =3D {}; =20 - trace_erofs_read_folio(folio, true); - + trace_erofs_read_folio(folio_inode(folio), folio, true); iomap_read_folio(&erofs_iomap_ops, &read_ctx, &iter_ctx); return 0; } @@ -400,8 +399,7 @@ static void erofs_readahead(struct readahead_control *r= ac) struct erofs_iomap_iter_ctx iter_ctx =3D {}; =20 trace_erofs_readahead(rac->mapping->host, readahead_index(rac), - readahead_count(rac), true); - + readahead_count(rac), true); iomap_readahead(&erofs_iomap_ops, &read_ctx, &iter_ctx); } =20 diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c index 932e8b353ba1..d07dc248d264 100644 --- a/fs/erofs/fileio.c +++ b/fs/erofs/fileio.c @@ -161,7 +161,7 @@ static int erofs_fileio_read_folio(struct file *file, s= truct folio *folio) struct erofs_fileio io =3D {}; int err; =20 - trace_erofs_read_folio(folio, true); + trace_erofs_read_folio(folio_inode(folio), folio, true); err =3D erofs_fileio_scan_folio(&io, folio); erofs_fileio_rq_submit(io.rq); return err; diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 3d31f7840ca0..93ab6a481b64 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1887,7 +1887,7 @@ static int z_erofs_read_folio(struct file *file, stru= ct folio *folio) Z_EROFS_DEFINE_FRONTEND(f, inode, folio_pos(folio)); int err; =20 - trace_erofs_read_folio(folio, false); + trace_erofs_read_folio(inode, folio, false); z_erofs_pcluster_readmore(&f, NULL, true); err =3D z_erofs_scan_folio(&f, folio, false); z_erofs_pcluster_readmore(&f, NULL, false); diff --git a/include/trace/events/erofs.h b/include/trace/events/erofs.h index dad7360f42f9..def20d06507b 100644 --- a/include/trace/events/erofs.h +++ b/include/trace/events/erofs.h @@ -82,9 +82,9 @@ TRACE_EVENT(erofs_fill_inode, =20 TRACE_EVENT(erofs_read_folio, =20 - TP_PROTO(struct folio *folio, bool raw), + TP_PROTO(struct inode *inode, struct folio *folio, bool raw), =20 - TP_ARGS(folio, raw), + TP_ARGS(inode, folio, raw), =20 TP_STRUCT__entry( __field(dev_t, dev ) @@ -96,9 +96,9 @@ TRACE_EVENT(erofs_read_folio, ), =20 TP_fast_assign( - __entry->dev =3D folio->mapping->host->i_sb->s_dev; - __entry->nid =3D EROFS_I(folio->mapping->host)->nid; - __entry->dir =3D S_ISDIR(folio->mapping->host->i_mode); + __entry->dev =3D inode->i_sb->s_dev; + __entry->nid =3D EROFS_I(inode)->nid; + __entry->dir =3D S_ISDIR(inode->i_mode); __entry->index =3D folio->index; __entry->uptodate =3D folio_test_uptodate(folio); __entry->raw =3D raw; --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4145B35F8C7; Fri, 16 Jan 2026 10:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558140; cv=none; b=aOmey+0Klm/17+lvyT0Kh6xAOoO8DjqIkGwoDAV/NJ5ZLO1v4VwAxQASLuB3m7JJOtuPJpjf7jIH7qOFUHDlET9+HiA6EiVve6rGPNqqwi88Xp2lz3EXAPLSllaN5yaysjcVtC6TDzYYuGYBkDADSPaoyRrXrlO+eJ+0LNd5hh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558140; c=relaxed/simple; bh=Y4+k2W4PvoiQR0mAU4aBnFx1KuJtI3DhdaRPnAxwKIA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FVZE42sTrrzC9bxh6PnQQ2yzf9KALwJFdRVgnERZ63SQaeMo6IJX4L/gi9phPB52KZ5L8w0pXU3jdvqMWG01O7qqdQfs4DkixyYr6hkdagcuMWM82XrJcHHCGw9NiX7xKJCkFzGsNNT0dWFxe+j87lwSVNtCnLBC4HRGChP0qjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=H0/fNF4h; arc=none smtp.client-ip=113.46.200.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="H0/fNF4h" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=w5l/foA3H/NaILmQeWPwMekoYDv7cqxU2HTgGg9vx6c=; b=H0/fNF4hpN+0SC2rSuMO2cBtZBmjBEWbbtlzbt9MRdJkoQ44j6HPdSUvbbJYqJpJGmDF8RhNj PG/yJERC7MTXOKAAwoM0GBseLXOiNrO0DBmDH+42UkkLtBD4dmDtFbqGQ84e82XLTSZikTaa8YZ Xxr6Qxn7PM0jO+0+UXezd1k= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4dswTg6jL8znTVZ; Fri, 16 Jan 2026 18:05:43 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id F41F040536; Fri, 16 Jan 2026 18:08:42 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:42 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 7/9] erofs: support unencoded inodes for page cache share Date: Fri, 16 Jan 2026 09:55:48 +0000 Message-ID: <20260116095550.627082-8-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" This patch adds inode page cache sharing functionality for unencoded files. I conducted experiments in the container environment. Below is the memory usage for reading all files in two different minor versions of container images: +-------------------+------------------+-------------+---------------+ | Image | Page Cache Share | Memory (MB) | Memory | | | | | Reduction (%) | +-------------------+------------------+-------------+---------------+ | | No | 241 | - | | redis +------------------+-------------+---------------+ | 7.2.4 & 7.2.5 | Yes | 163 | 33% | +-------------------+------------------+-------------+---------------+ | | No | 872 | - | | postgres +------------------+-------------+---------------+ | 16.1 & 16.2 | Yes | 630 | 28% | +-------------------+------------------+-------------+---------------+ | | No | 2771 | - | | tensorflow +------------------+-------------+---------------+ | 2.11.0 & 2.11.1 | Yes | 2340 | 16% | +-------------------+------------------+-------------+---------------+ | | No | 926 | - | | mysql +------------------+-------------+---------------+ | 8.0.11 & 8.0.12 | Yes | 735 | 21% | +-------------------+------------------+-------------+---------------+ | | No | 390 | - | | nginx +------------------+-------------+---------------+ | 7.2.4 & 7.2.5 | Yes | 219 | 44% | +-------------------+------------------+-------------+---------------+ | tomcat | No | 924 | - | | 10.1.25 & 10.1.26 +------------------+-------------+---------------+ | | Yes | 474 | 49% | +-------------------+------------------+-------------+---------------+ Additionally, the table below shows the runtime memory usage of the container: +-------------------+------------------+-------------+---------------+ | Image | Page Cache Share | Memory (MB) | Memory | | | | | Reduction (%) | +-------------------+------------------+-------------+---------------+ | | No | 35 | - | | redis +------------------+-------------+---------------+ | 7.2.4 & 7.2.5 | Yes | 28 | 20% | +-------------------+------------------+-------------+---------------+ | | No | 149 | - | | postgres +------------------+-------------+---------------+ | 16.1 & 16.2 | Yes | 95 | 37% | +-------------------+------------------+-------------+---------------+ | | No | 1028 | - | | tensorflow +------------------+-------------+---------------+ | 2.11.0 & 2.11.1 | Yes | 930 | 10% | +-------------------+------------------+-------------+---------------+ | | No | 155 | - | | mysql +------------------+-------------+---------------+ | 8.0.11 & 8.0.12 | Yes | 132 | 15% | +-------------------+------------------+-------------+---------------+ | | No | 25 | - | | nginx +------------------+-------------+---------------+ | 7.2.4 & 7.2.5 | Yes | 20 | 20% | +-------------------+------------------+-------------+---------------+ | tomcat | No | 186 | - | | 10.1.25 & 10.1.26 +------------------+-------------+---------------+ | | Yes | 98 | 48% | +-------------------+------------------+-------------+---------------+ Co-developed-by: Hongzhen Luo Signed-off-by: Hongzhen Luo Signed-off-by: Hongbo Li --- fs/erofs/data.c | 32 +++++++++++++++++++++++--------- fs/erofs/fileio.c | 25 ++++++++++++++++--------- fs/erofs/inode.c | 3 ++- fs/erofs/internal.h | 6 ++++++ fs/erofs/ishare.c | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 19 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index ea198defb531..3a4eb0dececd 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -269,6 +269,7 @@ void erofs_onlinefolio_end(struct folio *folio, int err= , bool dirty) struct erofs_iomap_iter_ctx { struct page *page; void *base; + struct inode *realinode; }; =20 static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t le= ngth, @@ -276,14 +277,15 @@ static int erofs_iomap_begin(struct inode *inode, lof= f_t offset, loff_t length, { struct iomap_iter *iter =3D container_of(iomap, struct iomap_iter, iomap); struct erofs_iomap_iter_ctx *ctx =3D iter->private; - struct super_block *sb =3D inode->i_sb; + struct inode *realinode =3D ctx ? ctx->realinode : inode; + struct super_block *sb =3D realinode->i_sb; struct erofs_map_blocks map; struct erofs_map_dev mdev; int ret; =20 map.m_la =3D offset; map.m_llen =3D length; - ret =3D erofs_map_blocks(inode, &map); + ret =3D erofs_map_blocks(realinode, &map); if (ret < 0) return ret; =20 @@ -296,7 +298,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_= t offset, loff_t length, return 0; } =20 - if (!(map.m_flags & EROFS_MAP_META) || !erofs_inode_in_metabox(inode)) { + if (!(map.m_flags & EROFS_MAP_META) || !erofs_inode_in_metabox(realinode)= ) { mdev =3D (struct erofs_map_dev) { .m_deviceid =3D map.m_deviceid, .m_pa =3D map.m_pa, @@ -322,7 +324,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_= t offset, loff_t length, void *ptr; =20 ptr =3D erofs_read_metabuf(&buf, sb, map.m_pa, - erofs_inode_in_metabox(inode)); + erofs_inode_in_metabox(realinode)); if (IS_ERR(ptr)) return PTR_ERR(ptr); iomap->inline_data =3D ptr; @@ -383,10 +385,15 @@ static int erofs_read_folio(struct file *file, struct= folio *folio) .ops =3D &iomap_bio_read_ops, .cur_folio =3D folio, }; - struct erofs_iomap_iter_ctx iter_ctx =3D {}; + bool need_iput; + struct erofs_iomap_iter_ctx iter_ctx =3D { + .realinode =3D erofs_real_inode(folio_inode(folio), &need_iput), + }; =20 - trace_erofs_read_folio(folio_inode(folio), folio, true); + trace_erofs_read_folio(iter_ctx.realinode, folio, true); iomap_read_folio(&erofs_iomap_ops, &read_ctx, &iter_ctx); + if (need_iput) + iput(iter_ctx.realinode); return 0; } =20 @@ -396,11 +403,16 @@ static void erofs_readahead(struct readahead_control = *rac) .ops =3D &iomap_bio_read_ops, .rac =3D rac, }; - struct erofs_iomap_iter_ctx iter_ctx =3D {}; + bool need_iput; + struct erofs_iomap_iter_ctx iter_ctx =3D { + .realinode =3D erofs_real_inode(rac->mapping->host, &need_iput), + }; =20 - trace_erofs_readahead(rac->mapping->host, readahead_index(rac), + trace_erofs_readahead(iter_ctx.realinode, readahead_index(rac), readahead_count(rac), true); iomap_readahead(&erofs_iomap_ops, &read_ctx, &iter_ctx); + if (need_iput) + iput(iter_ctx.realinode); } =20 static sector_t erofs_bmap(struct address_space *mapping, sector_t block) @@ -421,7 +433,9 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb,= struct iov_iter *to) return dax_iomap_rw(iocb, to, &erofs_iomap_ops); #endif if ((iocb->ki_flags & IOCB_DIRECT) && inode->i_sb->s_bdev) { - struct erofs_iomap_iter_ctx iter_ctx =3D {}; + struct erofs_iomap_iter_ctx iter_ctx =3D { + .realinode =3D inode, + }; =20 return iomap_dio_rw(iocb, to, &erofs_iomap_ops, NULL, 0, &iter_ctx, 0); diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c index d07dc248d264..c1d0081609dc 100644 --- a/fs/erofs/fileio.c +++ b/fs/erofs/fileio.c @@ -88,9 +88,9 @@ void erofs_fileio_submit_bio(struct bio *bio) bio)); } =20 -static int erofs_fileio_scan_folio(struct erofs_fileio *io, struct folio *= folio) +static int erofs_fileio_scan_folio(struct erofs_fileio *io, + struct inode *inode, struct folio *folio) { - struct inode *inode =3D folio_inode(folio); struct erofs_map_blocks *map =3D &io->map; unsigned int cur =3D 0, end =3D folio_size(folio), len, attached =3D 0; loff_t pos =3D folio_pos(folio), ofs; @@ -158,31 +158,38 @@ static int erofs_fileio_scan_folio(struct erofs_filei= o *io, struct folio *folio) =20 static int erofs_fileio_read_folio(struct file *file, struct folio *folio) { + bool need_iput; + struct inode *realinode =3D erofs_real_inode(folio_inode(folio), &need_ip= ut); struct erofs_fileio io =3D {}; int err; =20 - trace_erofs_read_folio(folio_inode(folio), folio, true); - err =3D erofs_fileio_scan_folio(&io, folio); + trace_erofs_read_folio(realinode, folio, true); + err =3D erofs_fileio_scan_folio(&io, realinode, folio); erofs_fileio_rq_submit(io.rq); + if (need_iput) + iput(realinode); return err; } =20 static void erofs_fileio_readahead(struct readahead_control *rac) { - struct inode *inode =3D rac->mapping->host; + bool need_iput; + struct inode *realinode =3D erofs_real_inode(rac->mapping->host, &need_ip= ut); struct erofs_fileio io =3D {}; struct folio *folio; int err; =20 - trace_erofs_readahead(inode, readahead_index(rac), + trace_erofs_readahead(realinode, readahead_index(rac), readahead_count(rac), true); while ((folio =3D readahead_folio(rac))) { - err =3D erofs_fileio_scan_folio(&io, folio); + err =3D erofs_fileio_scan_folio(&io, realinode, folio); if (err && err !=3D -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); } erofs_fileio_rq_submit(io.rq); + if (need_iput) + iput(realinode); } =20 const struct address_space_operations erofs_fileio_aops =3D { diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 202cbbb4eada..d33816cff813 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -213,7 +213,8 @@ static int erofs_fill_inode(struct inode *inode) switch (inode->i_mode & S_IFMT) { case S_IFREG: inode->i_op =3D &erofs_generic_iops; - inode->i_fop =3D &erofs_file_fops; + inode->i_fop =3D erofs_ishare_fill_inode(inode) ? + &erofs_ishare_fops : &erofs_file_fops; break; case S_IFDIR: inode->i_op =3D &erofs_dir_iops; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 15945e3308b8..d38e63e361c1 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -591,11 +591,17 @@ int __init erofs_init_ishare(void); void erofs_exit_ishare(void); bool erofs_ishare_fill_inode(struct inode *inode); void erofs_ishare_free_inode(struct inode *inode); +struct inode *erofs_real_inode(struct inode *inode, bool *need_iput); #else static inline int erofs_init_ishare(void) { return 0; } static inline void erofs_exit_ishare(void) {} static inline bool erofs_ishare_fill_inode(struct inode *inode) { return f= alse; } static inline void erofs_ishare_free_inode(struct inode *inode) {} +static inline struct inode *erofs_real_inode(struct inode *inode, bool *ne= ed_iput) +{ + *need_iput =3D false; + return inode; +} #endif =20 long erofs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index 6b710c935afb..affa34ac5b2e 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -11,6 +11,12 @@ =20 static struct vfsmount *erofs_ishare_mnt; =20 +static inline bool erofs_is_ishare_inode(struct inode *inode) +{ + /* assumed FS_ONDEMAND is excluded with FS_PAGE_CACHE_SHARE feature */ + return inode->i_sb->s_type =3D=3D &erofs_anon_fs_type; +} + static int erofs_ishare_iget5_eq(struct inode *inode, void *data) { struct erofs_inode_fingerprint *fp1 =3D &EROFS_I(inode)->fingerprint; @@ -38,6 +44,8 @@ bool erofs_ishare_fill_inode(struct inode *inode) struct inode *sharedinode; unsigned long hash; =20 + if (erofs_inode_is_data_compressed(vi->datalayout)) + return false; if (erofs_xattr_fill_inode_fingerprint(&fp, inode, sbi->domain_id)) return false; hash =3D xxh32(fp.opaque, fp.size, 0); @@ -149,6 +157,32 @@ const struct file_operations erofs_ishare_fops =3D { .splice_read =3D filemap_splice_read, }; =20 +struct inode *erofs_real_inode(struct inode *inode, bool *need_iput) +{ + struct erofs_inode *vi, *vi_share; + struct inode *realinode; + + *need_iput =3D false; + if (!erofs_is_ishare_inode(inode)) + return inode; + + vi_share =3D EROFS_I(inode); + spin_lock(&vi_share->ishare_lock); + /* fetch any one as real inode */ + DBG_BUGON(list_empty(&vi_share->ishare_list)); + list_for_each_entry(vi, &vi_share->ishare_list, ishare_list) { + realinode =3D igrab(&vi->vfs_inode); + if (realinode) { + *need_iput =3D true; + break; + } + } + spin_unlock(&vi_share->ishare_lock); + + DBG_BUGON(!realinode); + return realinode; +} + int __init erofs_init_ishare(void) { erofs_ishare_mnt =3D kern_mount(&erofs_anon_fs_type); --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B428535BDDB; Fri, 16 Jan 2026 10:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558127; cv=none; b=aglGXuzKeTW/aFuEzJ/P8Xh+Kbq77A6zems6IrcBNW92ERFczGZcvQEgHdiL/c0irnt/2vUya2iXmLoPT6qdcl7OzrfrJqlxPBFVEN3Fc19mfIYBahr+TA1vDjsFsULVd/hRuASjFC4u1bF5c/GpuniHg3dii/XCjrumCqUhI54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558127; c=relaxed/simple; bh=7bccBY+8R842a2lzvpO/VaUeCUOZ6hEejCOfP8ihjdo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GnxZLZnY3W/V9Gk5acLdeq2BaghFonIeGyolsoTRmNXiyxsOPIK/ZDh//bAWtbzhH4RmKbmObMDA4fnkOch3EkUqhWfSXNhFulM7W+dmXTOnbWPUCwzkKRtjPUxaFpSHbRESZ1EKHV3nyq5dOYt2GzvHkrAk4OLmYeXGA+tydGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=luzM9vjp; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="luzM9vjp" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=++qjl2jTgctpUWtnLLkUztenmX2mH2N2bI/tdJjFPnM=; b=luzM9vjpbiQ2l82xOg1MHxs97Y9kKRBlMtvngEUxODyzhxnZy8nqGRYZtwe+ijPSQQrreem9q 2yp5mufGUNFzrlbVAlsUieBJpVFd2uYK7JoNzekqgJIlWap+koRXVUSXtpfdm/Pf42d3YZpB7bq s3Dk/8dcnS6UNKz8pLgNFOQ= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4dswTh2ZNVz12Lrj; Fri, 16 Jan 2026 18:05:44 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 669F6405A2; Fri, 16 Jan 2026 18:08:43 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:42 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 8/9] erofs: support compressed inodes for page cache share Date: Fri, 16 Jan 2026 09:55:49 +0000 Message-ID: <20260116095550.627082-9-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" From: Hongzhen Luo This patch adds page cache sharing functionality for compressed inodes. Signed-off-by: Hongzhen Luo Signed-off-by: Hongbo Li Reviewed-by: Gao Xiang --- fs/erofs/ishare.c | 2 -- fs/erofs/zdata.c | 38 ++++++++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index affa34ac5b2e..96679286da95 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -44,8 +44,6 @@ bool erofs_ishare_fill_inode(struct inode *inode) struct inode *sharedinode; unsigned long hash; =20 - if (erofs_inode_is_data_compressed(vi->datalayout)) - return false; if (erofs_xattr_fill_inode_fingerprint(&fp, inode, sbi->domain_id)) return false; hash =3D xxh32(fp.opaque, fp.size, 0); diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 93ab6a481b64..59ee9a36d9eb 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -493,7 +493,7 @@ enum z_erofs_pclustermode { }; =20 struct z_erofs_frontend { - struct inode *const inode; + struct inode *inode, *sharedinode; struct erofs_map_blocks map; struct z_erofs_bvec_iter biter; =20 @@ -508,8 +508,8 @@ struct z_erofs_frontend { unsigned int icur; }; =20 -#define Z_EROFS_DEFINE_FRONTEND(fe, i, ho) struct z_erofs_frontend fe =3D = { \ - .inode =3D i, .head =3D Z_EROFS_PCLUSTER_TAIL, \ +#define Z_EROFS_DEFINE_FRONTEND(fe, i, si, ho) struct z_erofs_frontend fe = =3D { \ + .inode =3D i, .sharedinode =3D si, .head =3D Z_EROFS_PCLUSTER_TAIL, \ .mode =3D Z_EROFS_PCLUSTER_FOLLOWED, .headoffset =3D ho } =20 static bool z_erofs_should_alloc_cache(struct z_erofs_frontend *fe) @@ -1866,7 +1866,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_= frontend *f, pgoff_t index =3D cur >> PAGE_SHIFT; struct folio *folio; =20 - folio =3D erofs_grab_folio_nowait(inode->i_mapping, index); + folio =3D erofs_grab_folio_nowait(f->sharedinode->i_mapping, index); if (!IS_ERR_OR_NULL(folio)) { if (folio_test_uptodate(folio)) folio_unlock(folio); @@ -1883,11 +1883,13 @@ static void z_erofs_pcluster_readmore(struct z_erof= s_frontend *f, =20 static int z_erofs_read_folio(struct file *file, struct folio *folio) { - struct inode *const inode =3D folio->mapping->host; - Z_EROFS_DEFINE_FRONTEND(f, inode, folio_pos(folio)); + struct inode *sharedinode =3D folio->mapping->host; + bool need_iput; + struct inode *realinode =3D erofs_real_inode(sharedinode, &need_iput); + Z_EROFS_DEFINE_FRONTEND(f, realinode, sharedinode, folio_pos(folio)); int err; =20 - trace_erofs_read_folio(inode, folio, false); + trace_erofs_read_folio(realinode, folio, false); z_erofs_pcluster_readmore(&f, NULL, true); err =3D z_erofs_scan_folio(&f, folio, false); z_erofs_pcluster_readmore(&f, NULL, false); @@ -1896,23 +1898,28 @@ static int z_erofs_read_folio(struct file *file, st= ruct folio *folio) /* if some pclusters are ready, need submit them anyway */ err =3D z_erofs_runqueue(&f, 0) ?: err; if (err && err !=3D -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); =20 erofs_put_metabuf(&f.map.buf); erofs_release_pages(&f.pagepool); + + if (need_iput) + iput(realinode); return err; } =20 static void z_erofs_readahead(struct readahead_control *rac) { - struct inode *const inode =3D rac->mapping->host; - Z_EROFS_DEFINE_FRONTEND(f, inode, readahead_pos(rac)); + struct inode *sharedinode =3D rac->mapping->host; + bool need_iput; + struct inode *realinode =3D erofs_real_inode(sharedinode, &need_iput); + Z_EROFS_DEFINE_FRONTEND(f, realinode, sharedinode, readahead_pos(rac)); unsigned int nrpages =3D readahead_count(rac); struct folio *head =3D NULL, *folio; int err; =20 - trace_erofs_readahead(inode, readahead_index(rac), nrpages, false); + trace_erofs_readahead(realinode, readahead_index(rac), nrpages, false); z_erofs_pcluster_readmore(&f, rac, true); while ((folio =3D readahead_folio(rac))) { folio->private =3D head; @@ -1926,8 +1933,8 @@ static void z_erofs_readahead(struct readahead_contro= l *rac) =20 err =3D z_erofs_scan_folio(&f, folio, true); if (err && err !=3D -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); @@ -1935,6 +1942,9 @@ static void z_erofs_readahead(struct readahead_contro= l *rac) (void)z_erofs_runqueue(&f, nrpages); erofs_put_metabuf(&f.map.buf); erofs_release_pages(&f.pagepool); + + if (need_iput) + iput(realinode); } =20 const struct address_space_operations z_erofs_aops =3D { --=20 2.22.0 From nobody Sun Feb 8 14:22:35 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 394FE35FF52; Fri, 16 Jan 2026 10:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558143; cv=none; b=VHb0K6jDUAe+xLEPZs4/0j9yOoWXbC5wQC0ltq5gDkyoFo4L/pkqyzRNfZHXRS5+Mmidx4BeuoihVE4JwldTakQAEayiIIbPJI5Hqni/1x6qeSw2C9rD3Mx7Hn16RaL0cTGV/nArqstWTuF7aTtyRt2oJJy4qLTnHTcXGvoRS2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768558143; c=relaxed/simple; bh=pXnDClVRTnHHgum20VgnGGA8xY6ykQ05HoqhepeDEv4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c0VCyK42kLAmU67C1Gf0LPe8x4URBOaSboIddszRBdJqyd5WSjskzjlM7xPY65Ehth+rXNMtVEEToDDAAjn7wj2rDX9skxGmR4o9sT0Xn+PtL6k1oib0Wa6v0BAF6+NrUXmvbDDzG/DdjLCMg2N/ZNbWzkmV2Xk4OFQRttnkFoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=ET4nQgDE; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="ET4nQgDE" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=XzmAs2VpZLSxoIrsGbEfPR013qwffyPmOWZWIOJmd7w=; b=ET4nQgDEN5fYb3hoQ8vIAzZBtp6wiXUMv1NRArCFLuT2+7LbB0ZtiaUJbe4KeP8OBrpaOTNYo IOgLN5fMC0HizzauOwIRsnpx/LjDgNUINCiH08vX29OH1T+GnUoIzDWysuevgBd0crGEm8GAn+k KCC9YTjfCMoJWlJMien4q0A= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4dswTF1c2Cz1prKt; Fri, 16 Jan 2026 18:05:21 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id EEEB240538; Fri, 16 Jan 2026 18:08:43 +0800 (CST) Received: from huawei.com (10.67.174.162) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 16 Jan 2026 18:08:43 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v15 9/9] erofs: implement .fadvise for page cache share Date: Fri, 16 Jan 2026 09:55:50 +0000 Message-ID: <20260116095550.627082-10-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260116095550.627082-1-lihongbo22@huawei.com> References: <20260116095550.627082-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" From: Hongzhen Luo This patch implements the .fadvise interface for page cache share. Similar to overlayfs, it drops those clean, unused pages through vfs_fadvise(). Signed-off-by: Hongzhen Luo Signed-off-by: Hongbo Li Reviewed-by: Gao Xiang --- fs/erofs/ishare.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index 96679286da95..78242f9d8dde 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -145,6 +145,13 @@ static int erofs_ishare_mmap(struct file *file, struct= vm_area_struct *vma) return generic_file_readonly_mmap(file, vma); } =20 +static int erofs_ishare_fadvise(struct file *file, loff_t offset, + loff_t len, int advice) +{ + return vfs_fadvise((struct file *)file->private_data, + offset, len, advice); +} + const struct file_operations erofs_ishare_fops =3D { .open =3D erofs_ishare_file_open, .llseek =3D generic_file_llseek, @@ -153,6 +160,7 @@ const struct file_operations erofs_ishare_fops =3D { .release =3D erofs_ishare_file_release, .get_unmapped_area =3D thp_get_unmapped_area, .splice_read =3D filemap_splice_read, + .fadvise =3D erofs_ishare_fadvise, }; =20 struct inode *erofs_real_inode(struct inode *inode, bool *need_iput) --=20 2.22.0