From nobody Mon Feb 9 04:14:13 2026 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 1BD5B1E3769 for ; Sat, 1 Mar 2025 14:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740840628; cv=none; b=S1QGCDoLVprwECdLiZI7svjhysu7nvjssR8ZiOwT7HTm05c5xU5EaH+Yw81kQ0l935Qs91rKpUOQKj0QvEB07kFc0FvSp5KGw+crW685Mm/4l3b6RGvWCN7M/be1Pf8oeVkfZzqXBHUC+/ucm3GnIEeDTxGTy+NbKTtA58aP3JY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740840628; c=relaxed/simple; bh=TXe/AJi4P0405t0Nn8ub1Nz6aLbMsSePOpe5bgKwALs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F4hsZxitiPyIuJbawB8XeGFpSXle/Du4K6Ku62J455XdQs6O358sMkHY5vE+b2QSY+eUw/IQQnTDHup3Yfyf6FGdDn8vQvz/fOqdsv96oJj8d87Mc37vs1wLG64DCg+h4LZwie4Sm81dm/EvVhcWdMsQLEQuel9doZgoOxrPBKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=B5F3CPmV; arc=none smtp.client-ip=115.124.30.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="B5F3CPmV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1740840618; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=LsN4AVILIAF5l64ooZXWfDVtzbln1b/ogW51HXy4MRg=; b=B5F3CPmVrptC4nafYB2La266UwPWmytf4kxNsaAjWBilVE27yjdkNVnfio9nxU+FzaP8WO+ibfoCofF3eNaLecfhN1Sei7ysc74u1rbmQLtxn9Tj4I4Y/A/GZ3OSmRlqC4P3leG5cLJPdHKHugbp4AB41YoXKmsKmH7QsCuvKj8= Received: from localhost(mailfrom:hongzhen@linux.alibaba.com fp:SMTPD_---0WQSfpYr_1740840617 cluster:ay36) by smtp.aliyun-inc.com; Sat, 01 Mar 2025 22:50:17 +0800 From: Hongzhen Luo To: linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Hongzhen Luo Subject: [RFC PATCH v6 6/7] erofs: support compressed inodes for page cache share Date: Sat, 1 Mar 2025 22:49:43 +0800 Message-ID: <20250301145002.2420830-7-hongzhen@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250301145002.2420830-1-hongzhen@linux.alibaba.com> References: <20250301145002.2420830-1-hongzhen@linux.alibaba.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 Content-Type: text/plain; charset="utf-8" This patch adds page cache sharing functionality for compressed inodes. Signed-off-by: Hongzhen Luo --- fs/erofs/zdata.c | 57 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index aff09f94afb2..b6383cb26acb 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 @@ -474,7 +475,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 @@ -1835,11 +1836,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; z_erofs_pcluster_readmore(&f, NULL, true); err =3D z_erofs_scan_folio(&f, folio, false); z_erofs_pcluster_readmore(&f, NULL, false); @@ -1848,25 +1862,43 @@ 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)); struct folio *head =3D NULL, *folio; unsigned int nrpages =3D readahead_count(rac); + struct erofs_read_ctx rdctx =3D { + .file =3D rac->file, + .inode =3D inode, + }; int err; =20 + erofs_read_begin(&rdctx); + + if (erofs_is_ishare_inode(inode)) + realinode =3D erofs_ishare_iget(inode); + else + realinode =3D inode; + + f.inode =3D realinode; z_erofs_pcluster_readmore(&f, rac, true); nrpages =3D readahead_count(rac); - trace_erofs_readpages(inode, readahead_index(rac), nrpages, false); + trace_erofs_readpages(realinode, readahead_index(rac), nrpages, false); while ((folio =3D readahead_folio(rac))) { folio->private =3D head; head =3D folio; @@ -1879,8 +1911,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); @@ -1888,6 +1920,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.43.5