1 ext4: fix stripe-unaligned allocations
3 From: Jan Kara <jack@suse.cz>
5 When a filesystem is created using:
7 mkfs.ext4 -b 4096 -E stride=512 <dev>
9 and we try to allocate 64MB extent, we will end up directly in
10 ext4_mb_complex_scan_group(). This is because the request is detected
11 as power-of-two allocation (so we start in ext4_mb_regular_allocator()
12 with ac_criteria == 0) however the check before
13 ext4_mb_simple_scan_group() refuses the direct buddy scan because the
14 allocation request is too large. Since cr == 0, the check whether we
15 should use ext4_mb_scan_aligned() fails as well and we fall back to
16 ext4_mb_complex_scan_group().
18 Fix the problem by checking for upper limit on power-of-two requests
19 directly when detecting them.
21 Reported-by: Ross Zwisler <ross.zwisler@linux.intel.com>
22 Signed-off-by: Jan Kara <jack@suse.cz>
23 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
25 fs/ext4/mballoc.c | 6 ++++--
26 1 file changed, 4 insertions(+), 2 deletions(-)
28 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
29 index 7ae43c59bc79..37db7ba0f69e 100644
30 --- a/fs/ext4/mballoc.c
31 +++ b/fs/ext4/mballoc.c
32 @@ -2136,8 +2136,10 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
33 * We search using buddy data only if the order of the request
34 * is greater than equal to the sbi_s_mb_order2_reqs
35 * You can tune it via /sys/fs/ext4/<partition>/mb_order2_req
36 + * We also support searching for power-of-two requests only for
37 + * requests upto maximum buddy size we have constructed.
39 - if (i >= sbi->s_mb_order2_reqs) {
40 + if (i >= sbi->s_mb_order2_reqs && i <= sb->s_blocksize_bits + 2) {
42 * This should tell if fe_len is exactly power of 2
44 @@ -2207,7 +2209,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
47 ac->ac_groups_scanned++;
48 - if (cr == 0 && ac->ac_2order < sb->s_blocksize_bits+2)
50 ext4_mb_simple_scan_group(ac, &e4b);
51 else if (cr == 1 && sbi->s_stripe &&
52 !(ac->ac_g_ex.fe_len % sbi->s_stripe))