Return-Path: Received: from omzsmtpe02.verizonbusiness.com ([199.249.25.209]:14224 "EHLO omzsmtpe02.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753659AbdJGWiy (ORCPT ); Sat, 7 Oct 2017 18:38:54 -0400 From: "Levin, Alexander (Sasha Levin)" Cc: Jan Kara , Theodore Ts'o , "Levin, Alexander (Sasha Levin)" To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH review for 3.18 03/12] ext4: fix stripe-unaligned allocations Date: Sat, 7 Oct 2017 22:37:59 +0000 Message-ID: <20171007223752.25085-3-alexander.levin@verizon.com> References: <20171007223752.25085-1-alexander.levin@verizon.com> In-Reply-To: <20171007223752.25085-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jan Kara [ Upstream commit d9b22cf9f5466a057f2a4f1e642b469fa9d73117 ] When a filesystem is created using: mkfs.ext4 -b 4096 -E stride=3D512 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 =3D=3D 0) however the check before ext4_mb_simple_scan_group() refuses the direct buddy scan because the allocation request is too large. Since cr =3D=3D 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 Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/mballoc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index da268894e7c7..6f51f016f80b 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2113,8 +2113,10 @@ ext4_mb_regular_allocator(struct ext4_allocation_con= text *ac) * We search using buddy data only if the order of the request * is greater than equal to the sbi_s_mb_order2_reqs * You can tune it via /sys/fs/ext4//mb_order2_req + * We also support searching for power-of-two requests only for + * requests upto maximum buddy size we have constructed. */ - if (i >=3D sbi->s_mb_order2_reqs) { + if (i >=3D sbi->s_mb_order2_reqs && i <=3D sb->s_blocksize_bits + 2) { /* * This should tell if fe_len is exactly power of 2 */ @@ -2176,7 +2178,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_cont= ext *ac) } =20 ac->ac_groups_scanned++; - if (cr =3D=3D 0 && ac->ac_2order < sb->s_blocksize_bits+2) + if (cr =3D=3D 0) ext4_mb_simple_scan_group(ac, &e4b); else if (cr =3D=3D 1 && sbi->s_stripe && !(ac->ac_g_ex.fe_len % sbi->s_stripe)) --=20 2.11.0