From 3c70515d068ddd713ee71e4e7abb1c577c00bc97 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 24 Aug 2017 11:58:18 -0400 ext4: cleanup goto next group avoid duplicated codes, also we need goto next group in case we found reserved inode. Signed-off-by: Wang Shilong Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara --- fs/ext4/ialloc.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 54f1ae0..7d71533 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -775,28 +775,19 @@ got_group: /* * Check free inodes count before loading bitmap. */ - if (ext4_free_inodes_count(sb, gdp) == 0) { - if (++group == ngroups) - group = 0; - continue; - } + if (ext4_free_inodes_count(sb, gdp) == 0) + goto next_group; grp = ext4_get_group_info(sb, group); /* Skip groups with already-known suspicious inode tables */ - if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { - if (++group == ngroups) - group = 0; - continue; - } + if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) + goto next_group; brelse(inode_bitmap_bh); inode_bitmap_bh = ext4_read_inode_bitmap(sb, group); /* Skip groups with suspicious inode tables */ - if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) || !inode_bitmap_bh) { - if (++group == ngroups) - group = 0; - continue; - } + if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) || !inode_bitmap_bh) + goto next_group; repeat_in_this_group: ino = ext4_find_next_zero_bit((unsigned long *) @@ -807,7 +798,7 @@ repeat_in_this_group: if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) { ext4_error(sb, "reserved inode found cleared - " "inode=%lu", ino + 1); - continue; + goto next_group; } if ((EXT4_SB(sb)->s_journal == NULL) && recently_deleted(sb, group, ino)) { -- 1.8.3.1