Skip to content

Commit 2fe435d

Browse files
Wang Shilongtytso
authored andcommitted
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 <wshilong@ddn.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
1 parent 4f9d956 commit 2fe435d

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

‎fs/ext4/ialloc.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -892,29 +892,21 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
892892
/*
893893
* Check free inodes count before loading bitmap.
894894
*/
895-
if (ext4_free_inodes_count(sb, gdp) == 0) {
896-
if (++group == ngroups)
897-
group = 0;
898-
continue;
899-
}
895+
if (ext4_free_inodes_count(sb, gdp) == 0)
896+
goto next_group;
900897

901898
grp = ext4_get_group_info(sb, group);
902899
/* Skip groups with already-known suspicious inode tables */
903-
if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
904-
if (++group == ngroups)
905-
group = 0;
906-
continue;
907-
}
900+
if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp))
901+
goto next_group;
908902

909903
brelse(inode_bitmap_bh);
910904
inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
911905
/* Skip groups with suspicious inode tables */
912906
if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) ||
913907
IS_ERR(inode_bitmap_bh)) {
914908
inode_bitmap_bh = NULL;
915-
if (++group == ngroups)
916-
group = 0;
917-
continue;
909+
goto next_group;
918910
}
919911

920912
repeat_in_this_group:
@@ -926,7 +918,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
926918
if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) {
927919
ext4_error(sb, "reserved inode found cleared - "
928920
"inode=%lu", ino + 1);
929-
continue;
921+
goto next_group;
930922
}
931923
if ((EXT4_SB(sb)->s_journal == NULL) &&
932924
recently_deleted(sb, group, ino)) {

0 commit comments

Comments
 (0)