From nobody Tue Feb 10 00:57:53 2026 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 1504F338F5B; Thu, 22 Jan 2026 13:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769089826; cv=none; b=PtLkwSYh1hgr0aaCLwno8qgykQmkrBzOX0Jj/H6YXWR5kTbJM0u+a6FMoVyYXBJ6w3Zs6DNTw+6Q1TF4N4i966+LnzxNkUJRBWyW3HsY1knoRh4VgdnpdlmTiU0qAWUupjHPQn6PhgXmDtjdu75sz30/INdRaOIv+LzZaSQmcM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769089826; c=relaxed/simple; bh=+SUjc358ft0Qx2/9xo/Em/VA/96fSeWHqg/BOtUlNh0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BLPKS8PpgEB5KVuaXHG7OjxVbpBkMH3FGMYkrTBBUx6bdtIxihcfiadIzYuTXqpiFCytqzVCwHe0g6OcHr6xw7YeENmi1zO/znGyHRz1FdyTxFmMJS+K+c68hnOKvfj3ehciuHXA+c8RxoI0VOiLhNHeD/IxpiTFzoVqxhXpxy0= 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=nGyTQUOZ; arc=none smtp.client-ip=113.46.200.216 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="nGyTQUOZ" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=xAa8T4/dhzGgisIp59i8kaQOP1U0tmXz+haC7atdmWY=; b=nGyTQUOZkihDPX/H39dxjz4qbnBOfZ+xZmMLdT4k5TyZC+nI69xCtxLut8rmURbCyeAAYq2Eg FClX5fuv4+9GKtTe4A9FLJ9m/m2SiDuvusXcvu9d675c55J9CeSIEdehWmlWtUZeMFEks7Ov9YU oXb9AAZh1fr1trqqWG7OBzA= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4dxj5K70sWz1T4Gp; Thu, 22 Jan 2026 21:46:13 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 50F612016A; Thu, 22 Jan 2026 21:50:18 +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; Thu, 22 Jan 2026 21:50:17 +0800 From: Hongbo Li To: , , CC: , , , , , , Subject: [PATCH v16 04/10] erofs: add erofs_inode_set_aops helper to set the aops. Date: Thu, 22 Jan 2026 13:37:12 +0000 Message-ID: <20260122133718.658056-5-lihongbo22@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20260122133718.658056-1-lihongbo22@huawei.com> References: <20260122133718.658056-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: kwepems200002.china.huawei.com (7.221.188.68) To kwepemr500015.china.huawei.com (7.202.195.162) Content-Type: text/plain; charset="utf-8" Add erofs_inode_set_aops helper to set the inode->i_mapping->a_ops, and using IS_ENABLED to make it cleaner. Signed-off-by: Hongbo Li --- fs/erofs/inode.c | 23 +---------------------- fs/erofs/internal.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index bce98c845a18..389632bb46c4 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -235,28 +235,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..8e28c2fa8735 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -455,6 +455,29 @@ 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)) { + if (!IS_ENABLED(CONFIG_EROFS_FS_ZIP)) + return -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; + } + inode->i_mapping->a_ops =3D &erofs_aops; + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND)) { + if (!no_fscache && erofs_is_fscache_mode(realinode->i_sb)) + inode->i_mapping->a_ops =3D &erofs_fscache_access_aops; + } else { + if (erofs_is_fileio_mode(EROFS_SB(realinode->i_sb))) + inode->i_mapping->a_ops =3D &erofs_fileio_aops; + } + return 0; +} + int erofs_register_sysfs(struct super_block *sb); void erofs_unregister_sysfs(struct super_block *sb); int __init erofs_init_sysfs(void); --=20 2.22.0