From patchwork Fri Jun 5 07:32:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 11590887 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 8D75592A for ; Sat, 6 Jun 2020 00:22:29 +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 mail.kernel.org (Postfix) with ESMTPS id 47FE0206FA for ; Sat, 6 Jun 2020 00:22:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IcZ+0asO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47FE0206FA 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=1591402948; 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=xiSgFkyQv21JK8tJKGaeaRzAh3uQFEu/UyZCyAGdejc=; b=IcZ+0asOROJsa6S2egWDz92h+ecIW//bhA72TupJeQnqL1mY2JISA2J0mE2j1LfV3unN8u MXkZqrMc17394wi2rtavQUwxEGGZnubnLw0qMQP3qcmPqtLaXaRspAw0QNgy4sC6FX2fNX wIcKD2Al4rAqHBao3b0jAfa/hN+TZxM= 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-188-99RtugDpM12ujiWRCMyyXg-1; Fri, 05 Jun 2020 20:22:26 -0400 X-MC-Unique: 99RtugDpM12ujiWRCMyyXg-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 C7C20A0BE9; Sat, 6 Jun 2020 00:22:21 +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 A998B7CCEE; Sat, 6 Jun 2020 00:22:21 +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 80C85B3492; Sat, 6 Jun 2020 00:22:21 +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 0557mssU006063 for ; Fri, 5 Jun 2020 03:48:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48F5F2029F6F; Fri, 5 Jun 2020 07:48:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 332942017F02 for ; Fri, 5 Jun 2020 07:48:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 EEDF6800294 for ; Fri, 5 Jun 2020 07:48:51 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-389-v0ZoIg67PS-8MRqPHeiGbA-1; Fri, 05 Jun 2020 03:48:49 -0400 X-MC-Unique: v0ZoIg67PS-8MRqPHeiGbA-1 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 69455CA57FB6EB25590F; Fri, 5 Jun 2020 15:32:35 +0800 (CST) Received: from code-website.localdomain (10.175.104.175) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 5 Jun 2020 15:32:27 +0800 From: yangerkun To: , , Date: Fri, 5 Jun 2020 15:32:00 +0800 Message-ID: <20200605073201.1742675-2-yangerkun@huawei.com> In-Reply-To: <20200605073201.1742675-1-yangerkun@huawei.com> References: <20200605073201.1742675-1-yangerkun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 0557mssU006063 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 05 Jun 2020 09:30:21 -0400 Cc: dm-devel@redhat.com, yangerkun@huawei.com Subject: [dm-devel] [RFC 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..903c0d158c6e 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 as 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 Fri Jun 5 07:32:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 11590889 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 694AE912 for ; Sat, 6 Jun 2020 00:22:31 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25FC92076D for ; Sat, 6 Jun 2020 00:22:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A11udzZE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25FC92076D 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=1591402950; 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=WC3TC/1xODu+nBi/T2JT5VRLwdkA3HxUtOKn2mirev4=; b=A11udzZEFBPzKtVWgR8hXnDB3KHOe+vEKiQhewcXsf3Q0skTMselvYubX4GuDmMg0FW4bX f8eD5S6QGZN89Oai6VqsRPll0+HMckJLoww4xT++8JiDrA/uPQUJOBP6kVrmcJcTKRTr5H lsrGTz7agzAeX86Cd2UpaJYsrUmWdv8= 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-63--wcZ_lkHNFOl_sVKRgKfCQ-1; Fri, 05 Jun 2020 20:22:28 -0400 X-MC-Unique: -wcZ_lkHNFOl_sVKRgKfCQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0F3A835B51; Sat, 6 Jun 2020 00:22:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D58D95D9E5; Sat, 6 Jun 2020 00:22:23 +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 AC693180530A; Sat, 6 Jun 2020 00:22:23 +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 0557muql006070 for ; Fri, 5 Jun 2020 03:48:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35B07200C0FC; Fri, 5 Jun 2020 07:48:56 +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 23240202683D for ; Fri, 5 Jun 2020 07:48:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 5532D18A6671 for ; Fri, 5 Jun 2020 07:48:54 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-UZkj5KVBOYCpX_jnx1-g5w-1; Fri, 05 Jun 2020 03:48:49 -0400 X-MC-Unique: UZkj5KVBOYCpX_jnx1-g5w-1 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5E57A3B4FDA59AD90264; Fri, 5 Jun 2020 15:32:35 +0800 (CST) Received: from code-website.localdomain (10.175.104.175) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 5 Jun 2020 15:32:27 +0800 From: yangerkun To: , , Date: Fri, 5 Jun 2020 15:32:01 +0800 Message-ID: <20200605073201.1742675-3-yangerkun@huawei.com> In-Reply-To: <20200605073201.1742675-1-yangerkun@huawei.com> References: <20200605073201.1742675-1-yangerkun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 0557muql006070 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 05 Jun 2020 09:30:21 -0400 Cc: dm-devel@redhat.com, yangerkun@huawei.com Subject: [dm-devel] [RFC 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.79 on 10.5.11.14 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/admin-guide/device-mapper/dm-dust.rst b/Documentation/admin-guide/device-mapper/dm-dust.rst index b6e7e7ead831..185b3ce6298b 100644 --- a/Documentation/admin-guide/device-mapper/dm-dust.rst +++ b/Documentation/admin-guide/device-mapper/dm-dust.rst @@ -205,6 +205,21 @@ appear:: kernel: device-mapper: dust: clearbadblocks: no badblocks found +Listling the bad block list +--------------------------- + +To list all bad block list, run the following message command:: + + $ sudo dmsetup message dust1 0 listbadblocks + +We will get following message(image that we have insert block 1/2, and +we will list the block index in order):: + + device-mapper: dust: dust_list_badblocks: badblocks list as 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 +238,7 @@ Single argument message commands:: countbadblocks clearbadblocks + listbadblocks disable enable quiet