From 6a7a700a1490dfde6b60c2fb36df92a052059866 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 28 Nov 2019 15:04:25 +0300 Subject: [PATCH] LU-12988 ldiskfs: skip non-loaded groups at cr=0/1 cr=0 is supposed to be an optimization to save CPU cycles, but if buddy data (in memory) is not initialized then all this makes no sense as we have to do sync IO taking a lot of cycles. also, at cr=0 mballoc doesn't store any avaibale chunk. cr=1 also skips groups using heruistic based on avg. fragment size. it's more useful to skip such groups and switch to cr=2 where groups will be scanned for available chunks. using sparse image and dm-slow virtual device of 120TB was simulated. then the image was formatted as OST and filled using debugfs to mark ~85% of available space as busy. mount as OST w/o the patch couldn't complete in half an hour (according to vmstat it would take ~10-11 hours). with the patch applied mount took ~20 seconds. Signed-off-by: Alex Zhuravlev Change-Id: I88c8c1b01b386af0fa438bfeb97acb6110bd00ec Reviewed-on: https://review.whamcloud.com/36891 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Wang Shilong Reviewed-by: Artem Blagodarenko --- .../rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch | 19 +++++++++++++++++++ .../rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch | 19 +++++++++++++++++++ .../kernel_patches/series/ldiskfs-3.10-rhel7.2.series | 1 + .../kernel_patches/series/ldiskfs-3.10-rhel7.3.series | 1 + .../kernel_patches/series/ldiskfs-3.10-rhel7.4.series | 1 + .../kernel_patches/series/ldiskfs-3.10-rhel7.5.series | 1 + .../kernel_patches/series/ldiskfs-3.10-rhel7.6.series | 1 + .../kernel_patches/series/ldiskfs-3.10-rhel7.7.series | 1 + .../kernel_patches/series/ldiskfs-3.10-rhel7.series | 1 + .../kernel_patches/series/ldiskfs-4.18-rhel8.series | 1 + 10 files changed, 46 insertions(+) create mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch create mode 100644 ldiskfs/kernel_patches/patches/rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch new file mode 100644 index 0000000..1bb8398 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch @@ -0,0 +1,19 @@ +--- linux-4.18/fs/ext4/mballoc.c 2019-11-28 14:55:26.500545920 +0300 ++++ linux-4.18/fs/ext4/mballoc.c 2019-11-28 14:53:18.600086008 +0300 +@@ -2060,7 +2060,15 @@ static int ext4_mb_good_group(struct + + /* We only do this if the grp has never been initialized */ + if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { +- int ret = ext4_mb_init_group(ac->ac_sb, group); ++ int ret; ++ ++ /* cr=0/1 is a very optimistic search to find large ++ * good chunks almost for free. if buddy data is ++ * not ready, then this optimization makes no sense */ ++ ++ if (cr < 2) ++ return 0; ++ ret = ext4_mb_init_group(ac->ac_sb, group); + if (ret) + return ret; + } diff --git a/ldiskfs/kernel_patches/patches/rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch b/ldiskfs/kernel_patches/patches/rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch new file mode 100644 index 0000000..38925ac --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch @@ -0,0 +1,19 @@ +--- linux-4.18/fs/ext4/mballoc.c 2019-11-28 14:55:26.500545920 +0300 ++++ linux-4.18/fs/ext4/mballoc.c 2019-11-28 14:53:18.600086008 +0300 +@@ -2060,7 +2060,15 @@ static int ext4_mb_good_group(struct + + /* We only do this if the grp has never been initialized */ + if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { +- int ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS); ++ int ret; ++ ++ /* cr=0/1 is a very optimistic search to find large ++ * good chunks almost for free. if buddy data is ++ * not ready, then this optimization makes no sense */ ++ ++ if (cr < 2) ++ return 0; ++ ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS); + if (ret) + return ret; + } diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series index 1588268..3948c95 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series @@ -37,3 +37,4 @@ rhel7/ext4-export-orphan-add.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series index ca71367..c0d41d9 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series @@ -37,3 +37,4 @@ rhel7/ext4-export-orphan-add.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series index 89fdbc2..906c6f5 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series @@ -37,3 +37,4 @@ rhel7/ext4-export-orphan-add.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series index f6b3552..5be93d7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series @@ -37,3 +37,4 @@ rhel7/ext4-mmp-dont-mark-bh-dirty.patch rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel7.2/ext4-export-mb-stream-allocator-variables.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series index bcca593..4602afa 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series @@ -38,3 +38,4 @@ rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inode rhel7.2/ext4-export-mb-stream-allocator-variables.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.2/ext4-simple-blockalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series index d564fc0..db81695 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series @@ -38,3 +38,4 @@ rhel7.2/ext4-export-mb-stream-allocator-variables.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.7/ext4-fix-project-with-unpatched-kernel.patch rhel7.2/ext4-simple-blockalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series index d5d372b..cf7f31d 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series @@ -32,3 +32,4 @@ rhel7/ext4-export-orphan-add.patch rhel7/ext4-mmp-dont-mark-bh-dirty.patch rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series index b5b98a3..adcca20 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series @@ -22,3 +22,4 @@ rhel7/ext4-export-orphan-add.patch ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel8/ext4-export-mb-stream-allocator-variables.patch rhel8/ext4-simple-blockalloc.patch +rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch -- 1.8.3.1