]>
Commit | Line | Data |
---|---|---|
0ec9138f FG |
1 | From: Ojaswin Mujoo <ojaswin@linux.ibm.com> |
2 | To: linux-ext4@vger.kernel.org, "Theodore Ts'o" <tytso@mit.edu> | |
3 | Cc: Ritesh Harjani <ritesh.list@gmail.com>, linux-kernel@vger.kernel.org, | |
4 | Jan Kara <jack@suse.cz>, glandvador@yahoo.com, bugzilla@eyal.emu.id.au | |
5 | Subject: [PATCH 1/1] ext4: fallback to complex scan if aligned scan doesn't work | |
6 | Date: Fri, 15 Dec 2023 16:49:50 +0530 | |
7 | Message-Id: <ee033f6dfa0a7f2934437008a909c3788233950f.1702455010.git.ojaswin@linux.ibm.com> | |
8 | X-Mailer: git-send-email 2.39.3 | |
9 | In-Reply-To: <cover.1702455010.git.ojaswin@linux.ibm.com> | |
10 | References: <cover.1702455010.git.ojaswin@linux.ibm.com> | |
11 | ||
12 | Currently in case the goal length is a multiple of stripe size we use | |
13 | ext4_mb_scan_aligned() to find the stripe size aligned physical blocks. | |
14 | In case we are not able to find any, we again go back to calling | |
15 | ext4_mb_choose_next_group() to search for a different suitable block | |
16 | group. However, since the linear search always begins from the start, | |
17 | most of the times we end up with the same BG and the cycle continues. | |
18 | ||
19 | With large fliesystems, the CPU can be stuck in this loop for hours | |
20 | which can slow down the whole system. Hence, until we figure out a | |
21 | better way to continue the search (rather than starting from beginning) | |
22 | in ext4_mb_choose_next_group(), lets just fallback to | |
23 | ext4_mb_complex_scan_group() in case aligned scan fails, as it is much | |
24 | more likely to find the needed blocks. | |
25 | ||
26 | Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> | |
27 | --- | |
28 | fs/ext4/mballoc.c | 21 +++++++++++++-------- | |
29 | 1 file changed, 13 insertions(+), 8 deletions(-) | |
30 | ||
31 | diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c | |
32 | index d72b5e3c92ec..63f12ec02485 100644 | |
33 | --- a/fs/ext4/mballoc.c | |
34 | +++ b/fs/ext4/mballoc.c | |
35 | @@ -2895,14 +2895,19 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) | |
36 | ac->ac_groups_scanned++; | |
37 | if (cr == CR_POWER2_ALIGNED) | |
38 | ext4_mb_simple_scan_group(ac, &e4b); | |
39 | - else if ((cr == CR_GOAL_LEN_FAST || | |
40 | - cr == CR_BEST_AVAIL_LEN) && | |
41 | - sbi->s_stripe && | |
42 | - !(ac->ac_g_ex.fe_len % | |
43 | - EXT4_B2C(sbi, sbi->s_stripe))) | |
44 | - ext4_mb_scan_aligned(ac, &e4b); | |
45 | - else | |
46 | - ext4_mb_complex_scan_group(ac, &e4b); | |
47 | + else { | |
48 | + bool is_stripe_aligned = sbi->s_stripe && | |
49 | + !(ac->ac_g_ex.fe_len % | |
50 | + EXT4_B2C(sbi, sbi->s_stripe)); | |
51 | + | |
52 | + if ((cr == CR_GOAL_LEN_FAST || | |
53 | + cr == CR_BEST_AVAIL_LEN) && | |
54 | + is_stripe_aligned) | |
55 | + ext4_mb_scan_aligned(ac, &e4b); | |
56 | + | |
57 | + if (ac->ac_status == AC_STATUS_CONTINUE) | |
58 | + ext4_mb_complex_scan_group(ac, &e4b); | |
59 | + } | |
60 | ||
61 | ext4_unlock_group(sb, group); | |
62 | ext4_mb_unload_buddy(&e4b); | |
63 | -- | |
64 | 2.39.3 | |
65 | ||
66 |