From nobody Wed Feb 11 15:24:47 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88ADEC6FD1D for ; Fri, 7 Apr 2023 14:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240383AbjDGOR2 (ORCPT ); Fri, 7 Apr 2023 10:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbjDGORS (ORCPT ); Fri, 7 Apr 2023 10:17:18 -0400 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387876E95 for ; Fri, 7 Apr 2023 07:17:17 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R281e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VfX8evk_1680877033; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VfX8evk_1680877033) by smtp.aliyun-inc.com; Fri, 07 Apr 2023 22:17:13 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/7] erofs: initialize packed inode after root inode is assigned Date: Fri, 7 Apr 2023 22:17:05 +0800 Message-Id: <20230407141710.113882-3-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20230407141710.113882-1-jefflexu@linux.alibaba.com> References: <20230407141710.113882-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As commit 8f7acdae2cd4 ("staging: erofs: kill all failure handling in fill_super()"), move the initialization of packed inode after root inode is assigned, so that the iput() in .put_super() is adequate as the failure handling. Otherwise, iput() is also needed in .kill_sb(), in case of the mounting fails halfway. Signed-off-by: Jingbo Xu Reviewed-by: Gao Xiang Reviewed-by: Yue Hu --- fs/erofs/internal.h | 1 + fs/erofs/super.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 2bcff3194e4a..caea9dc1cd82 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -157,6 +157,7 @@ struct erofs_sb_info { =20 /* what we really care is nid, rather than ino.. */ erofs_nid_t root_nid; + erofs_nid_t packed_nid; /* used for statfs, f_files - f_favail */ u64 inos; =20 diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 58ffbf410bfb..325602820dc8 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -388,17 +388,7 @@ static int erofs_read_superblock(struct super_block *s= b) #endif sbi->islotbits =3D ilog2(sizeof(struct erofs_inode_compact)); sbi->root_nid =3D le16_to_cpu(dsb->root_nid); -#ifdef CONFIG_EROFS_FS_ZIP - sbi->packed_inode =3D NULL; - if (erofs_sb_has_fragments(sbi) && dsb->packed_nid) { - sbi->packed_inode =3D - erofs_iget(sb, le64_to_cpu(dsb->packed_nid)); - if (IS_ERR(sbi->packed_inode)) { - ret =3D PTR_ERR(sbi->packed_inode); - goto out; - } - } -#endif + sbi->packed_nid =3D le64_to_cpu(dsb->packed_nid); sbi->inos =3D le64_to_cpu(dsb->inos); =20 sbi->build_time =3D le64_to_cpu(dsb->build_time); @@ -820,6 +810,16 @@ static int erofs_fc_fill_super(struct super_block *sb,= struct fs_context *fc) =20 erofs_shrinker_register(sb); /* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */ +#ifdef CONFIG_EROFS_FS_ZIP + 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; + } + } +#endif err =3D erofs_init_managed_cache(sb); if (err) return err; --=20 2.19.1.6.gb485710b