Whamcloud - gitweb
LU-16222 kernel: RHEL 8.7 client and server support
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel8.7 / ext4-mballoc-skip-uninit-groups-cr0.patch
1 Index: kernel-4.18.0-423.el8/fs/ext4/mballoc.c
2 ===================================================================
3 --- kernel-4.18.0-423.el8.orig/fs/ext4/mballoc.c
4 +++ kernel-4.18.0-423.el8/fs/ext4/mballoc.c
5 @@ -1958,6 +1958,21 @@ int ext4_mb_find_by_goal(struct ext4_all
6         return 0;
7  }
8
9 +static inline int ext4_mb_uninit_on_disk(struct super_block *sb,
10 +                                   ext4_group_t group)
11 +{
12 +       struct ext4_group_desc *desc;
13 +
14 +       if (!ext4_has_group_desc_csum(sb))
15 +               return 0;
16 +
17 +       desc = ext4_get_group_desc(sb, group, NULL);
18 +       if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))
19 +               return 1;
20 +
21 +       return 0;
22 +}
23 +
24  /*
25   * The routine scans buddy structures (not bitmap!) from given order
26   * to max order and tries to find big enough chunk to satisfy the req
27 @@ -2196,6 +2211,12 @@ static int ext4_mb_good_group_nolock(str
28
29         /* We only do this if the grp has never been initialized */
30         if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
31 +               /* cr=0/1 is a very optimistic search to find large
32 +                * good chunks almost for free. if buddy data is
33 +                * not ready, then this optimization makes no sense */
34 +
35 +               if (cr < 2 && !ext4_mb_uninit_on_disk(ac->ac_sb, group))
36 +                       return 0;
37                 ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS);
38                 if (ret)
39                         return ret;