All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] introduce interface to list all badblocks
@ 2020-06-08  8:45 yangerkun
  2020-06-08  8:45 ` [PATCH 1/2] dm dust: add " yangerkun
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: yangerkun @ 2020-06-08  8:45 UTC (permalink / raw)
  To: bgurney, agk, snitzer; +Cc: dm-devel, yangerkun

We can add/remove/query the badblocks, but no interface to list all
badblocks when we want to know the badblocks we ever set still
available. Add message listbadblocks to do this.

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.


yangerkun (2):
  dm dust: add interface to list all badblocks
  dm dust: introduce listbadblocks in the rst

 .../admin-guide/device-mapper/dm-dust.rst     | 18 ++++++++++++++++
 drivers/md/dm-dust.c                          | 21 +++++++++++++++++++
 2 files changed, 39 insertions(+)

-- 
2.23.0.rc2.8.gff66981f45

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] dm dust: add interface to list all badblocks
  2020-06-08  8:45 [PATCH 0/2] introduce interface to list all badblocks yangerkun
@ 2020-06-08  8:45 ` yangerkun
  2020-06-08  8:45 ` [PATCH 2/2] dm dust: introduce listbadblocks in the rst yangerkun
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: yangerkun @ 2020-06-08  8:45 UTC (permalink / raw)
  To: bgurney, agk, snitzer; +Cc: dm-devel, yangerkun

This interface may help anyone want to know all badblocks without query
block one by one.

Signed-off-by: yangerkun <yangerkun@huawei.com>
Reviewed-by: Bryan Gurney <bgurney@redhat.com>
---
 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;
 		}
-- 
2.23.0.rc2.8.gff66981f45

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] dm dust: introduce listbadblocks in the rst
  2020-06-08  8:45 [PATCH 0/2] introduce interface to list all badblocks yangerkun
  2020-06-08  8:45 ` [PATCH 1/2] dm dust: add " yangerkun
@ 2020-06-08  8:45 ` yangerkun
  2020-06-15  0:57 ` [PATCH 0/2] introduce interface to list all badblocks yangerkun
  2020-06-15 17:03 ` Alasdair G Kergon
  3 siblings, 0 replies; 7+ messages in thread
From: yangerkun @ 2020-06-08  8:45 UTC (permalink / raw)
  To: bgurney, agk, snitzer; +Cc: dm-devel, yangerkun

Since we support the listbadblocks command, introduce the detail in the
doc.

Signed-off-by: yangerkun <yangerkun@huawei.com>
Reviewed-by: Bryan Gurney <bgurney@redhat.com>
---
 .../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
-- 
2.23.0.rc2.8.gff66981f45

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] introduce interface to list all badblocks
  2020-06-08  8:45 [PATCH 0/2] introduce interface to list all badblocks yangerkun
  2020-06-08  8:45 ` [PATCH 1/2] dm dust: add " yangerkun
  2020-06-08  8:45 ` [PATCH 2/2] dm dust: introduce listbadblocks in the rst yangerkun
@ 2020-06-15  0:57 ` yangerkun
  2020-06-15 17:03 ` Alasdair G Kergon
  3 siblings, 0 replies; 7+ messages in thread
From: yangerkun @ 2020-06-15  0:57 UTC (permalink / raw)
  To: bgurney, agk, snitzer; +Cc: dm-devel

Hi,

Sorry for not send to Mike. Can you consider to apply this patchset?

Thanks,
Kun.

在 2020/6/8 16:45, yangerkun 写道:
> We can add/remove/query the badblocks, but no interface to list all
> badblocks when we want to know the badblocks we ever set still
> available. Add message listbadblocks to do this.
> 
> 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.
> 
> 
> yangerkun (2):
>    dm dust: add interface to list all badblocks
>    dm dust: introduce listbadblocks in the rst
> 
>   .../admin-guide/device-mapper/dm-dust.rst     | 18 ++++++++++++++++
>   drivers/md/dm-dust.c                          | 21 +++++++++++++++++++
>   2 files changed, 39 insertions(+)
> 


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] introduce interface to list all badblocks
  2020-06-08  8:45 [PATCH 0/2] introduce interface to list all badblocks yangerkun
                   ` (2 preceding siblings ...)
  2020-06-15  0:57 ` [PATCH 0/2] introduce interface to list all badblocks yangerkun
@ 2020-06-15 17:03 ` Alasdair G Kergon
  2020-06-16 12:28   ` Bryn M. Reeves
  3 siblings, 1 reply; 7+ messages in thread
From: Alasdair G Kergon @ 2020-06-15 17:03 UTC (permalink / raw)
  To: yangerkun; +Cc: dm-devel, snitzer, agk, bgurney

On Mon, Jun 08, 2020 at 04:45:11PM +0800, yangerkun wrote:
>     $ sudo dmsetup message dust1 0 listbadblocks
> The following message will appear, listing one bad block number per

Did you consider returning the data directly to the caller so it
can be accessed directly?

(e.g. like @stats_list handled in dm-stats.c)

Alasdair

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] introduce interface to list all badblocks
  2020-06-15 17:03 ` Alasdair G Kergon
@ 2020-06-16 12:28   ` Bryn M. Reeves
  2020-06-16 13:02     ` yangerkun
  0 siblings, 1 reply; 7+ messages in thread
From: Bryn M. Reeves @ 2020-06-16 12:28 UTC (permalink / raw)
  To: yangerkun, bgurney, agk, snitzer, dm-devel

On Mon, Jun 15, 2020 at 06:03:31PM +0100, Alasdair G Kergon wrote:
> On Mon, Jun 08, 2020 at 04:45:11PM +0800, yangerkun wrote:
> >     $ sudo dmsetup message dust1 0 listbadblocks
> > The following message will appear, listing one bad block number per
> 
> Did you consider returning the data directly to the caller so it
> can be accessed directly?
> 
> (e.g. like @stats_list handled in dm-stats.c)

Having this returned in the message response would certainly be more
natural and would simplify parsing the data: sending it to the log seems
like it would allow log lines from distinct devices to become
interleaved when the lists are long and the message is sent to two or
more devices near simultaneously. Without something to identify the
devices in each message you can't distinguish them.

Even with large numbers of bad blocks userspace libdevmapper will
automatically handle re-trying with a larger buffer if the list is too
big for the default.

We use (sometimes very large) message replies heavily in libdm-stats.

device-mapper.h provides the DMEMIT macro to output message replies.
See dm_stats_print() or various target status() functions for
examples.

Regards,
Bryn.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] introduce interface to list all badblocks
  2020-06-16 12:28   ` Bryn M. Reeves
@ 2020-06-16 13:02     ` yangerkun
  0 siblings, 0 replies; 7+ messages in thread
From: yangerkun @ 2020-06-16 13:02 UTC (permalink / raw)
  To: Bryn M. Reeves, bgurney, agk, snitzer, dm-devel



在 2020/6/16 20:28, Bryn M. Reeves 写道:
> On Mon, Jun 15, 2020 at 06:03:31PM +0100, Alasdair G Kergon wrote:
>> On Mon, Jun 08, 2020 at 04:45:11PM +0800, yangerkun wrote:
>>>      $ sudo dmsetup message dust1 0 listbadblocks
>>> The following message will appear, listing one bad block number per
>>
>> Did you consider returning the data directly to the caller so it
>> can be accessed directly?
>>
>> (e.g. like @stats_list handled in dm-stats.c)
> 
> Having this returned in the message response would certainly be more
> natural and would simplify parsing the data: sending it to the log seems
> like it would allow log lines from distinct devices to become
> interleaved when the lists are long and the message is sent to two or
> more devices near simultaneously. Without something to identify the
> devices in each message you can't distinguish them.
> 
> Even with large numbers of bad blocks userspace libdevmapper will
> automatically handle re-trying with a larger buffer if the list is too
> big for the default.
> 
> We use (sometimes very large) message replies heavily in libdm-stats.
> 
> device-mapper.h provides the DMEMIT macro to output message replies.
> See dm_stats_print() or various target status() functions for
> examples.
> 
> Regards,
> Bryn.
> 
Hi,

Thanks for your reply! I will read this code and consider to realize it!

Thanks,
Kun.

> 
> .
> 


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-16 13:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08  8:45 [PATCH 0/2] introduce interface to list all badblocks yangerkun
2020-06-08  8:45 ` [PATCH 1/2] dm dust: add " yangerkun
2020-06-08  8:45 ` [PATCH 2/2] dm dust: introduce listbadblocks in the rst yangerkun
2020-06-15  0:57 ` [PATCH 0/2] introduce interface to list all badblocks yangerkun
2020-06-15 17:03 ` Alasdair G Kergon
2020-06-16 12:28   ` Bryn M. Reeves
2020-06-16 13:02     ` yangerkun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.