Skip to contentSkip to conversation

introduce interface to list all badblocks

PATCH Superseded yangerkun 2 participants 5 messages Jun 18, 2020 – Jun 19, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

yangerkun

author
#0 lore raw

v2 cover introduce interface to list all badblocks

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(+)
Signature · 1 line
2.25.4
author
#1 lore raw

PATCH v2 1/2 dm dust: list badblock in dust_status

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.

---
 drivers/md/dm-dust.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/md/dm-dust.c +25 -0
index ff03b90072c5..f96adb240adc 100644
@@ -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:
Signature · 1 line
2.25.4
author
#2 lore raw

PATCH v2 2/2 dm dust: introduce list badblocks in the rst

In reply to yangerkun

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

---
 .../admin-guide/device-mapper/dm-dust.rst          | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Documentation/admin-guide/device-mapper/dm-dust.rst +14 -0
index b6e7e7ead831..9267d9330482 100644
@@ -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
 ---------------------
 
Signature · 1 line
2.25.4
#3 lore raw
In reply to yangerkun
Quoted 6 lines · 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:

Quoted 6 lines
    $ 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

author
#4 lore raw
Quoted 16 lines · Mike Snitzer
Quoted 6 lines · 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:

Quoted 6 lines
     $ 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.

Quoted 6 lines

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.

Quoted 6 lines

Mike

.

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel