From nobody Tue Feb 10 03:37:35 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 EA5D32EDD75 for ; Tue, 21 Oct 2025 10:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761044379; cv=none; b=j8hdhAFx5pZBwxQ0zOvqsbuZOO5tl234R2TXhnB5qRk29nr8MWtqnTgEPEoPF1kgobqSVjO+cNxYlhBY5Us3yU5jDsTTxqZ6CzsVQbDZvSB0xFNUQm3el48HzKas6c6fHuQcBXU2lz5zKw/yj6O/8ola4vvsgKrZFugjdJpYL9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761044379; c=relaxed/simple; bh=xXFZfZ4nNiHBb/W39Fr5wgWasrpseyiO8U4O8631IYQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KDYWyuBKgmpMEWAit5pbDfFMak+osG+aRe6+eqRgbCjSDrqsi+a8dgZwqzKqqQT1BVSMp7hrx1szD5pPxtgaYjdpsqPBDTqHiVmDjvptDLyERDiAiWN0rt9KETROLsCgDHTXB79gO5+GB0hr/rjk7Qxgx56tUlC2H4NYY81oSBY= 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=BArDbB0+; arc=none smtp.client-ip=113.46.200.217 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="BArDbB0+" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=R4gUs6vcWZbCSV9LDMDP4DWnJrknFMDZIKHxe0URueo=; b=BArDbB0+hRPRn0B6O7TN88wkUMspQEkzSzPdTl4i7nSpGbgtuMx4OVRI99e3WAafOdehNWKwr sno+fDYuQ+28C0inJTMPgQmZiL0sBUSQ8WwiXl/2gqvjhkfP8LGIKgp2RHPToloytwverYLkiuY jXZ9by+DPiu+i86jKnuSHbo= Received: from mail.maildlp.com (unknown [172.19.88.194]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4crTmd4r3Czcb1P; Tue, 21 Oct 2025 18:58:25 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 147DC140123; Tue, 21 Oct 2025 18:59:35 +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; Tue, 21 Oct 2025 18:59:34 +0800 From: Hongbo Li To: , , , CC: , , Subject: [PATCH RFC v7 6/7] erofs: support compressed inodes for page cache share Date: Tue, 21 Oct 2025 10:48:14 +0000 Message-ID: <20251021104815.70662-7-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20251021104815.70662-1-lihongbo22@huawei.com> References: <20251021104815.70662-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: kwepems100001.china.huawei.com (7.221.188.238) 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 [hongbo: forward port] Signed-off-by: Hongbo Li --- fs/erofs/zdata.c | 56 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index bc80cfe482f7..e76421de86cb 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -5,6 +5,7 @@ * Copyright (C) 2022 Alibaba Cloud */ #include "compress.h" +#include "ishare.h" #include #include #include @@ -493,7 +494,7 @@ enum z_erofs_pclustermode { }; =20 struct z_erofs_frontend { - struct inode *const inode; + struct inode *inode; struct erofs_map_blocks map; struct z_erofs_bvec_iter biter; =20 @@ -1870,10 +1871,24 @@ 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 *const inode =3D folio->mapping->host, *realinode; + Z_EROFS_DEFINE_FRONTEND(f, NULL, folio_pos(folio)); + struct erofs_read_ctx rdctx =3D { + .file =3D file, + .inode =3D inode, + }; int err; =20 + trace_erofs_read_folio(folio, false); + + erofs_read_begin(&rdctx); + + if (erofs_is_ishare_inode(inode)) + realinode =3D erofs_ishare_iget(inode); + else + realinode =3D inode; + + f.inode =3D realinode; trace_erofs_read_folio(folio, false); z_erofs_pcluster_readmore(&f, NULL, true); err =3D z_erofs_scan_folio(&f, folio, false); @@ -1883,23 +1898,39 @@ 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 (erofs_is_ishare_inode(inode)) + erofs_ishare_iput(realinode); + + erofs_read_end(&rdctx); 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 *const inode =3D rac->mapping->host, *realinode; + Z_EROFS_DEFINE_FRONTEND(f, NULL, readahead_pos(rac)); unsigned int nrpages =3D readahead_count(rac); struct folio *head =3D NULL, *folio; + struct erofs_read_ctx rdctx =3D { + .file =3D rac->file, + .inode =3D inode, + }; int err; =20 - trace_erofs_readahead(inode, readahead_index(rac), nrpages, false); + erofs_read_begin(&rdctx); + if (erofs_is_ishare_inode(inode)) + realinode =3D erofs_ishare_iget(inode); + else + realinode =3D inode; + + f.inode =3D realinode; + 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; @@ -1913,8 +1944,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); @@ -1922,6 +1953,11 @@ static void z_erofs_readahead(struct readahead_contr= ol *rac) (void)z_erofs_runqueue(&f, nrpages); erofs_put_metabuf(&f.map.buf); erofs_release_pages(&f.pagepool); + + if (erofs_is_ishare_inode(inode)) + erofs_ishare_iput(realinode); + + erofs_read_end(&rdctx); } =20 const struct address_space_operations z_erofs_aops =3D { --=20 2.22.0