Skip to content

Commit cb9bce7

Browse files
lostjefflehsiangkao
authored andcommitted
erofs: initialize packed inode after root inode is assigned
As commit 8f7acda ("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 <jefflexu@linux.alibaba.com> Reviewed-by: Yue Hu <huyue2@coolpad.com> Fixes: b15b2e3 ("erofs: support on-disk compressed fragments data") Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Acked-by: Chao Yu <chao@kernel.org> Link: https://lore.kernel.org/r/20230407141710.113882-3-jefflexu@linux.alibaba.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent cc4efd3 commit cb9bce7

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

fs/erofs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct erofs_sb_info {
157157

158158
/* what we really care is nid, rather than ino.. */
159159
erofs_nid_t root_nid;
160+
erofs_nid_t packed_nid;
160161
/* used for statfs, f_files - f_favail */
161162
u64 inos;
162163

fs/erofs/super.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,7 @@ static int erofs_read_superblock(struct super_block *sb)
388388
#endif
389389
sbi->islotbits = ilog2(sizeof(struct erofs_inode_compact));
390390
sbi->root_nid = le16_to_cpu(dsb->root_nid);
391-
#ifdef CONFIG_EROFS_FS_ZIP
392-
sbi->packed_inode = NULL;
393-
if (erofs_sb_has_fragments(sbi) && dsb->packed_nid) {
394-
sbi->packed_inode =
395-
erofs_iget(sb, le64_to_cpu(dsb->packed_nid));
396-
if (IS_ERR(sbi->packed_inode)) {
397-
ret = PTR_ERR(sbi->packed_inode);
398-
goto out;
399-
}
400-
}
401-
#endif
391+
sbi->packed_nid = le64_to_cpu(dsb->packed_nid);
402392
sbi->inos = le64_to_cpu(dsb->inos);
403393

404394
sbi->build_time = le64_to_cpu(dsb->build_time);
@@ -818,6 +808,16 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
818808

819809
erofs_shrinker_register(sb);
820810
/* sb->s_umount is already locked, SB_ACTIVE and SB_BORN are not set */
811+
#ifdef CONFIG_EROFS_FS_ZIP
812+
if (erofs_sb_has_fragments(sbi) && sbi->packed_nid) {
813+
sbi->packed_inode = erofs_iget(sb, sbi->packed_nid);
814+
if (IS_ERR(sbi->packed_inode)) {
815+
err = PTR_ERR(sbi->packed_inode);
816+
sbi->packed_inode = NULL;
817+
return err;
818+
}
819+
}
820+
#endif
821821
err = erofs_init_managed_cache(sb);
822822
if (err)
823823
return err;

0 commit comments

Comments
 (0)