From patchwork Mon Jun 8 08:45:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 11593239 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37711913 for ; Mon, 8 Jun 2020 12:11:58 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B915D206C3 for ; Mon, 8 Jun 2020 12:11:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SlLkcK0A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B915D206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591618316; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HRH5622GK53ELAhIow7ekeJc4DGC/92q9mGnusjs2NI=; b=SlLkcK0ArtoAf8C6Q0EHEtvEE+fjTk/i6PT4kx8D7urb3qIc/PY9dKOYOOPJW8QNHNs5zU uiFBw6hJutGqel7kqUai+G21H45ELn+4H+Fpda+ybvYexiR2zVDhhFiROrxj0bOd4fqyHU t49+DrM3HGZWCTOwMRqhn7qkm7MDO7E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-CtfzB5vaMqCSedckZsw-Hw-1; Mon, 08 Jun 2020 08:11:54 -0400 X-MC-Unique: CtfzB5vaMqCSedckZsw-Hw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 870ED835B5E; Mon, 8 Jun 2020 12:11:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E6B8891E8; Mon, 8 Jun 2020 12:11:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 291FF14CF3; Mon, 8 Jun 2020 12:11:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0588cXKO019780 for ; Mon, 8 Jun 2020 04:38:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30C192029F78; Mon, 8 Jun 2020 08:38:33 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CF112029F6F for ; Mon, 8 Jun 2020 08:38:30 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A8928007D9 for ; Mon, 8 Jun 2020 08:38:30 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-484-F3i0EakaNymIH-Wm3qkMCA-1; Mon, 08 Jun 2020 04:38:27 -0400 X-MC-Unique: F3i0EakaNymIH-Wm3qkMCA-1 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B99A6F025B8186699B03; Mon, 8 Jun 2020 16:38:21 +0800 (CST) Received: from localhost.localdomain (10.90.53.225) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Mon, 8 Jun 2020 16:38:11 +0800 From: yangerkun To: , , Date: Mon, 8 Jun 2020 16:45:12 +0800 Message-ID: <20200608084513.115671-2-yangerkun@huawei.com> In-Reply-To: <20200608084513.115671-1-yangerkun@huawei.com> References: <20200608084513.115671-1-yangerkun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0588cXKO019780 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 08 Jun 2020 08:11:03 -0400 Cc: dm-devel@redhat.com, yangerkun@huawei.com Subject: [dm-devel] [PATCH 1/2] dm dust: add interface to list all badblocks X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This interface may help anyone want to know all badblocks without query block one by one. Signed-off-by: yangerkun Reviewed-by: Bryan Gurney --- drivers/md/dm-dust.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/md/dm-dust.c b/drivers/md/dm-dust.c index ff03b90072c5..da5c10605c59 100644 --- a/drivers/md/dm-dust.c +++ b/drivers/md/dm-dust.c @@ -280,6 +280,24 @@ static int dust_clear_badblocks(struct dust_device *dd) return 0; } +static void dust_list_badblocks(struct dust_device *dd) +{ + unsigned long flags; + struct rb_root badblocklist; + struct rb_node *node; + struct badblock *bblk; + + DMINFO("%s: badblocks list below:", __func__); + spin_lock_irqsave(&dd->dust_lock, flags); + badblocklist = dd->badblocklist; + for (node = rb_first(&badblocklist); node; node = rb_next(node)) { + bblk = rb_entry(node, struct badblock, node); + DMINFO("bad block: %llu", bblk->bb); + } + spin_unlock_irqrestore(&dd->dust_lock, flags); + DMINFO("%s: badblocks list end.", __func__); +} + /* * Target parameters: * @@ -422,6 +440,9 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv, else dd->quiet_mode = false; r = 0; + } else if (!strcasecmp(argv[0], "listbadblocks")) { + dust_list_badblocks(dd); + r = 0; } else { invalid_msg = true; } From patchwork Mon Jun 8 08:45:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 11593241 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFD9A159A for ; Mon, 8 Jun 2020 12:11:58 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 69F3B206C3 for ; Mon, 8 Jun 2020 12:11:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ik5OafiK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69F3B206C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591618317; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/GNVLiXGuO9USeXxcf5qh/XqQaNzQh3hve1uLp85oqs=; b=Ik5OafiKUdoEBB9xxMtyIyPI6RiCpS1TUE183agwotR4zvySSbPj8/sjsaMcGvyGBLDYus Rl38wnPBzy+FWyv/XPEtW+c4fmDveMfYKrJYv/TQe59WJBOaW1FvL2ZbbQCB2Kkpgok1LY F9lt9v/V9vvp7lkrjT8cQhR/zp1XDJg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-yQ1iU9CUNtSJg4VH-akx0A-1; Mon, 08 Jun 2020 08:11:54 -0400 X-MC-Unique: yQ1iU9CUNtSJg4VH-akx0A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4EBC806E3B; Mon, 8 Jun 2020 12:11:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 362AD1A8EA; Mon, 8 Jun 2020 12:11:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A1A3B14CEA; Mon, 8 Jun 2020 12:11:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0588cXX6019779 for ; Mon, 8 Jun 2020 04:38:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30BBD2029F77; Mon, 8 Jun 2020 08:38:33 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CBCE2029F61 for ; Mon, 8 Jun 2020 08:38:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC6841859176 for ; Mon, 8 Jun 2020 08:38:32 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-z22Dy3JwOSOYoD4CYwqrZA-1; Mon, 08 Jun 2020 04:38:26 -0400 X-MC-Unique: z22Dy3JwOSOYoD4CYwqrZA-1 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B466C23E1279F7DD6BDD; Mon, 8 Jun 2020 16:38:21 +0800 (CST) Received: from localhost.localdomain (10.90.53.225) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Mon, 8 Jun 2020 16:38:11 +0800 From: yangerkun To: , , Date: Mon, 8 Jun 2020 16:45:13 +0800 Message-ID: <20200608084513.115671-3-yangerkun@huawei.com> In-Reply-To: <20200608084513.115671-1-yangerkun@huawei.com> References: <20200608084513.115671-1-yangerkun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0588cXX6019779 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 08 Jun 2020 08:11:03 -0400 Cc: dm-devel@redhat.com, yangerkun@huawei.com Subject: [dm-devel] [PATCH 2/2] dm dust: introduce listbadblocks in the rst X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Since we support the listbadblocks command, introduce the detail in the doc. Signed-off-by: yangerkun Reviewed-by: Bryan Gurney --- .../admin-guide/device-mapper/dm-dust.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/admin-guide/device-mapper/dm-dust.rst b/Documentation/admin-guide/device-mapper/dm-dust.rst index b6e7e7ead831..2c51a4acb8be 100644 --- a/Documentation/admin-guide/device-mapper/dm-dust.rst +++ b/Documentation/admin-guide/device-mapper/dm-dust.rst @@ -205,6 +205,23 @@ appear:: kernel: device-mapper: dust: clearbadblocks: no badblocks found +Listing the bad block list +-------------------------- + +To list all bad blocks in the bad block list, run the following message +command:: + + $ sudo dmsetup message dust1 0 listbadblocks + +The following message will appear, listing one bad block number per +line (using an example device with blocks 1 and 2 in the bad block +list):: + + device-mapper: dust: dust_list_badblocks: badblocks list below: + device-mapper: dust: bad block: 1 + device-mapper: dust: bad block: 2 + device-mapper: dust: dust_list_badblocks: badblocks list end. + Message commands list --------------------- @@ -223,6 +240,7 @@ Single argument message commands:: countbadblocks clearbadblocks + listbadblocks disable enable quiet