[dm-devel] [RFC 1/2] dm dust: add interface to list all badblocks
Bryan Gurney
bgurney at redhat.com
Fri Jun 5 19:47:29 UTC 2020
On Fri, Jun 5, 2020 at 3:48 AM yangerkun <yangerkun at huawei.com> wrote:
>
> This interface may help anyone want to know all badblocks without query
> block one by one.
>
> Signed-off-by: yangerkun <yangerkun at huawei.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..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;
> }
> --
> 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,
Reviewed-by: Bryan Gurney <bgurney at redhat.com>
Thanks,
Bryan
More information about the dm-devel
mailing list