From nobody Mon Feb 9 19:26:13 2026 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (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 0F35A2253FD for ; Mon, 10 Mar 2025 09:55:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741600521; cv=none; b=jMVHzptdOcOqsBUql1y9UwFy7sSiuPUHlqcIk6iryf8xzG8s6WylXxD4qYzde8I1Nqr1f9KlLg9rs48yP8sTq/0B+6JVHayoxF46TgZOLYELDqKHfvaeDrZS49uaxu1oaMUg8khzgRx/OrOolq1OjAU3c+piFCEqKPO1uy7adwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741600521; c=relaxed/simple; bh=/BWPX7Uz85GMrx3mCFBiA2EA62gbqPSIIPgArZwjZT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DW7GK4lmCc0e7BEFnft2BwN4u1q6TScdgO//KEVDHwlCmZUrynYAvvBniXaWMHjReQeq7wzbPeNbnM/lmggxR04oB0RUAR4zaKfWRM1hzaFqUi7GbMGCZPVusxdbTvqzoQftbmJG8EgYTl+KC4YQo2i1oWisk93eylpkRZX2I4o= 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=qyPTt7sk; arc=none smtp.client-ip=115.124.30.132 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="qyPTt7sk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1741600510; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=v3+UibsorVtK/yynVTxuLEiXsORirVMrgQEdb1NF2q4=; b=qyPTt7skhm0Mr7eyCyj9PYsO/uB192xbAauibE70MviexXDAcHpyHc7xB9bv8GYDA8rh2QHKoyMm8+0+zHi4p8jFJiJY0jQfhXg8A7yTM0K5C45RYKxVgCFVhcPTN0AGVtPGKixol0An19Zi6YuBJ0k+B7mLufOCMrve6hZ9lPE= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WR1F3zq_1741600509 cluster:ay36) by smtp.aliyun-inc.com; Mon, 10 Mar 2025 17:55:10 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 06/10] erofs: initialize decompression early Date: Mon, 10 Mar 2025 17:54:56 +0800 Message-ID: <20250310095459.2620647-7-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250310095459.2620647-1-hsiangkao@linux.alibaba.com> References: <20250310095459.2620647-1-hsiangkao@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" - Rename erofs_init_managed_cache() to z_erofs_init_super(); - Move the initialization of managed_pslots into z_erofs_init_super() too; - Move z_erofs_init_super() and packed inode preparation upwards, before the root inode initialization. Therefore, the root directory can also be compressible. Signed-off-by: Gao Xiang --- fs/erofs/internal.h | 4 ++-- fs/erofs/super.c | 26 ++++++++++---------------- fs/erofs/zdata.c | 4 ++-- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 91d0b400459c..b35742cf9431 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -436,6 +436,7 @@ int __init erofs_init_shrinker(void); void erofs_exit_shrinker(void); int __init z_erofs_init_subsystem(void); void z_erofs_exit_subsystem(void); +int z_erofs_init_super(struct super_block *sb); unsigned long z_erofs_shrink_scan(struct erofs_sb_info *sbi, unsigned long nr_shrink); int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *= map, @@ -445,7 +446,6 @@ void z_erofs_put_gbuf(void *ptr); int z_erofs_gbuf_growsize(unsigned int nrpages); int __init z_erofs_gbuf_init(void); void z_erofs_gbuf_exit(void); -int erofs_init_managed_cache(struct super_block *sb); int z_erofs_parse_cfgs(struct super_block *sb, struct erofs_super_block *d= sb); #else static inline void erofs_shrinker_register(struct super_block *sb) {} @@ -454,7 +454,7 @@ static inline int erofs_init_shrinker(void) { return 0;= } static inline void erofs_exit_shrinker(void) {} static inline int z_erofs_init_subsystem(void) { return 0; } static inline void z_erofs_exit_subsystem(void) {} -static inline int erofs_init_managed_cache(struct super_block *sb) { retur= n 0; } +static inline int z_erofs_init_super(struct super_block *sb) { return 0; } #endif /* !CONFIG_EROFS_FS_ZIP */ =20 #ifdef CONFIG_EROFS_FS_BACKED_BY_FILE diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 18445dc8597d..0156ee7217c9 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -636,9 +636,16 @@ static int erofs_fc_fill_super(struct super_block *sb,= struct fs_context *fc) else sb->s_flags &=3D ~SB_POSIXACL; =20 -#ifdef CONFIG_EROFS_FS_ZIP - xa_init(&sbi->managed_pslots); -#endif + err =3D z_erofs_init_super(sb); + if (err) + return err; + + if (erofs_sb_has_fragments(sbi) && sbi->packed_nid) { + inode =3D erofs_iget(sb, sbi->packed_nid); + if (IS_ERR(inode)) + return PTR_ERR(inode); + sbi->packed_inode =3D inode; + } =20 inode =3D erofs_iget(sb, sbi->root_nid); if (IS_ERR(inode)) @@ -650,24 +657,11 @@ static int erofs_fc_fill_super(struct super_block *sb= , struct fs_context *fc) iput(inode); return -EINVAL; } - sb->s_root =3D d_make_root(inode); if (!sb->s_root) return -ENOMEM; =20 erofs_shrinker_register(sb); - if (erofs_sb_has_fragments(sbi) && sbi->packed_nid) { - sbi->packed_inode =3D erofs_iget(sb, sbi->packed_nid); - if (IS_ERR(sbi->packed_inode)) { - err =3D PTR_ERR(sbi->packed_inode); - sbi->packed_inode =3D NULL; - return err; - } - } - err =3D erofs_init_managed_cache(sb); - if (err) - return err; - err =3D erofs_xattr_prefixes_init(sb); if (err) return err; diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 5e4b65070b86..bc6d6842c5c2 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -644,18 +644,18 @@ static const struct address_space_operations z_erofs_= cache_aops =3D { .invalidate_folio =3D z_erofs_cache_invalidate_folio, }; =20 -int erofs_init_managed_cache(struct super_block *sb) +int z_erofs_init_super(struct super_block *sb) { struct inode *const inode =3D new_inode(sb); =20 if (!inode) return -ENOMEM; - set_nlink(inode, 1); inode->i_size =3D OFFSET_MAX; inode->i_mapping->a_ops =3D &z_erofs_cache_aops; mapping_set_gfp_mask(inode->i_mapping, GFP_KERNEL); EROFS_SB(sb)->managed_cache =3D inode; + xa_init(&EROFS_SB(sb)->managed_pslots); return 0; } =20 --=20 2.43.5