From patchwork Thu May 4 12:48:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 90071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp288958vqo; Thu, 4 May 2023 05:51:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vKQoe6eDRRLNAqTU0def6DppLrRpykGNfl+MeO7JqGfcZQL6kSPyicwL6D7BA8Cg8u0Z7 X-Received: by 2002:a17:90b:3b87:b0:24e:c45:9ae5 with SMTP id pc7-20020a17090b3b8700b0024e0c459ae5mr2251050pjb.8.1683204686433; Thu, 04 May 2023 05:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683204686; cv=none; d=google.com; s=arc-20160816; b=x17N8X98BUaTiehzO/q0g7JgBbQkrOpp+8CaYDpkhIH9YJssXWc85BLs919FPtrxxR /5XZUW7na1/uWhBblwykK30hjbbkWygjaXAz5L1hpFwevULYbKGHYeb5WTlV7ewKQXSn nq76OT+UTWIRSgk3OheYWlpyrO3iks4jgIL7DOTDNquIfiNLT9RxE1Ys162o2DwZaopt LKaLKmEZkiFW4rLzaOBAjAdHMq6B/7h61I0p6mV6p+t0OuvLmqxnoDvhxDb9u/agEEb/ y0pGBXlqDb5of5gwVsdU9+OUFu4/Lw7oyUxAnuAZCeGooSxa1O2zOkAO+aq4HO4cIrtY ntew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Dbr5p3uqmeWLjzMNfnSUXDEmxtDjKXJ9BzYG3E2pfYQ=; b=RzlB5+OBScInFQMrIubP3Vmmm5HPtlkpB74Lburt796VGdQNr3PQkOorzWSWCEcNdt iztzAd207ZtbvHLyUxhQuHCaATDmPSZqDEiqG4rBJDOtdMwgldFlnQVpZuzYTRqnPP/7 8Zen7AbO80ZibwWt27pbdt48k8eLAnotm2fO05a+2h8MN4bXr6aRU33m2TGEzhBYAPAu FGOaWLKU2BPTOFYqWc/YLrSnDTXlNrkmVGGT6s50H2VhX1kR8h3yriOuR3y8xChSuceR MwlXH2SbsXhqBagUfQcUBoXp/SuY2I5WbIbOLShgUYzNLwZKvUy6sRO+Jteb4b1Wy1Ez SNcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hk3-20020a17090b224300b0024b9ac5462csi17162310pjb.94.2023.05.04.05.51.14; Thu, 04 May 2023 05:51:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230148AbjEDMuK (ORCPT + 99 others); Thu, 4 May 2023 08:50:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230427AbjEDMtv (ORCPT ); Thu, 4 May 2023 08:49:51 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1ACD59E8; Thu, 4 May 2023 05:49:41 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QBttm42vcz4f3k5n; Thu, 4 May 2023 20:49:36 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgBnHbHdqVNkzuf5Ig--.27873S9; Thu, 04 May 2023 20:49:37 +0800 (CST) From: linan666@huaweicloud.com To: axboe@kernel.dk, linan122@huawei.com, vishal.l.verma@intel.com, dan.j.williams@intel.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH v2 05/11] block/badblocks: fix the bug of reverse order Date: Thu, 4 May 2023 20:48:22 +0800 Message-Id: <20230504124828.679770-6-linan666@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230504124828.679770-1-linan666@huaweicloud.com> References: <20230504124828.679770-1-linan666@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBnHbHdqVNkzuf5Ig--.27873S9 X-Coremail-Antispam: 1UD129KBjvdXoWrKFyruF1kuw1xKr4DWr1UGFg_yoWfAFX_Ja 40yay8Xrn5Jr1ayw1SyF1vyF4FvFW5Cr18Kry7Jr1kZa1Uta18Aws8Kr98Xrn8CFyDG39I yryfXr9Ivr4IqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbvxYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r126s 0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_GcCE3s1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACI402YVCY1x0262 8vn2kIc2xKxwAKzVCY07xG64k0F24l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAI cVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVF xhVjvjDU0xZFpf9x07UMa0PUUUUU= X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764968037284243037?= X-GMAIL-MSGID: =?utf-8?q?1764968037284243037?= From: Li Nan Order of badblocks will be reversed if we set a large area at once. 'hi' remains unchanged while adding continuous badblocks is wrong, the next setting is greater than 'hi', it should be added to the next position. Let 'hi' +1 each cycle. # echo 0 2048 > bad_blocks # cat bad_blocks 1536 512 1024 512 512 512 0 512 Fixes: 9e0e252a048b ("badblocks: Add core badblock management code") Signed-off-by: Li Nan --- block/badblocks.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/badblocks.c b/block/badblocks.c index f34351b59414..11e3a3ae2c72 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -320,6 +320,7 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors, p[hi] = BB_MAKE(s, this_sectors, acknowledged); sectors -= this_sectors; s += this_sectors; + hi++; changed = true; } }