From patchwork Thu May 4 12:48:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 90076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp293361vqo; Thu, 4 May 2023 05:59:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cw6GqXa7cKzLJ9JfrgKDXFtnVUOGux6Du6u/yWkoHdQkLGYo1n41bVdaZFnBslGnXuZF5 X-Received: by 2002:a05:6a20:940a:b0:f0:929c:e8c5 with SMTP id hl10-20020a056a20940a00b000f0929ce8c5mr1777529pzb.35.1683205163544; Thu, 04 May 2023 05:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683205163; cv=none; d=google.com; s=arc-20160816; b=hqOrqzjcASUPvlTS5gki9BR26Yao+iuyVwN6ZTT2CVHbk5j8UWwfvUujqK5k8GgPNQ 110dp2uVpERTCfYyzQi3rwGsLB2dLyu1rMfGdfQ3WpRmFiOsfDKp4CleE4PJiH99FDGY YIYlzJkWC0KN/ogufJFw8xTyn/UJvjqefNP0Kam39l163g6zc+u8toe5FjzUbE+gQhfE 5fW2i1rM/+KeI7HkYGGihxJFeh3sYQCPByNEBziJ+QPejJtlv0lQdDcGcKzOE9HvxjvU IF8YPdhvQau+GMWaeo4jaOHJSQCisD9Xk3TB3eoq5HGI3RA+b4xiSKFu8+Fqy2hDSsz3 Muqw== 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=liICAxlMwkOQCaI+MkxEFMRFBWeqgO1xww8OLQkyKSk=; b=iLKPjO3IbCf0GPQCLjQ36vYB6mvxdkVAwodlz98swrxNHUktSEcA8oIVPJT4xOMWoj khCsXekLg5FI8JdZdYGt00sWQ26Otfe5dZ6rObEm73em3WAExyjiI/qZIPjjarnwXYms VxXTuNO84euxkLoecGTTjwJNF9Oy8i+A5yZN3+9w5m1upN7xFonCmEun7cPP1qh37F/l i+GHsXhpBdcVLLLmPxylzf/QEoTcJle1gEMTqHqunvx1SjBbESRJ2TJNsMzS90qKGOv8 zjAp6WgNFDoi/ayqto04UNnQAcA/SpYfxbhxkL57YATamJQpBHqkFApqKVScZNT8VRxG puiw== 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 j69-20020a638048000000b00528cf858c87si12858272pgd.156.2023.05.04.05.59.08; Thu, 04 May 2023 05:59:23 -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 S230424AbjEDMu0 (ORCPT + 99 others); Thu, 4 May 2023 08:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbjEDMtv (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 929A26A7E; Thu, 4 May 2023 05:49:43 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QBttn0tW5z4f3v51; Thu, 4 May 2023 20:49:37 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgBnHbHdqVNkzuf5Ig--.27873S10; Thu, 04 May 2023 20:49:38 +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 06/11] block/badblocks: fix ack set fail in badblocks_set Date: Thu, 4 May 2023 20:48:23 +0800 Message-Id: <20230504124828.679770-7-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--.27873S10 X-Coremail-Antispam: 1UD129KBjvdXoWrZF4xtrWrWrW8tF17JFWUArb_yoWkXrg_J3 WFyFZ5Xrn5CFs8Cr1Yy3W0qrsY9F45Cr4kCw12qrn7XrsrtF1DJws8tr93Wrn5CFZrC390 v34rXr9Iva4IqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-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?1764968537907659712?= X-GMAIL-MSGID: =?utf-8?q?1764968537907659712?= From: Li Nan If we try to set ack for a BB_MAX_LEN badblocks, it will return 0(success) but did not set ack at all in badblocks_set(). Check ack before setting to fix it, and do not set badblocks already exist. Fixes: 9e0e252a048b ("badblocks: Add core badblock management code") Signed-off-by: Li Nan --- block/badblocks.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/badblocks.c b/block/badblocks.c index 11e3a3ae2c72..c11eb869f2f3 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -219,18 +219,18 @@ int badblocks_set(struct badblocks *bb, sector_t s, int sectors, if (e < s + sectors) e = s + sectors; if (e - a <= BB_MAX_LEN) { - p[lo] = BB_MAKE(a, e-a, ack); s = e; } else { /* does not all fit in one range, * make p[lo] maximal */ - if (BB_LEN(p[lo]) != BB_MAX_LEN) - p[lo] = BB_MAKE(a, BB_MAX_LEN, ack); s = a + BB_MAX_LEN; } + if (s - a != BB_LEN(p[lo]) || ack != BB_ACK(p[lo])) { + p[lo] = BB_MAKE(a, s - a, ack); + changed = true; + } sectors = e - s; - changed = true; } } if (sectors && hi < bb->count) {