Skip to content

Commit 5624ea1

Browse files
jankaragregkh
authored andcommitted
ext4: fix stripe-unaligned allocations
[ Upstream commit d9b22cf9f5466a057f2a4f1e642b469fa9d73117 ] When a filesystem is created using: mkfs.ext4 -b 4096 -E stride=512 <dev> and we try to allocate 64MB extent, we will end up directly in ext4_mb_complex_scan_group(). This is because the request is detected as power-of-two allocation (so we start in ext4_mb_regular_allocator() with ac_criteria == 0) however the check before ext4_mb_simple_scan_group() refuses the direct buddy scan because the allocation request is too large. Since cr == 0, the check whether we should use ext4_mb_scan_aligned() fails as well and we fall back to ext4_mb_complex_scan_group(). Fix the problem by checking for upper limit on power-of-two requests directly when detecting them. Reported-by: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a76eb0e commit 5624ea1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fs/ext4/mballoc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,8 +2136,10 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
21362136
* We search using buddy data only if the order of the request
21372137
* is greater than equal to the sbi_s_mb_order2_reqs
21382138
* You can tune it via /sys/fs/ext4/<partition>/mb_order2_req
2139+
* We also support searching for power-of-two requests only for
2140+
* requests upto maximum buddy size we have constructed.
21392141
*/
2140-
if (i >= sbi->s_mb_order2_reqs) {
2142+
if (i >= sbi->s_mb_order2_reqs && i <= sb->s_blocksize_bits + 2) {
21412143
/*
21422144
* This should tell if fe_len is exactly power of 2
21432145
*/
@@ -2207,7 +2209,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
22072209
}
22082210

22092211
ac->ac_groups_scanned++;
2210-
if (cr == 0 && ac->ac_2order < sb->s_blocksize_bits+2)
2212+
if (cr == 0)
22112213
ext4_mb_simple_scan_group(ac, &e4b);
22122214
else if (cr == 1 && sbi->s_stripe &&
22132215
!(ac->ac_g_ex.fe_len % sbi->s_stripe))

0 commit comments

Comments
 (0)