From patchwork Sat Dec 23 06:37:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 13503942 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (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 4C7A86116; Sat, 23 Dec 2023 06:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SxvfB3tyVz4f3lVV; Sat, 23 Dec 2023 14:39:30 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id D1E2E1A09A0; Sat, 23 Dec 2023 14:39:35 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXmhCjgIZlBfyaEQ--.4053S8; Sat, 23 Dec 2023 14:39:35 +0800 (CST) From: linan666@huaweicloud.com To: axboe@kernel.dk, geliang.tang@suse.com, xni@redhat.com, colyli@suse.de Cc: ira.weiny@intel.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linan666@huaweicloud.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH 4/4] badblocks: clean up prev_badblocks() Date: Sat, 23 Dec 2023 14:37:28 +0800 Message-Id: <20231223063728.3229446-5-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231223063728.3229446-1-linan666@huaweicloud.com> References: <20231223063728.3229446-1-linan666@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Uns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IF0xvE42xK8VAvwI 8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v2 6r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUY4EEUUUUU X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ From: Li Nan The offset of 'lo' must <= ‘s' after biset. clean up redundant check. And replace the check of badblocks->count with badblocks_empty(). Signed-off-by: Li Nan --- block/badblocks.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/badblocks.c b/block/badblocks.c index 71a3e43351da..88ed13897443 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -486,7 +486,7 @@ static int prev_badblocks(struct badblocks *bb, struct badblocks_context *bad, int lo, hi; u64 *p; - if (!bb->count) + if (badblocks_empty(bb)) goto out; if (hint >= 0) { @@ -521,8 +521,7 @@ static int prev_badblocks(struct badblocks *bb, struct badblocks_context *bad, hi = mid; } - if (BB_OFFSET(p[lo]) <= s) - ret = lo; + ret = lo; out: return ret; }