Whamcloud - gitweb
LU-17705 ptlrpc: replace synchronize_rcu() with rcu_barrier()
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel8 / ext4-mballoc-skip-uninit-groups-cr0.patch
1 --- linux-4.18/fs/ext4/mballoc.c        2019-11-28 14:55:26.500545920 +0300
2 +++ linux-4.18/fs/ext4/mballoc.c        2019-11-28 14:53:18.600086008 +0300
3 @@ -1885,6 +1885,21 @@ void ext4_mb_scan_aligned(struct ext4_allocation_context *ac,
4
5         return 0;
6  }
7 +
8 +static inline int ext4_mb_uninit_on_disk(struct super_block *sb,
9 +                                   ext4_group_t group)
10 +{
11 +       struct ext4_group_desc *desc;
12 +
13 +       if (!ext4_has_group_desc_csum(sb))
14 +               return 0;
15 +
16 +       desc = ext4_get_group_desc(sb, group, NULL);
17 +       if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))
18 +               return 1;
19 +
20 +       return 0;
21 +}
22
23  /*
24   * The routine scans buddy structures (not bitmap!) from given order
25 @@ -2060,7 +2060,15 @@ static int ext4_mb_good_group(struct
26  
27         /* We only do this if the grp has never been initialized */
28         if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
29 -               int ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS);
30 +               int ret;
31 +
32 +               /* cr=0/1 is a very optimistic search to find large
33 +                * good chunks almost for free. if buddy data is
34 +                * not ready, then this optimization makes no sense */
35 +
36 +               if (cr < 2 && !ext4_mb_uninit_on_disk(ac->ac_sb, group))
37 +                       return 0;
38 +               ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS);
39                 if (ret)
40                         return ret;
41         }