@@ -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;
}