Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp63413lqo; Wed, 27 Mar 2024 07:05:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXmmY/VloMnDoC42WOCR1W//BYEG61XSx9XL7TJRYZqKzB2s9zYnOd+hdS9crWyx64ms/7DMMkGJ0dhLUcwJQuSnoDQ2N2+9jZN/5JpA== X-Google-Smtp-Source: AGHT+IFLU3yK1uk5N6MZ6Qr23asnuWRNcmVG/4V4kdTrgiR+jNQUMjXOXIH5zB4oHBoghurjyjsy X-Received: by 2002:a05:6358:4e15:b0:17e:bae0:fe95 with SMTP id ld21-20020a0563584e1500b0017ebae0fe95mr5364108rwc.7.1711548355673; Wed, 27 Mar 2024 07:05:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711548355; cv=pass; d=google.com; s=arc-20160816; b=CzhXlqc6cF1bPB2aTxfetwNeDUhwcN0aVed9WZEDS/v4sQY7miTYMUu4QKAhYeJ7xe GBW3aO0VJSVoiMCibcbOdjrXBitc0V9HFogDR68bO/6cnEBnlpn3nC8bFuixuy0q/8jF A3W8CDijCDcCfkcSa2GHzX2An4yUnK6GvA00ExFq3NdwifwqaydGy8uSi7CVb8rYAfnh 7WFIQxfRxbxIYw9bb3EXFvnegowOkfsH8Fb9697ELHQWRwAF0lK4qOBuLzaw8pc8xzsS WK6nahC5MaBbGWPAwJqC9YEhH8VASsW3RAcWay8PRHB7WAo45slwDvTSBdvys+k1ix/A 8O8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=QtMm16RLdo2+sI4lS0UXYqBRbbq0ZUdH49yZyzRPgEM=; fh=VZYbYYVWUaBjALw5RsXFeevcg0476TXeiYnLmJ3T9Iw=; b=TPiDOpIW622XI0aJDgm8WAnN0hO9E/8vVgqV94VMWfG9Dlfo6ARsRo1Bbez4+C9Wy3 ZgBIppjF0DfpqG1GDi6S9AmKPzTlI+sGHBO8gsgDTQtigIuEqalCTNN9CdHiDCUJVy+U 2BljUvV+gcLOQAoyEG/DD4S+QFH9MWVVAffmeIpQEaHRxi4s5omrG4907cRzfXwEXWh1 bv9XrOkK2SKp15qzI1I6aa5n07ClFc1t76UTOFn92u4yT2JgPZ5jNtoshxr4o6v7jwWW ijulfu6Ku2zbqeormias8R5BXYjFJybEBrkFDsi6/toWQhqFcFpULwt6rtoGwsOJssqq YYQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7v+qloP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-1759-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1759-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x25-20020a056102091900b0047548c99cc3si1569542vsh.736.2024.03.27.07.05.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 07:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1759-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7v+qloP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-1759-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1759-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4980A1C2B743 for ; Wed, 27 Mar 2024 14:05:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC7891B8851; Wed, 27 Mar 2024 12:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M7v+qloP" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DF63130AF3; Wed, 27 Mar 2024 12:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711542518; cv=none; b=LIAvrKRpZWisc16wX0sXiZe45b0bJC1aqQXxef+R5VjUfvbNjIC9Ra4xyk52TCe05GgXW899lJ43L36iSlYSz1P2v8ujx15Rg8sVr6KrOEBjUkcWApuWEy+9aOVrTCgt1fA2iwfHi9yndlsRXvPDN4RqHhCriOnCmJNQ3R1TmTA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711542518; c=relaxed/simple; bh=myDVq6Ecyu1kDt857GRSaya/9nojDIL7DWhZExsuCac=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=LMmUEQbH7iP7/E2yX1lJsXmEAg0mZCcuugO90TXmKDxVAW4RqwFMwtWfI5ZSYmMKMMmGF3XEtw22IzgcTW6l6ChhQRJPVCVP3PZdwhF5da/mcArA7Adal38pXONoxFx8mbHh6crJBOzugevYL+nBdQ+WoAWXOt5t8TJmUYbPrHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M7v+qloP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08D1DC43390; Wed, 27 Mar 2024 12:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711542518; bh=myDVq6Ecyu1kDt857GRSaya/9nojDIL7DWhZExsuCac=; h=From:To:Cc:Subject:Date:From; b=M7v+qloPAhgKqbDGJTrRPQrPpOqqpjA3dKt6s8qPGPCXprRWjkTNdW9wIwwmr5Qw8 dl1PUqIkUb6r1cyrLRo2+6dNm6kc64ir3zkwzOEsmtITG2YZdmYPmvFkEU0wboLAk+ 0VPgNQvd+zib5g9lOb8ViuHiflMOm0vd4MzKxY7+8JuMm81qfwAi/dCh4ZYG+gGlKs b2TZoUT9SZwViL+TuhGng1jzdT6AcuiuDPyR0pMLB6rzCjCqazfbVfQE5x/m2FYm8t ti4K1GUrYkjgrQ4NVE1qGJYRZJyryGa5GCz+y77ek8jyfCQ757nn2GcGkgYeZVsXiQ 1WpcMr1UB2s7Q== From: Sasha Levin To: stable@vger.kernel.org, libaokun1@huawei.com Cc: stable@kernel.org, yangerkun , Jan Kara , Ojaswin Mujoo , Theodore Ts'o , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: FAILED: Patch "ext4: correct best extent lstart adjustment logic" failed to apply to 4.19-stable tree Date: Wed, 27 Mar 2024 08:28:35 -0400 Message-ID: <20240327122836.2842901-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Hint: ignore X-stable: review Content-Transfer-Encoding: 8bit The patch below does not apply to the 4.19-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Thanks, Sasha ------------------ original commit in Linus's tree ------------------ From 4fbf8bc733d14bceb16dda46a3f5e19c6a9621c5 Mon Sep 17 00:00:00 2001 From: Baokun Li Date: Thu, 1 Feb 2024 22:18:45 +0800 Subject: [PATCH] ext4: correct best extent lstart adjustment logic When yangerkun review commit 93cdf49f6eca ("ext4: Fix best extent lstart adjustment logic in ext4_mb_new_inode_pa()"), it was found that the best extent did not completely cover the original request after adjusting the best extent lstart in ext4_mb_new_inode_pa() as follows: original request: 2/10(8) normalized request: 0/64(64) best extent: 0/9(9) When we check if best ex can be kept at start of goal, ac_o_ex.fe_logical is 2 less than the adjusted best extent logical end 9, so we think the adjustment is done. But obviously 0/9(9) doesn't cover 2/10(8), so we should determine here if the original request logical end is less than or equal to the adjusted best extent logical end. In addition, add a comment stating when adjusted best_ex will not cover the original request, and remove the duplicate assertion because adjusting lstart makes no change to b_ex.fe_len. Link: https://lore.kernel.org/r/3630fa7f-b432-7afd-5f79-781bc3b2c5ea@huawei.com Fixes: 93cdf49f6eca ("ext4: Fix best extent lstart adjustment logic in ext4_mb_new_inode_pa()") Cc: Signed-off-by: yangerkun Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/20240201141845.1879253-1-libaokun1@huawei.com Signed-off-by: Theodore Ts'o --- fs/ext4/mballoc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index bce82e1e792fd..bd26f2a907512 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5172,10 +5172,16 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) .fe_len = ac->ac_orig_goal_len, }; loff_t orig_goal_end = extent_logical_end(sbi, &ex); + loff_t o_ex_end = extent_logical_end(sbi, &ac->ac_o_ex); - /* we can't allocate as much as normalizer wants. - * so, found space must get proper lstart - * to cover original request */ + /* + * We can't allocate as much as normalizer wants, so we try + * to get proper lstart to cover the original request, except + * when the goal doesn't cover the original request as below: + * + * orig_ex:2045/2055(10), isize:8417280 -> normalized:0/2048 + * best_ex:0/200(200) -> adjusted: 1848/2048(200) + */ BUG_ON(ac->ac_g_ex.fe_logical > ac->ac_o_ex.fe_logical); BUG_ON(ac->ac_g_ex.fe_len < ac->ac_o_ex.fe_len); @@ -5187,7 +5193,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) * 1. Check if best ex can be kept at end of goal (before * cr_best_avail trimmed it) and still cover original start * 2. Else, check if best ex can be kept at start of goal and - * still cover original start + * still cover original end * 3. Else, keep the best ex at start of original request. */ ex.fe_len = ac->ac_b_ex.fe_len; @@ -5197,7 +5203,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) goto adjust_bex; ex.fe_logical = ac->ac_g_ex.fe_logical; - if (ac->ac_o_ex.fe_logical < extent_logical_end(sbi, &ex)) + if (o_ex_end <= extent_logical_end(sbi, &ex)) goto adjust_bex; ex.fe_logical = ac->ac_o_ex.fe_logical; @@ -5205,7 +5211,6 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) ac->ac_b_ex.fe_logical = ex.fe_logical; BUG_ON(ac->ac_o_ex.fe_logical < ac->ac_b_ex.fe_logical); - BUG_ON(ac->ac_o_ex.fe_len > ac->ac_b_ex.fe_len); BUG_ON(extent_logical_end(sbi, &ex) > orig_goal_end); } -- 2.43.0