Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dm dust: add interface to list all badblocks

This interface may help anyone who want to know all badblocks without
querying for each block.

[Bryan: DMEMIT message if no blocks are in the bad block list.]

Signed-off-by: yangerkun <yangerkun@huawei.com>
Signed-off-by: Bryan Gurney <bgurney@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

yangerkun and committed by
Mike Snitzer
0c248ea2 4f7f590b

+44
+17
Documentation/admin-guide/device-mapper/dm-dust.rst
··· 206 206 207 207 dust_clear_badblocks: no badblocks found 208 208 209 + Listing the bad block list 210 + -------------------------- 211 + 212 + To list all bad blocks in the bad block list (using an example device 213 + with blocks 1 and 2 in the bad block list), run the following message 214 + command:: 215 + 216 + $ sudo dmsetup message dust1 0 listbadblocks 217 + 1 218 + 2 219 + 220 + If there are no bad blocks in the bad block list, the command will 221 + execute with no output:: 222 + 223 + $ sudo dmsetup message dust1 0 listbadblocks 224 + 209 225 Message commands list 210 226 --------------------- 211 227 ··· 240 224 241 225 countbadblocks 242 226 clearbadblocks 227 + listbadblocks 243 228 disable 244 229 enable 245 230 quiet
+27
drivers/md/dm-dust.c
··· 284 284 return 1; 285 285 } 286 286 287 + static int dust_list_badblocks(struct dust_device *dd, char *result, unsigned int maxlen, 288 + unsigned int *sz_ptr) 289 + { 290 + unsigned long flags; 291 + struct rb_root badblocklist; 292 + struct rb_node *node; 293 + struct badblock *bblk; 294 + unsigned int sz = *sz_ptr; 295 + unsigned long long num = 0; 296 + 297 + spin_lock_irqsave(&dd->dust_lock, flags); 298 + badblocklist = dd->badblocklist; 299 + for (node = rb_first(&badblocklist); node; node = rb_next(node)) { 300 + bblk = rb_entry(node, struct badblock, node); 301 + DMEMIT("%llu\n", bblk->bb); 302 + num++; 303 + } 304 + 305 + spin_unlock_irqrestore(&dd->dust_lock, flags); 306 + if (!num) 307 + DMEMIT("No blocks in badblocklist"); 308 + 309 + return 1; 310 + } 311 + 287 312 /* 288 313 * Target parameters: 289 314 * ··· 452 427 else 453 428 dd->quiet_mode = false; 454 429 r = 0; 430 + } else if (!strcasecmp(argv[0], "listbadblocks")) { 431 + r = dust_list_badblocks(dd, result, maxlen, &sz); 455 432 } else { 456 433 invalid_msg = true; 457 434 }