]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0014-ext4-fallback-to-complex-scan-if-aligned-scan-doesn-.patch
rebase patches on top of Ubuntu-6.5.0-27.27
[pve-kernel.git] / patches / kernel / 0014-ext4-fallback-to-complex-scan-if-aligned-scan-doesn-.patch
CommitLineData
5dde66b4 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
0ec9138f 2From: Ojaswin Mujoo <ojaswin@linux.ibm.com>
0ec9138f 3Date: Fri, 15 Dec 2023 16:49:50 +0530
5dde66b4 4Subject: [PATCH] ext4: fallback to complex scan if aligned scan doesn't work
0ec9138f
FG
5
6Currently in case the goal length is a multiple of stripe size we use
7ext4_mb_scan_aligned() to find the stripe size aligned physical blocks.
8In case we are not able to find any, we again go back to calling
9ext4_mb_choose_next_group() to search for a different suitable block
10group. However, since the linear search always begins from the start,
11most of the times we end up with the same BG and the cycle continues.
12
13With large fliesystems, the CPU can be stuck in this loop for hours
14which can slow down the whole system. Hence, until we figure out a
15better way to continue the search (rather than starting from beginning)
16in ext4_mb_choose_next_group(), lets just fallback to
17ext4_mb_complex_scan_group() in case aligned scan fails, as it is much
18more likely to find the needed blocks.
19
20Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
21---
22 fs/ext4/mballoc.c | 21 +++++++++++++--------
23 1 file changed, 13 insertions(+), 8 deletions(-)
24
25diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
4cf5a7d9 26index 5246b408cf0c..e3b942664842 100644
0ec9138f
FG
27--- a/fs/ext4/mballoc.c
28+++ b/fs/ext4/mballoc.c
5dde66b4 29@@ -2894,14 +2894,19 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
0ec9138f
FG
30 ac->ac_groups_scanned++;
31 if (cr == CR_POWER2_ALIGNED)
32 ext4_mb_simple_scan_group(ac, &e4b);
33- else if ((cr == CR_GOAL_LEN_FAST ||
34- cr == CR_BEST_AVAIL_LEN) &&
35- sbi->s_stripe &&
36- !(ac->ac_g_ex.fe_len %
37- EXT4_B2C(sbi, sbi->s_stripe)))
38- ext4_mb_scan_aligned(ac, &e4b);
39- else
40- ext4_mb_complex_scan_group(ac, &e4b);
41+ else {
42+ bool is_stripe_aligned = sbi->s_stripe &&
43+ !(ac->ac_g_ex.fe_len %
44+ EXT4_B2C(sbi, sbi->s_stripe));
45+
46+ if ((cr == CR_GOAL_LEN_FAST ||
47+ cr == CR_BEST_AVAIL_LEN) &&
48+ is_stripe_aligned)
49+ ext4_mb_scan_aligned(ac, &e4b);
50+
51+ if (ac->ac_status == AC_STATUS_CONTINUE)
52+ ext4_mb_complex_scan_group(ac, &e4b);
53+ }
54
55 ext4_unlock_group(sb, group);
56 ext4_mb_unload_buddy(&e4b);