introduce interface to list all badblocks
Subsystems (2)
cover introduce interface to list all badblocks
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 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.
yangerkun (2):
dm dust: add interface to list all badblocks
dm dust: introduce listbadblocks in the rst
.../admin-guide/device-mapper/dm-dust.rst | 16 ++++++++++++++ drivers/md/dm-dust.c | 21 +++++++++++++++++++ 2 files changed, 37 insertions(+)
Signature · 1 line
2.25.4
RFC 1/2 dm dust: add interface to list all badblocks
This interface may help anyone want to know all badblocks without query block one by one.
--- drivers/md/dm-dust.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/md/dm-dust.c +21 -0
@@ -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; }
Signature · 1 line
2.25.4
Re: [RFC 1/2] dm dust: add interface to list all badblocks
Quoted 49 lines · yangerkun
This interface may help anyone want to know all badblocks without query block one by one.
Signed-off-by yangerkun <[email protected]>--- drivers/md/dm-dust.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)drivers/md/dm-dust.c +21
-1@@ -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; } --
Quoted 2 lines
2.25.4
I tested this, and it looks good.
I see that the message says "badblocks list as below"; I'm wondering if that was meant to say "badblocks list is below". Or perhaps it might be better to say "badblocks list below".
Aside from that potential correction,
Thanks,
Bryan
RFC 2/2 dm dust: introduce listbadblocks in the rst
In reply to yangerkunSince we support the listbadblocks command, introduce the detail in the doc.
--- .../admin-guide/device-mapper/dm-dust.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/admin-guide/device-mapper/dm-dust.rst +16 -0
@@ -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
Signature · 1 line
2.25.4
Re: [RFC 2/2] dm dust: introduce listbadblocks in the rst
Quoted 5 lines · yangerkun
Since we support the listbadblocks command, introduce the detail in the doc.
Signed-off-by yangerkun <[email protected]>
Thank you for the documentation. I have a few corrections listed below:
Documentation/admin-guide/device-mapper/dm-dust.rst appear:: · line 208
Quoted 13 lines
--- .../admin-guide/device-mapper/dm-dust.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Documentation/admin-guide/device-mapper/dm-dust.rst +1
-0@@ -205,6 +205,21 @@ appear:: kernel: device-mapper: dust: clearbadblocks: no badblocks found +Listling the bad block list
"Listing the bad block list"
Documentation/admin-guide/device-mapper/dm-dust.rst appear:: · line 211
Quoted 3 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +3
-0+--------------------------- + +To list all bad block list, run the following message command::
"To list all bad blocks in the bad block list"
Documentation/admin-guide/device-mapper/dm-dust.rst appear:: · line 216
Quoted 5 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +5
-0+ + $ 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)::
"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)"
After those corrections are made,
Thanks,
Bryan
Quoted 20 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +7
-1+ + 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 --2.25.4
Re: [RFC 2/2] dm dust: introduce listbadblocks in the rst
Quoted 41 lines · Bryan Gurney
Quoted 5 lines · yangerkun
Since we support the listbadblocks command, introduce the detail in the doc.
Signed-off-by yangerkun <[email protected]>Thank you for the documentation. I have a few corrections listed below:
Documentation/admin-guide/device-mapper/dm-dust.rst appear:: · line 208
Quoted 13 lines
--- .../admin-guide/device-mapper/dm-dust.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Documentation/admin-guide/device-mapper/dm-dust.rst +1
-0@@ -205,6 +205,21 @@ appear:: kernel: device-mapper: dust: clearbadblocks: no badblocks found +Listling the bad block list"Listing the bad block list"
Documentation/admin-guide/device-mapper/dm-dust.rst appear:: · line 211
Quoted 3 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +3
-0+--------------------------- + +To list all bad block list, run the following message command::"To list all bad blocks in the bad block list"
Documentation/admin-guide/device-mapper/dm-dust.rst appear:: · line 216
Quoted 5 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +5
-0+ + $ 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)::"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)"
Quoted 3 lines
After those corrections are made,
Reviewed-by Bryan Gurney <[email protected]>
Thanks for your advise for this series, I will fix it and send v2 with your review tag!
Thanks,
Kun.
Quoted 19 lines
Thanks,
Bryan
Quoted 11 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +6
-0+ + 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::
Quoted 11 lines
Quoted 9 lines
Documentation/admin-guide/device-mapper/dm-dust.rst +1
-1countbadblocks clearbadblocks + listbadblocks disable enable quiet --2.25.4
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel