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


This patchset will list badblocks while we do 'dmsetup status'.

Image that we have mark block 1 and 2 as bad block, run following
command will list all bad blocks:

    $ sudo dmsetup status dust1
    0 33552384 dust 252:17 bypass verbose badblocks list: 1 2

v1->v2:
Realize this logical in dust_status instead dust_message since the
result can return to user directly.


yangerkun (2):
  dm dust: list badblock in dust_status
  dm dust: introduce list badblocks in the rst

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

-- 
2.25.4

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

* [PATCH v2 1/2] dm dust: list badblock in dust_status
  2020-06-18  9:06 [PATCH v2 0/2] introduce interface to list all badblocks yangerkun
@ 2020-06-18  9:06 ` yangerkun
  2020-06-18  9:06 ` [PATCH v2 2/2] dm dust: introduce list badblocks in the rst yangerkun
  2020-06-18 15:40 ` [PATCH v2 0/2] introduce interface to list all badblocks Mike Snitzer
  2 siblings, 0 replies; 5+ messages in thread
From: yangerkun @ 2020-06-18  9:06 UTC (permalink / raw)
  To: snitzer, bgurney, agk, bmr; +Cc: dm-devel, yangerkun

List all bad blocks may help user check the status of dust. We add this
logical in dust_status, which will return result to user directly.

Signed-off-by: yangerkun <yangerkun@huawei.com>
---
 drivers/md/dm-dust.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/md/dm-dust.c b/drivers/md/dm-dust.c
index ff03b90072c5..f96adb240adc 100644
--- a/drivers/md/dm-dust.c
+++ b/drivers/md/dm-dust.c
@@ -478,6 +478,30 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
 	return r;
 }
 
+static void dust_list_badblocks(struct dust_device *dd, char *result, unsigned int maxlen,
+				unsigned int *sz_ptr)
+{
+	unsigned long flags;
+	struct rb_root badblocklist;
+	struct rb_node *node;
+	struct badblock *bblk;
+	unsigned int sz = *sz_ptr;
+	int num = 0;
+
+	DMEMIT(" badblocks list:");
+	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);
+		DMEMIT(" %llu", bblk->bb);
+		num++;
+	}
+
+	spin_unlock_irqrestore(&dd->dust_lock, flags);
+	if (!num)
+		DMEMIT(" null");
+}
+
 static void dust_status(struct dm_target *ti, status_type_t type,
 			unsigned int status_flags, char *result, unsigned int maxlen)
 {
@@ -489,6 +513,7 @@ static void dust_status(struct dm_target *ti, status_type_t type,
 		DMEMIT("%s %s %s", dd->dev->name,
 		       dd->fail_read_on_bb ? "fail_read_on_bad_block" : "bypass",
 		       dd->quiet_mode ? "quiet" : "verbose");
+		dust_list_badblocks(dd, result, maxlen, &sz);
 		break;
 
 	case STATUSTYPE_TABLE:
-- 
2.25.4

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

* [PATCH v2 2/2] dm dust: introduce list badblocks in the rst
  2020-06-18  9:06 [PATCH v2 0/2] introduce interface to list all badblocks yangerkun
  2020-06-18  9:06 ` [PATCH v2 1/2] dm dust: list badblock in dust_status yangerkun
@ 2020-06-18  9:06 ` yangerkun
  2020-06-18 15:40 ` [PATCH v2 0/2] introduce interface to list all badblocks Mike Snitzer
  2 siblings, 0 replies; 5+ messages in thread
From: yangerkun @ 2020-06-18  9:06 UTC (permalink / raw)
  To: snitzer, bgurney, agk, bmr; +Cc: dm-devel, yangerkun

Since we can list bad blocks with command status, introduce the detail
in the doc.

Signed-off-by: yangerkun <yangerkun@huawei.com>
---
 .../admin-guide/device-mapper/dm-dust.rst          | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/admin-guide/device-mapper/dm-dust.rst b/Documentation/admin-guide/device-mapper/dm-dust.rst
index b6e7e7ead831..9267d9330482 100644
--- a/Documentation/admin-guide/device-mapper/dm-dust.rst
+++ b/Documentation/admin-guide/device-mapper/dm-dust.rst
@@ -205,6 +205,20 @@ appear::
 
         kernel: device-mapper: dust: clearbadblocks: no badblocks found
 
+Listing the bad blocks
+----------------------
+
+After we have add some bad blocks(like block 1 and 2), run the following
+command can help us to check the bad blocks::
+
+        $ sudo dmsetup status dust1
+        0 33552384 dust 252:17 bypass verbose badblocks list: 1 2
+
+And if there is no bad blocks, we will get following results::
+
+        $ sudo dmsetup status dust1
+        0 33552384 dust 252:17 bypass verbose badblocks list: null
+
 Message commands list
 ---------------------
 
-- 
2.25.4

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

* Re: [PATCH v2 0/2] introduce interface to list all badblocks
  2020-06-18  9:06 [PATCH v2 0/2] introduce interface to list all badblocks yangerkun
  2020-06-18  9:06 ` [PATCH v2 1/2] dm dust: list badblock in dust_status yangerkun
  2020-06-18  9:06 ` [PATCH v2 2/2] dm dust: introduce list badblocks in the rst yangerkun
@ 2020-06-18 15:40 ` Mike Snitzer
  2020-06-19  1:07   ` yangerkun
  2 siblings, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2020-06-18 15:40 UTC (permalink / raw)
  To: yangerkun; +Cc: bmr, dm-devel, agk, bgurney

On Thu, Jun 18 2020 at  5:06am -0400,
yangerkun <yangerkun@huawei.com> wrote:

> 
> This patchset will list badblocks while we do 'dmsetup status'.
> 
> Image that we have mark block 1 and 2 as bad block, run following
> command will list all bad blocks:
> 
>     $ sudo dmsetup status dust1
>     0 33552384 dust 252:17 bypass verbose badblocks list: 1 2
> 
> v1->v2:
> Realize this logical in dust_status instead dust_message since the
> result can return to user directly.

Seems you've misundeerstood.  Please don't augment status to include the
listing of badblocks.  The list _could_ be extremely long.

The feedback you got earlier was to use DMEMIT() from the .message
hook.  And the listing would be provided as output from the 'dmsetup
message ...' command.

Mike

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

* Re: [PATCH v2 0/2] introduce interface to list all badblocks
  2020-06-18 15:40 ` [PATCH v2 0/2] introduce interface to list all badblocks Mike Snitzer
@ 2020-06-19  1:07   ` yangerkun
  0 siblings, 0 replies; 5+ messages in thread
From: yangerkun @ 2020-06-19  1:07 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: bmr, dm-devel, agk, bgurney



在 2020/6/18 23:40, Mike Snitzer 写道:
> On Thu, Jun 18 2020 at  5:06am -0400,
> yangerkun <yangerkun@huawei.com> wrote:
> 
>>
>> This patchset will list badblocks while we do 'dmsetup status'.
>>
>> Image that we have mark block 1 and 2 as bad block, run following
>> command will list all bad blocks:
>>
>>      $ sudo dmsetup status dust1
>>      0 33552384 dust 252:17 bypass verbose badblocks list: 1 2
>>
>> v1->v2:
>> Realize this logical in dust_status instead dust_message since the
>> result can return to user directly.
> 
> Seems you've misundeerstood.  Please don't augment status to include the
> listing of badblocks.  The list _could_ be extremely long.
> 
> The feedback you got earlier was to use DMEMIT() from the .message
> hook.  And the listing would be provided as output from the 'dmsetup
> message ...' command.

Got it! It's my mistake.

Thanks,
Kun.
> 
> Mike
> 
> 
> .
> 


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

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

end of thread, other threads:[~2020-06-19  1:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18  9:06 [PATCH v2 0/2] introduce interface to list all badblocks yangerkun
2020-06-18  9:06 ` [PATCH v2 1/2] dm dust: list badblock in dust_status yangerkun
2020-06-18  9:06 ` [PATCH v2 2/2] dm dust: introduce list badblocks in the rst yangerkun
2020-06-18 15:40 ` [PATCH v2 0/2] introduce interface to list all badblocks Mike Snitzer
2020-06-19  1:07   ` 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.