add patch remove-useless-code-in-strtohash
[ext4-patch-queue.git] / cleanup-goto-next-group
blobab12b3b6ae0e6e360c1dc09979d19cd4ab03d28e
1 ext4: cleanup goto next group
3 From: Wang Shilong <wshilong@ddn.com>
5 avoid duplicated codes, also we need goto
6 next group in case we found reserved inode.
8 Signed-off-by: Wang Shilong <wshilong@ddn.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 Reviewed-by: Jan Kara <jack@suse.cz>
11 ---
12  fs/ext4/ialloc.c | 20 ++++++--------------
13  1 file changed, 6 insertions(+), 14 deletions(-)
15 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
16 index 0d03e73..9e6eb1c 100644
17 --- a/fs/ext4/ialloc.c
18 +++ b/fs/ext4/ialloc.c
19 @@ -892,19 +892,13 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
20                 /*
21                  * Check free inodes count before loading bitmap.
22                  */
23 -               if (ext4_free_inodes_count(sb, gdp) == 0) {
24 -                       if (++group == ngroups)
25 -                               group = 0;
26 -                       continue;
27 -               }
28 +               if (ext4_free_inodes_count(sb, gdp) == 0)
29 +                       goto next_group;
31                 grp = ext4_get_group_info(sb, group);
32                 /* Skip groups with already-known suspicious inode tables */
33 -               if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
34 -                       if (++group == ngroups)
35 -                               group = 0;
36 -                       continue;
37 -               }
38 +               if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp))
39 +                       goto next_group;
41                 brelse(inode_bitmap_bh);
42                 inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
43 @@ -912,9 +906,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
44                 if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) ||
45                     IS_ERR(inode_bitmap_bh)) {
46                         inode_bitmap_bh = NULL;
47 -                       if (++group == ngroups)
48 -                               group = 0;
49 -                       continue;
50 +                       goto next_group;
51                 }
53  repeat_in_this_group:
54 @@ -926,7 +918,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
55                 if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) {
56                         ext4_error(sb, "reserved inode found cleared - "
57                                    "inode=%lu", ino + 1);
58 -                       continue;
59 +                       goto next_group;
60                 }
61                 if ((EXT4_SB(sb)->s_journal == NULL) &&
62                     recently_deleted(sb, group, ino)) {
63 -- 
64 2.9.3