Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9061236rwd; Wed, 21 Jun 2023 02:26:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76KBfr5amK4mMsAxLOII5fm3DPLcZJkbPHaK6jBC4Hqq4VNytL3luY2a23UrOGeILeAVAG X-Received: by 2002:a05:6a20:9189:b0:10f:f672:6e88 with SMTP id v9-20020a056a20918900b0010ff6726e88mr11576950pzd.4.1687339584610; Wed, 21 Jun 2023 02:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687339584; cv=none; d=google.com; s=arc-20160816; b=oQCw2CcK58xYF9sMVsJ2stE9riV3k9+S4QN4bmb34+2VEvthK9nn3kt36qhZi+Da4P /YIrez8TBg8YvwM68mwmoR3CVMEF2ac4fdHte6olqyyT43oLMCEU9jmXxJrnERlasOX3 ZbXP4+9lzGvnoeGGiCBp7cagZyUU8/K/c4OM4pWUU9WDlGRpRO0QsFbvn8oKpBm2zPkS ZcV9jnp57d+WM0I479KgRM759MdKi+SmyaqCdLE4biNqZ96FYJXKYDOhoSSbJjU7eUl8 C2ri/tMQa/nrF4Q1fxZP2ksXR4LUAKE9ALufZGalQwVsLehouxH+FMeaB7ZURVCQop2d iWAQ== 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=4HLLx2Ci1bAFvnEL0yqzYMsCH/mD87xt8jeDw81tUMM=; b=nUUn3hB6FrE9tAl3xAWf4+6Euoe8uYKc2dXw9nQXyFp/nmcVX8YVHUGP7uWKKgH+5m ev8uesa6pXjelZZFqZViSPIDcKVJ0pelXDg5nwhntdPg22sMjTCTAx2D1FX5P/Lw/f3R 86Vyhftn+lyGZKy8bWncBlwASUIhVe4nCDtHhAuKqdyqNC09rem+ducP0nDhgH+nmaFj uE2/H5Mu8ZcgJYd23zb41H37S6XPNdTdJQoCniNK2EP753alj83asmzev1QpnQiuN9CH KvAHaNN1+0vmvmZHt+tLFEAh7B2PVeDzUik9pW03kwP5ERB3fIDelRv+BVh2cXVRT5sw rW8w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a170902788900b001b58767a0f7si3684164pll.60.2023.06.21.02.26.11; Wed, 21 Jun 2023 02:26:24 -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 S231294AbjFUJWe (ORCPT + 99 others); Wed, 21 Jun 2023 05:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230148AbjFUJW1 (ORCPT ); Wed, 21 Jun 2023 05:22:27 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB85D10F9; Wed, 21 Jun 2023 02:22:26 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QmJ1W2gmNz4f3yYb; Wed, 21 Jun 2023 17:22:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCHLaFMwZJk+OrGMA--.39130S8; Wed, 21 Jun 2023 17:22:24 +0800 (CST) From: linan666@huaweicloud.com To: axboe@kernel.dk, linan122@huawei.com, dan.j.williams@intel.com, vishal.l.verma@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 v3 4/4] block/badblocks: fix the bug of reverse order Date: Thu, 22 Jun 2023 01:20:52 +0800 Message-Id: <20230621172052.1499919-5-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230621172052.1499919-1-linan666@huaweicloud.com> References: <20230621172052.1499919-1-linan666@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgCHLaFMwZJk+OrGMA--.39130S8 X-Coremail-Antispam: 1UD129KBjvdXoWrKFyruF1kuw1xKr4DWr1UGFg_yoWfAFX_J3 4vyFW8Xrn5JFnIkw1SyFy0yF4FvFW5Cr18Kry7Arn7Za1Utan5AwsxKr98Xrn8GFy7G3sI yr93Xryavr4IqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbQ8YFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r126s0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC 64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM2 8EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq 3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1lnxkEFVAIw20F6cxK64vIFxWle2I262 IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAF wI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0x vY0x0EwIxGrwACI402YVCY1x02628vn2kIc2xKxwAKzVCY07xG64k0F24l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42 xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF 7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUsVWlDUUUU X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, KHOP_HELO_FCRDNS,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 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 2c2ef8284a3f..3b816690b940 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -301,6 +301,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; } } -- 2.39.2