From nobody Thu Apr 2 20:21:22 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 3BB8A287258 for ; Fri, 13 Feb 2026 07:47:21 +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=1770968845; cv=none; b=SZqHXHJ5DfWaUUETtiUK0d4nm2MoHf4AQUmgtHRgJMTecgdNQD0H/zrwoFJ7hMxOp0YURdhcG7NjEeuTh991s1vqQEL+giElB+qognrbJhAPICkbZKAkS5OYvWC/qFzONH101DLx0zqAL+Of5mQzw4TJzLTBd91Y2E2UDKcEL3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770968845; c=relaxed/simple; bh=DIZcNrAJDyqtnOM5PgKNoOdg38Jp5AvGKs9AqntNKzs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ic4N7Rk7/PHCUUcH4TLDt3doElHNhWUnAwRYL2JgWzngZBWee10Mx0aCgD4SN/almPtHGjr6mL4KP82aWvOpvXrXoMtZeqzh5xE5cxnK7NdTDfns1Oaxzuv0fjE6cWSfWaOdCDRRwc41MN4bo664rJgPoWIiilujJE89JLqzBYk= 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=dfSVEQwZ; 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="dfSVEQwZ" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=3XNdty5a43OTAqhwjQ0kXNuw1GyPUDUGoKJlC3miOrY=; b=dfSVEQwZa7ra/7xwGhKB78g0MENPkd/KEg7mjq92Fku/DR6C74UQm8Dd5aQzx7WfbXiUhM7mB 12VOcS4OhDk73PB04SlsGDDTVhOmj2UBQL30fO7lkU9v65/kHLzvtVg7Cg+PsqXqnSwtHgL8fvX gnANS/0Dph64dukM1lpk4x4= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4fC3zd4Tq1z1prMF; Fri, 13 Feb 2026 15:42:37 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 97C964036C; Fri, 13 Feb 2026 15:47:19 +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, 13 Feb 2026 15:47:19 +0800 From: Hongbo Li To: , CC: , , , Subject: [PATCH] erofs: allow sharing page cache with the same aops only Date: Fri, 13 Feb 2026 07:33:45 +0000 Message-ID: <20260213073345.768320-1-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 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: kwepems100001.china.huawei.com (7.221.188.238) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" Inode with identical data but different @aops cannot be mixed because the page cache is managed by different subsystems (e.g., @aops for compressed on-disk inodes cannot handle plain on-disk inodes). In this patch, we never allow inodes to share the page cache among plain, compressed, and fileio cases. When a shared inode is created, we initialize @aops that is the same as the initial real inode, and subsequent inodes cannot share the page cache if the inferred @aops differ from the corresponding shared inode. This is reasonable as a first step because, in typical use cases, if an inode is compressible, it will fall into compressed inodes across different filesystem images unless users use plain filesystems. However, in that cases, users will use plain filesystems all the time. Fixes: 5ef3208e3be5 ("erofs: introduce the page cache share feature") Signed-off-by: Hongbo Li --- fs/erofs/inode.c | 3 ++- fs/erofs/internal.h | 20 +++++++++----------- fs/erofs/ishare.c | 14 +++++++++----- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 4f86169c23f1..5b05272fd9c4 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -254,7 +254,8 @@ static int erofs_fill_inode(struct inode *inode) } =20 mapping_set_large_folios(inode->i_mapping); - return erofs_inode_set_aops(inode, inode, false); + inode->i_mapping->a_ops =3D erofs_get_aops(inode, false); + return IS_ERR(inode->i_mapping->a_ops) ? PTR_ERR(inode->i_mapping->a_ops)= : 0; } =20 /* diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index d1634455e389..764e81b3bc08 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -471,26 +471,24 @@ static inline void *erofs_vm_map_ram(struct page **pa= ges, unsigned int count) return NULL; } =20 -static inline int erofs_inode_set_aops(struct inode *inode, - struct inode *realinode, bool no_fscache) +static inline const struct address_space_operations * +erofs_get_aops(struct inode *realinode, bool no_fscache) { if (erofs_inode_is_data_compressed(EROFS_I(realinode)->datalayout)) { if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP)) - return -EOPNOTSUPP; + return ERR_PTR(-EOPNOTSUPP); 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; - return 0; + return &z_erofs_aops; } - inode->i_mapping->a_ops =3D &erofs_aops; - if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && !no_fscache && - erofs_is_fscache_mode(realinode->i_sb)) - inode->i_mapping->a_ops =3D &erofs_fscache_access_aops; if (IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && erofs_is_fileio_mode(EROFS_SB(realinode->i_sb))) - inode->i_mapping->a_ops =3D &erofs_fileio_aops; - return 0; + return &erofs_fileio_aops; + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && !no_fscache && + erofs_is_fscache_mode(realinode->i_sb)) + return &erofs_fscache_access_aops; + return &erofs_aops; } =20 int erofs_register_sysfs(struct super_block *sb); diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c index ce980320a8b9..829d50d5c717 100644 --- a/fs/erofs/ishare.c +++ b/fs/erofs/ishare.c @@ -40,10 +40,14 @@ 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); + const struct address_space_operations *aops; struct erofs_inode_fingerprint fp; struct inode *sharedinode; unsigned long hash; =20 + aops =3D erofs_get_aops(inode, true); + if (IS_ERR(aops)) + return false; if (erofs_xattr_fill_inode_fingerprint(&fp, inode, sbi->domain_id)) return false; hash =3D xxh32(fp.opaque, fp.size, 0); @@ -56,15 +60,15 @@ bool erofs_ishare_fill_inode(struct inode *inode) } =20 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_mapping->a_ops =3D aops; sharedinode->i_size =3D vi->vfs_inode.i_size; unlock_new_inode(sharedinode); } else { kfree(fp.opaque); + if (aops !=3D sharedinode->i_mapping->a_ops) { + iput(sharedinode); + return false; + } if (sharedinode->i_size !=3D vi->vfs_inode.i_size) { _erofs_printk(inode->i_sb, KERN_WARNING "size(%lld:%lld) not matches for the same fingerprint\n", --=20 2.22.0