From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7F4DD1519AC for ; Fri, 13 Feb 2026 23:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771025240; cv=none; b=lGyvYzGQznODZr8vS8YNqwtzeWuNAuN/738skH02mZaZA0woabxOD+kqS8uYKbsFEvY6Cujvm6YfPGiPRepoT+EpConzoZqlIBq1AS4Rks8V9BTU3MA0d7B/MFA7EYy0lEauUKxuB7EAyNx3WHHROLhZayF31K2+vNQuGotx34w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771025240; c=relaxed/simple; bh=rrPE5oyNED8nIqHeHO8t/nEmXPjdnhH+v75FkQE2/iQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cAZP8ktovP01lzlgHLIPbfOliNslftCbvEpWIEfRrAaPk5sD/M5tYkyd326tEL2eO+DVNKDlhPdEJ6fzmgAdmKGbHoUcCqvIRl/Q+Dk9oRp2ohu5meezOvMT6C3S3dTz6Rp+jVI1c/mhWZunZqZPFkU706+96xxsfkIQGrFhdUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f/U5ekwU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f/U5ekwU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D44C1C116C6; Fri, 13 Feb 2026 23:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771025240; bh=rrPE5oyNED8nIqHeHO8t/nEmXPjdnhH+v75FkQE2/iQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f/U5ekwUAOnDgdrMdE54JHUEr43zXgMGpnnmbyHlTp9I7hi47gkR7+hujfpjXcHYL 0SMFiyoQ41vRNwTxj+5piqdjpUdHb6TuGSn3CoCNVjIknFvaeflsLzGFDEvKII2Byh imHAXU0pEnG4C21bjQ9vBa8cfZwr1SAt1ywUs39Rv7YpJhDIC7yM+GSaYgVzQPZI1J JCTsBgSX6sWH/ACrHYFomVJ7xNdETtkm+DMKD57Tdcie6hsn70py1P28OdW68enPpz YBRgVHydtufJLyB1s9mo5DYIxPxbdZYOob+96MYJbBLqPt3zN+2O99CWP1nWmVzL8i SxDD/nmqs7BpA== Date: Sat, 14 Feb 2026 07:27:15 +0800 From: Gao Xiang To: Hongbo Li Cc: hsiangkao@linux.alibaba.com, chao@kernel.org, xiang@kernel.org, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] erofs: allow sharing page cache with the same aops only Message-ID: Mail-Followup-To: Hongbo Li , hsiangkao@linux.alibaba.com, chao@kernel.org, xiang@kernel.org, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20260213073345.768320-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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260213073345.768320-1-lihongbo22@huawei.com> Hi Hongbo, On Fri, Feb 13, 2026 at 07:33:45AM +0000, Hongbo Li wrote: > 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) > } > > mapping_set_large_folios(inode->i_mapping); > - return erofs_inode_set_aops(inode, inode, false); > + inode->i_mapping->a_ops = erofs_get_aops(inode, false); > + return IS_ERR(inode->i_mapping->a_ops) ? PTR_ERR(inode->i_mapping->a_ops) : 0; I hope there is an aops variable instead of assigning inode->i_mapping->a_ops directly. > } > > /* > 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 **pages, unsigned int count) > return NULL; > } > > -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 != PAGE_SHIFT, > erofs_info, realinode->i_sb, > "EXPERIMENTAL EROFS subpage compressed block support in use. Use at your own risk!"); > - inode->i_mapping->a_ops = &z_erofs_aops; > - return 0; > + return &z_erofs_aops; > } > - inode->i_mapping->a_ops = &erofs_aops; > - if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && !no_fscache && > - erofs_is_fscache_mode(realinode->i_sb)) > - inode->i_mapping->a_ops = &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 = &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; Can you rearrange it as if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && !no_fscache && erofs_is_fscache_mode(realinode->i_sb)) return &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 = &erofs_fileio_aops; return &erofs_aops; ? Thanks, Gao Xiang