Whamcloud - gitweb
LU-9796 ldiskfs: improve inode allocation performance
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel7 / ext4-cleanup-goto-next-group.patch
1 From 3c70515d068ddd713ee71e4e7abb1c577c00bc97 Mon Sep 17 00:00:00 2001
2 From: Wang Shilong <wshilong@ddn.com>
3 Date: Thu, 24 Aug 2017 11:58:18 -0400
4 ext4: cleanup goto next group
5
6 avoid duplicated codes, also we need goto
7 next group in case we found reserved inode.
8
9 Signed-off-by: Wang Shilong <wshilong@ddn.com>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
11 Reviewed-by: Jan Kara <jack@suse.cz>
12 ---
13  fs/ext4/ialloc.c | 23 +++++++----------------
14  1 file changed, 7 insertions(+), 16 deletions(-)
15
16 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
17 index 54f1ae0..7d71533 100644
18 --- a/fs/ext4/ialloc.c
19 +++ b/fs/ext4/ialloc.c
20 @@ -775,28 +775,19 @@ got_group:
21                 /*
22                  * Check free inodes count before loading bitmap.
23                  */
24 -               if (ext4_free_inodes_count(sb, gdp) == 0) {
25 -                       if (++group == ngroups)
26 -                               group = 0;
27 -                       continue;
28 -               }
29 +               if (ext4_free_inodes_count(sb, gdp) == 0)
30 +                       goto next_group;
31  
32                 grp = ext4_get_group_info(sb, group);
33                 /* Skip groups with already-known suspicious inode tables */
34 -               if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
35 -                       if (++group == ngroups)
36 -                               group = 0;
37 -                       continue;
38 -               }
39 +               if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp))
40 +                       goto next_group;
41  
42                 brelse(inode_bitmap_bh);
43                 inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
44                 /* Skip groups with suspicious inode tables */
45 -               if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) || !inode_bitmap_bh) {
46 -                       if (++group == ngroups)
47 -                               group = 0;
48 -                       continue;
49 -               }
50 +               if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) || !inode_bitmap_bh)
51 +                       goto next_group;
52  
53  repeat_in_this_group:
54                 ino = ext4_find_next_zero_bit((unsigned long *)
55 @@ -807,7 +798,7 @@ repeat_in_this_group:
56                 if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) {
57                         ext4_error(sb, "reserved inode found cleared - "
58                                    "inode=%lu", ino + 1);
59 -                       continue;
60 +                       goto next_group;
61                 }
62                 if ((EXT4_SB(sb)->s_journal == NULL) &&
63                     recently_deleted(sb, group, ino)) {
64 -- 
65 1.8.3.1
66