aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorJason Yan <yanaijie@huawei.com>2022-09-16 22:15:13 +0800
committerTheodore Ts'o <tytso@mit.edu>2022-09-30 23:46:52 -0400
commita5fc51193507e10a0733c40282e71216dd0486ff (patch)
treeec1db1de49301959b8dbcb3efca993faed1f7f3c /fs/ext4
parentext4: goto right label 'failed_mount3a' (diff)
downloadlinux-dev-a5fc51193507e10a0733c40282e71216dd0486ff.tar.xz
linux-dev-a5fc51193507e10a0733c40282e71216dd0486ff.zip
ext4: remove cantfind_ext4 error handler
The 'cantfind_ext4' error handler is just a error msg print and then goto failed_mount. This two level goto makes the code complex and not easy to read. The only benefit is that is saves a little bit code. However some branches can merge and some branches dot not even need it. So do some refactor and remove it. Signed-off-by: Jason Yan <yanaijie@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Link: https://lore.kernel.org/r/20220916141527.1012715-3-yanaijie@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/super.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 016b3410e915..34a261f6b47e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4344,8 +4344,12 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
es = (struct ext4_super_block *) (bh->b_data + offset);
sbi->s_es = es;
sb->s_magic = le16_to_cpu(es->s_magic);
- if (sb->s_magic != EXT4_SUPER_MAGIC)
- goto cantfind_ext4;
+ if (sb->s_magic != EXT4_SUPER_MAGIC) {
+ if (!silent)
+ ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
+ goto failed_mount;
+ }
+
sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written);
/* Warn if metadata_csum and gdt_csum are both set. */
@@ -4358,8 +4362,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
if (!ext4_verify_csum_type(sb, es)) {
ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with "
"unknown checksum algorithm.");
- silent = 1;
- goto cantfind_ext4;
+ goto failed_mount;
}
ext4_setup_csum_trigger(sb, EXT4_JTR_ORPHAN_FILE,
ext4_orphan_file_block_trigger);
@@ -4377,9 +4380,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
if (!ext4_superblock_csum_verify(sb, es)) {
ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with "
"invalid superblock checksum. Run e2fsck?");
- silent = 1;
ret = -EFSBADCRC;
- goto cantfind_ext4;
+ goto failed_mount;
}
/* Precompute checksum seed for all metadata */
@@ -4772,8 +4774,11 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb);
- if (sbi->s_inodes_per_block == 0)
- goto cantfind_ext4;
+ if (sbi->s_inodes_per_block == 0 || sbi->s_blocks_per_group == 0) {
+ if (!silent)
+ ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
+ goto failed_mount;
+ }
if (sbi->s_inodes_per_group < sbi->s_inodes_per_block ||
sbi->s_inodes_per_group > blocksize * 8) {
ext4_msg(sb, KERN_ERR, "invalid inodes per group: %lu\n",
@@ -4870,9 +4875,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
goto failed_mount;
}
- if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
- goto cantfind_ext4;
-
/* check blocks count against device size */
blocks_count = sb_bdev_nr_blocks(sb);
if (blocks_count && ext4_blocks_count(es) > blocks_count) {
@@ -5382,11 +5384,6 @@ no_journal:
return 0;
-cantfind_ext4:
- if (!silent)
- ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
- goto failed_mount;
-
failed_mount9:
ext4_release_orphan_info(sb);
failed_mount8: