Skip to content

Commit 6c053e4

Browse files
committed
Merge: ext4: fallback to complex scan if aligned scan doesn't work
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6642 JIRA: https://issues.redhat.com/browse/RHEL-83284 Conflicts: Work around allocation criteria logic difference and lack of macros in RHEL9. commit 1f6bc02 Author: Ojaswin Mujoo <[email protected]> Date: Fri Dec 15 16:49:50 2023 +0530 ext4: fallback to complex scan if aligned scan doesn't work Currently in case the goal length is a multiple of stripe size we use ext4_mb_scan_aligned() to find the stripe size aligned physical blocks. In case we are not able to find any, we again go back to calling ext4_mb_choose_next_group() to search for a different suitable block group. However, since the linear search always begins from the start, most of the times we end up with the same BG and the cycle continues. With large fliesystems, the CPU can be stuck in this loop for hours which can slow down the whole system. Hence, until we figure out a better way to continue the search (rather than starting from beginning) in ext4_mb_choose_next_group(), lets just fallback to ext4_mb_complex_scan_group() in case aligned scan fails, as it is much more likely to find the needed blocks. Signed-off-by: Ojaswin Mujoo <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/ee033f6dfa0a7f2934437008a909c3788233950f.1702455010.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Brian Foster <[email protected]> Approved-by: Eric Sandeen <[email protected]> Approved-by: Carlos Maiolino <[email protected]> Approved-by: Jay Shin <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Augusto Caringi <[email protected]>
2 parents 14ba1f0 + cde9021 commit 6c053e4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

fs/ext4/mballoc.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,12 +2786,17 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
27862786
ac->ac_groups_scanned++;
27872787
if (cr == 0)
27882788
ext4_mb_simple_scan_group(ac, &e4b);
2789-
else if (cr == 1 && sbi->s_stripe &&
2790-
!(ac->ac_g_ex.fe_len %
2791-
EXT4_B2C(sbi, sbi->s_stripe)))
2792-
ext4_mb_scan_aligned(ac, &e4b);
2793-
else
2794-
ext4_mb_complex_scan_group(ac, &e4b);
2789+
else {
2790+
bool is_stripe_aligned = sbi->s_stripe &&
2791+
!(ac->ac_g_ex.fe_len %
2792+
EXT4_B2C(sbi, sbi->s_stripe));
2793+
2794+
if (cr == 1 && is_stripe_aligned)
2795+
ext4_mb_scan_aligned(ac, &e4b);
2796+
2797+
if (ac->ac_status == AC_STATUS_CONTINUE)
2798+
ext4_mb_complex_scan_group(ac, &e4b);
2799+
}
27952800

27962801
ext4_unlock_group(sb, group);
27972802
ext4_mb_unload_buddy(&e4b);

0 commit comments

Comments
 (0)