1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #include <mdb/mdb_ctf.h> 29 #include <sys/zfs_context.h> 30 #include <sys/mdb_modapi.h> 31 #include <sys/dbuf.h> 32 #include <sys/dmu_objset.h> 33 #include <sys/dsl_dir.h> 34 #include <sys/dsl_pool.h> 35 #include <sys/metaslab_impl.h> 36 #include <sys/space_map.h> 37 #include <sys/list.h> 38 #include <sys/spa_impl.h> 39 #include <sys/vdev_impl.h> 40 #include <sys/zio_compress.h> 41 42 #ifndef _KERNEL 43 #include "../genunix/list.h" 44 #endif 45 46 #ifdef _KERNEL 47 #define ZFS_OBJ_NAME "zfs" 48 #else 49 #define ZFS_OBJ_NAME "libzpool.so.1" 50 #endif 51 52 static char * 53 local_strdup(const char *s) 54 { 55 char *s1 = mdb_alloc(strlen(s) + 1, UM_SLEEP); 56 57 (void) strcpy(s1, s); 58 return (s1); 59 } 60 61 static int 62 getmember(uintptr_t addr, const char *type, mdb_ctf_id_t *idp, 63 const char *member, int len, void *buf) 64 { 65 mdb_ctf_id_t id; 66 ulong_t off; 67 char name[64]; 68 69 if (idp == NULL) { 70 if (mdb_ctf_lookup_by_name(type, &id) == -1) { 71 mdb_warn("couldn't find type %s", type); 72 return (DCMD_ERR); 73 } 74 idp = &id; 75 } else { 76 type = name; 77 mdb_ctf_type_name(*idp, name, sizeof (name)); 78 } 79 80 if (mdb_ctf_offsetof(*idp, member, &off) == -1) { 81 mdb_warn("couldn't find member %s of type %s\n", member, type); 82 return (DCMD_ERR); 83 } 84 if (off % 8 != 0) { 85 mdb_warn("member %s of type %s is unsupported bitfield", 86 member, type); 87 return (DCMD_ERR); 88 } 89 off /= 8; 90 91 if (mdb_vread(buf, len, addr + off) == -1) { 92 mdb_warn("failed to read %s from %s at %p", 93 member, type, addr + off); 94 return (DCMD_ERR); 95 } 96 /* mdb_warn("read %s from %s at %p+%llx\n", member, type, addr, off); */ 97 98 return (0); 99 } 100 101 #define GETMEMB(addr, type, member, dest) \ 102 getmember(addr, #type, NULL, #member, sizeof (dest), &(dest)) 103 104 #define GETMEMBID(addr, ctfid, member, dest) \ 105 getmember(addr, NULL, ctfid, #member, sizeof (dest), &(dest)) 106 107 static int 108 getrefcount(uintptr_t addr, mdb_ctf_id_t *id, 109 const char *member, uint64_t *rc) 110 { 111 static int gotid; 112 static mdb_ctf_id_t rc_id; 113 ulong_t off; 114 115 if (!gotid) { 116 if (mdb_ctf_lookup_by_name("struct refcount", &rc_id) == -1) { 117 mdb_warn("couldn't find struct refcount"); 118 return (DCMD_ERR); 119 } 120 gotid = TRUE; 121 } 122 123 if (mdb_ctf_offsetof(*id, member, &off) == -1) { 124 char name[64]; 125 mdb_ctf_type_name(*id, name, sizeof (name)); 126 mdb_warn("couldn't find member %s of type %s\n", member, name); 127 return (DCMD_ERR); 128 } 129 off /= 8; 130 131 return (GETMEMBID(addr + off, &rc_id, rc_count, *rc)); 132 } 133 134 static int 135 read_symbol(char *sym_name, void **bufp) 136 { 137 GElf_Sym sym; 138 139 if (mdb_lookup_by_obj(MDB_TGT_OBJ_EVERY, sym_name, &sym)) { 140 mdb_warn("can't find symbol %s", sym_name); 141 return (DCMD_ERR); 142 } 143 144 *bufp = mdb_alloc(sym.st_size, UM_SLEEP); 145 146 if (mdb_vread(*bufp, sym.st_size, sym.st_value) == -1) { 147 mdb_warn("can't read data for symbol %s", sym_name); 148 mdb_free(*bufp, sym.st_size); 149 return (DCMD_ERR); 150 } 151 152 return (DCMD_OK); 153 } 154 155 static int verbose; 156 157 static int 158 freelist_walk_init(mdb_walk_state_t *wsp) 159 { 160 if (wsp->walk_addr == NULL) { 161 mdb_warn("must supply starting address\n"); 162 return (WALK_ERR); 163 } 164 165 wsp->walk_data = 0; /* Index into the freelist */ 166 return (WALK_NEXT); 167 } 168 169 static int 170 freelist_walk_step(mdb_walk_state_t *wsp) 171 { 172 uint64_t entry; 173 uintptr_t number = (uintptr_t)wsp->walk_data; 174 char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID", 175 "INVALID", "INVALID", "INVALID", "INVALID" }; 176 int mapshift = SPA_MINBLOCKSHIFT; 177 178 if (mdb_vread(&entry, sizeof (entry), wsp->walk_addr) == -1) { 179 mdb_warn("failed to read freelist entry %p", wsp->walk_addr); 180 return (WALK_DONE); 181 } 182 wsp->walk_addr += sizeof (entry); 183 wsp->walk_data = (void *)(number + 1); 184 185 if (SM_DEBUG_DECODE(entry)) { 186 mdb_printf("DEBUG: %3u %10s: txg=%llu pass=%llu\n", 187 number, 188 ddata[SM_DEBUG_ACTION_DECODE(entry)], 189 SM_DEBUG_TXG_DECODE(entry), 190 SM_DEBUG_SYNCPASS_DECODE(entry)); 191 } else { 192 mdb_printf("Entry: %3u offsets=%08llx-%08llx type=%c " 193 "size=%06llx", number, 194 SM_OFFSET_DECODE(entry) << mapshift, 195 (SM_OFFSET_DECODE(entry) + SM_RUN_DECODE(entry)) << 196 mapshift, 197 SM_TYPE_DECODE(entry) == SM_ALLOC ? 'A' : 'F', 198 SM_RUN_DECODE(entry) << mapshift); 199 if (verbose) 200 mdb_printf(" (raw=%012llx)\n", entry); 201 mdb_printf("\n"); 202 } 203 return (WALK_NEXT); 204 } 205 206 207 static int 208 dataset_name(uintptr_t addr, char *buf) 209 { 210 static int gotid; 211 static mdb_ctf_id_t dd_id; 212 uintptr_t dd_parent; 213 char dd_myname[MAXNAMELEN]; 214 215 if (!gotid) { 216 if (mdb_ctf_lookup_by_name("struct dsl_dir", 217 &dd_id) == -1) { 218 mdb_warn("couldn't find struct dsl_dir"); 219 return (DCMD_ERR); 220 } 221 gotid = TRUE; 222 } 223 if (GETMEMBID(addr, &dd_id, dd_parent, dd_parent) || 224 GETMEMBID(addr, &dd_id, dd_myname, dd_myname)) { 225 return (DCMD_ERR); 226 } 227 228 if (dd_parent) { 229 if (dataset_name(dd_parent, buf)) 230 return (DCMD_ERR); 231 strcat(buf, "/"); 232 } 233 234 if (dd_myname[0]) 235 strcat(buf, dd_myname); 236 else 237 strcat(buf, "???"); 238 239 return (0); 240 } 241 242 static int 243 objset_name(uintptr_t addr, char *buf) 244 { 245 static int gotid; 246 static mdb_ctf_id_t osi_id, ds_id; 247 uintptr_t os_dsl_dataset; 248 char ds_snapname[MAXNAMELEN]; 249 uintptr_t ds_dir; 250 251 buf[0] = '\0'; 252 253 if (!gotid) { 254 if (mdb_ctf_lookup_by_name("struct objset_impl", 255 &osi_id) == -1) { 256 mdb_warn("couldn't find struct objset_impl"); 257 return (DCMD_ERR); 258 } 259 if (mdb_ctf_lookup_by_name("struct dsl_dataset", 260 &ds_id) == -1) { 261 mdb_warn("couldn't find struct dsl_dataset"); 262 return (DCMD_ERR); 263 } 264 265 gotid = TRUE; 266 } 267 268 if (GETMEMBID(addr, &osi_id, os_dsl_dataset, os_dsl_dataset)) 269 return (DCMD_ERR); 270 271 if (os_dsl_dataset == 0) { 272 strcat(buf, "mos"); 273 return (0); 274 } 275 276 if (GETMEMBID(os_dsl_dataset, &ds_id, ds_snapname, ds_snapname) || 277 GETMEMBID(os_dsl_dataset, &ds_id, ds_dir, ds_dir)) { 278 return (DCMD_ERR); 279 } 280 281 if (ds_dir && dataset_name(ds_dir, buf)) 282 return (DCMD_ERR); 283 284 if (ds_snapname[0]) { 285 strcat(buf, "@"); 286 strcat(buf, ds_snapname); 287 } 288 return (0); 289 } 290 291 static void 292 enum_lookup(char *out, size_t size, mdb_ctf_id_t id, int val, 293 const char *prefix) 294 { 295 const char *cp; 296 size_t len = strlen(prefix); 297 298 if ((cp = mdb_ctf_enum_name(id, val)) != NULL) { 299 if (strncmp(cp, prefix, len) == 0) 300 cp += len; 301 (void) strncpy(out, cp, size); 302 } else { 303 mdb_snprintf(out, size, "? (%d)", val); 304 } 305 } 306 307 /* ARGSUSED */ 308 static int 309 zio_pipeline(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 310 { 311 mdb_ctf_id_t pipe_enum; 312 int i; 313 char stage[1024]; 314 315 if (mdb_ctf_lookup_by_name("enum zio_stage", &pipe_enum) == -1) { 316 mdb_warn("Could not find enum zio_stage"); 317 return (DCMD_ERR); 318 } 319 320 for (i = 0; i < 32; i++) { 321 if (addr & (1U << i)) { 322 enum_lookup(stage, sizeof (stage), pipe_enum, i, 323 "ZIO_STAGE_"); 324 mdb_printf(" %s\n", stage); 325 } 326 } 327 328 return (DCMD_OK); 329 } 330 331 /* ARGSUSED */ 332 static int 333 zfs_params(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 334 { 335 /* 336 * This table can be approximately generated by running: 337 * egrep "^[a-z0-9_]+ [a-z0-9_]+( =.*)?;" *.c | cut -d ' ' -f 2 338 */ 339 static const char *params[] = { 340 "arc_reduce_dnlc_percent", 341 "zfs_arc_max", 342 "zfs_arc_min", 343 "arc_shrink_shift", 344 "zfs_mdcomp_disable", 345 "zfs_prefetch_disable", 346 "zfetch_max_streams", 347 "zfetch_min_sec_reap", 348 "zfetch_block_cap", 349 "zfetch_array_rd_sz", 350 "zfs_default_bs", 351 "zfs_default_ibs", 352 "metaslab_aliquot", 353 "reference_tracking_enable", 354 "reference_history", 355 "zio_taskq_threads", 356 "spa_max_replication_override", 357 "spa_mode", 358 "zfs_flags", 359 "zfs_txg_synctime", 360 "zfs_txg_timeout", 361 "zfs_write_limit_min", 362 "zfs_write_limit_max", 363 "zfs_write_limit_shift", 364 "zfs_write_limit_override", 365 "zfs_no_write_throttle", 366 "zfs_vdev_cache_max", 367 "zfs_vdev_cache_size", 368 "zfs_vdev_cache_bshift", 369 "vdev_mirror_shift", 370 "zfs_vdev_max_pending", 371 "zfs_vdev_min_pending", 372 "zfs_scrub_limit", 373 "zfs_vdev_time_shift", 374 "zfs_vdev_ramp_rate", 375 "zfs_vdev_aggregation_limit", 376 "fzap_default_block_shift", 377 "zfs_immediate_write_sz", 378 "zfs_read_chunk_size", 379 "zil_disable", 380 "zfs_nocacheflush", 381 "metaslab_gang_bang", 382 "zio_injection_enabled", 383 "zvol_immediate_write_sz", 384 }; 385 int i; 386 387 for (i = 0; i < sizeof (params) / sizeof (params[0]); i++) { 388 int sz; 389 uint64_t val64; 390 uint32_t *val32p = (uint32_t *)&val64; 391 392 sz = mdb_readvar(&val64, params[i]); 393 if (sz == 4) { 394 mdb_printf("%s = 0x%x\n", params[i], *val32p); 395 } else if (sz == 8) { 396 mdb_printf("%s = 0x%llx\n", params[i], val64); 397 } else { 398 mdb_warn("variable %s not found", params[i]); 399 } 400 } 401 402 return (DCMD_OK); 403 } 404 405 /* ARGSUSED */ 406 static int 407 blkptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 408 { 409 blkptr_t bp; 410 dmu_object_type_info_t *doti; 411 zio_compress_info_t *zct; 412 zio_checksum_info_t *zci; 413 int i; 414 char buf[MAXPATHLEN]; 415 416 if (mdb_vread(&bp, sizeof (blkptr_t), addr) == -1) { 417 mdb_warn("failed to read blkptr_t"); 418 return (DCMD_ERR); 419 } 420 421 if (read_symbol("dmu_ot", (void **)&doti) != DCMD_OK) 422 return (DCMD_ERR); 423 for (i = 0; i < DMU_OT_NUMTYPES; i++) { 424 mdb_readstr(buf, sizeof (buf), (uintptr_t)doti[i].ot_name); 425 doti[i].ot_name = local_strdup(buf); 426 } 427 428 if (read_symbol("zio_checksum_table", (void **)&zci) != DCMD_OK) 429 return (DCMD_ERR); 430 for (i = 0; i < ZIO_CHECKSUM_FUNCTIONS; i++) { 431 mdb_readstr(buf, sizeof (buf), (uintptr_t)zci[i].ci_name); 432 zci[i].ci_name = local_strdup(buf); 433 } 434 435 if (read_symbol("zio_compress_table", (void **)&zct) != DCMD_OK) 436 return (DCMD_ERR); 437 for (i = 0; i < ZIO_COMPRESS_FUNCTIONS; i++) { 438 mdb_readstr(buf, sizeof (buf), (uintptr_t)zct[i].ci_name); 439 zct[i].ci_name = local_strdup(buf); 440 } 441 442 /* 443 * Super-ick warning: This code is also duplicated in 444 * cmd/zdb.c . Yeah, I hate code replication, too. 445 */ 446 for (i = 0; i < BP_GET_NDVAS(&bp); i++) { 447 dva_t *dva = &bp.blk_dva[i]; 448 449 mdb_printf("DVA[%d]: vdev_id %lld / %llx\n", i, 450 DVA_GET_VDEV(dva), DVA_GET_OFFSET(dva)); 451 mdb_printf("DVA[%d]: GANG: %-5s GRID: %04x\t" 452 "ASIZE: %llx\n", i, DVA_GET_GANG(dva) ? "TRUE" : "FALSE", 453 DVA_GET_GRID(dva), DVA_GET_ASIZE(dva)); 454 mdb_printf("DVA[%d]: :%llu:%llx:%llx:%s%s%s%s\n", i, 455 DVA_GET_VDEV(dva), DVA_GET_OFFSET(dva), BP_GET_PSIZE(&bp), 456 BP_SHOULD_BYTESWAP(&bp) ? "e" : "", 457 !DVA_GET_GANG(dva) && BP_GET_LEVEL(&bp) != 0 ? "i" : "", 458 DVA_GET_GANG(dva) ? "g" : "", 459 BP_GET_COMPRESS(&bp) != 0 ? "d" : ""); 460 } 461 mdb_printf("LSIZE: %-16llx\t\tPSIZE: %llx\n", 462 BP_GET_LSIZE(&bp), BP_GET_PSIZE(&bp)); 463 mdb_printf("ENDIAN: %6s\t\t\t\t\tTYPE: %s\n", 464 BP_GET_BYTEORDER(&bp) ? "LITTLE" : "BIG", 465 doti[BP_GET_TYPE(&bp)].ot_name); 466 mdb_printf("BIRTH: %-16llx LEVEL: %-2d\tFILL: %llx\n", 467 bp.blk_birth, BP_GET_LEVEL(&bp), bp.blk_fill); 468 mdb_printf("CKFUNC: %-16s\t\tCOMP: %s\n", 469 zci[BP_GET_CHECKSUM(&bp)].ci_name, 470 zct[BP_GET_COMPRESS(&bp)].ci_name); 471 mdb_printf("CKSUM: %llx:%llx:%llx:%llx\n", 472 bp.blk_cksum.zc_word[0], 473 bp.blk_cksum.zc_word[1], 474 bp.blk_cksum.zc_word[2], 475 bp.blk_cksum.zc_word[3]); 476 477 return (DCMD_OK); 478 } 479 480 /* ARGSUSED */ 481 static int 482 dbuf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 483 { 484 mdb_ctf_id_t id; 485 dmu_buf_t db; 486 uintptr_t objset; 487 uint8_t level; 488 uint64_t blkid; 489 uint64_t holds; 490 char objectname[32]; 491 char blkidname[32]; 492 char path[MAXNAMELEN]; 493 494 if (DCMD_HDRSPEC(flags)) { 495 mdb_printf(" addr object lvl blkid holds os\n"); 496 } 497 498 if (mdb_ctf_lookup_by_name("struct dmu_buf_impl", &id) == -1) { 499 mdb_warn("couldn't find struct dmu_buf_impl_t"); 500 return (DCMD_ERR); 501 } 502 503 if (GETMEMBID(addr, &id, db_objset, objset) || 504 GETMEMBID(addr, &id, db, db) || 505 GETMEMBID(addr, &id, db_level, level) || 506 GETMEMBID(addr, &id, db_blkid, blkid)) { 507 return (WALK_ERR); 508 } 509 510 if (getrefcount(addr, &id, "db_holds", &holds)) { 511 return (WALK_ERR); 512 } 513 514 if (db.db_object == DMU_META_DNODE_OBJECT) 515 (void) strcpy(objectname, "mdn"); 516 else 517 (void) mdb_snprintf(objectname, sizeof (objectname), "%llx", 518 (u_longlong_t)db.db_object); 519 520 if (blkid == DB_BONUS_BLKID) 521 (void) strcpy(blkidname, "bonus"); 522 else 523 (void) mdb_snprintf(blkidname, sizeof (blkidname), "%llx", 524 (u_longlong_t)blkid); 525 526 if (objset_name(objset, path)) { 527 return (WALK_ERR); 528 } 529 530 mdb_printf("%p %8s %1u %9s %2llu %s\n", 531 addr, objectname, level, blkidname, holds, path); 532 533 return (DCMD_OK); 534 } 535 536 /* ARGSUSED */ 537 static int 538 dbuf_stats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 539 { 540 #define HISTOSZ 32 541 uintptr_t dbp; 542 dmu_buf_impl_t db; 543 dbuf_hash_table_t ht; 544 uint64_t bucket, ndbufs; 545 uint64_t histo[HISTOSZ]; 546 uint64_t histo2[HISTOSZ]; 547 int i, maxidx; 548 549 if (mdb_readvar(&ht, "dbuf_hash_table") == -1) { 550 mdb_warn("failed to read 'dbuf_hash_table'"); 551 return (DCMD_ERR); 552 } 553 554 for (i = 0; i < HISTOSZ; i++) { 555 histo[i] = 0; 556 histo2[i] = 0; 557 } 558 559 ndbufs = 0; 560 for (bucket = 0; bucket < ht.hash_table_mask+1; bucket++) { 561 int len; 562 563 if (mdb_vread(&dbp, sizeof (void *), 564 (uintptr_t)(ht.hash_table+bucket)) == -1) { 565 mdb_warn("failed to read hash bucket %u at %p", 566 bucket, ht.hash_table+bucket); 567 return (DCMD_ERR); 568 } 569 570 len = 0; 571 while (dbp != 0) { 572 if (mdb_vread(&db, sizeof (dmu_buf_impl_t), 573 dbp) == -1) { 574 mdb_warn("failed to read dbuf at %p", dbp); 575 return (DCMD_ERR); 576 } 577 dbp = (uintptr_t)db.db_hash_next; 578 for (i = MIN(len, HISTOSZ - 1); i >= 0; i--) 579 histo2[i]++; 580 len++; 581 ndbufs++; 582 } 583 584 if (len >= HISTOSZ) 585 len = HISTOSZ-1; 586 histo[len]++; 587 } 588 589 mdb_printf("hash table has %llu buckets, %llu dbufs " 590 "(avg %llu buckets/dbuf)\n", 591 ht.hash_table_mask+1, ndbufs, 592 (ht.hash_table_mask+1)/ndbufs); 593 594 mdb_printf("\n"); 595 maxidx = 0; 596 for (i = 0; i < HISTOSZ; i++) 597 if (histo[i] > 0) 598 maxidx = i; 599 mdb_printf("hash chain length number of buckets\n"); 600 for (i = 0; i <= maxidx; i++) 601 mdb_printf("%u %llu\n", i, histo[i]); 602 603 mdb_printf("\n"); 604 maxidx = 0; 605 for (i = 0; i < HISTOSZ; i++) 606 if (histo2[i] > 0) 607 maxidx = i; 608 mdb_printf("hash chain depth number of dbufs\n"); 609 for (i = 0; i <= maxidx; i++) 610 mdb_printf("%u or more %llu %llu%%\n", 611 i, histo2[i], histo2[i]*100/ndbufs); 612 613 614 return (DCMD_OK); 615 } 616 617 typedef struct dbufs_data { 618 mdb_ctf_id_t id; 619 uint64_t objset; 620 uint64_t object; 621 uint64_t level; 622 uint64_t blkid; 623 char *osname; 624 } dbufs_data_t; 625 626 #define DBUFS_UNSET (0xbaddcafedeadbeefULL) 627 628 /* ARGSUSED */ 629 static int 630 dbufs_cb(uintptr_t addr, const void *unknown, void *arg) 631 { 632 dbufs_data_t *data = arg; 633 uintptr_t objset; 634 dmu_buf_t db; 635 uint8_t level; 636 uint64_t blkid; 637 char osname[MAXNAMELEN]; 638 639 if (GETMEMBID(addr, &data->id, db_objset, objset) || 640 GETMEMBID(addr, &data->id, db, db) || 641 GETMEMBID(addr, &data->id, db_level, level) || 642 GETMEMBID(addr, &data->id, db_blkid, blkid)) { 643 return (WALK_ERR); 644 } 645 646 if ((data->objset == DBUFS_UNSET || data->objset == objset) && 647 (data->osname == NULL || (objset_name(objset, osname) == 0 && 648 strcmp(data->osname, osname) == 0)) && 649 (data->object == DBUFS_UNSET || data->object == db.db_object) && 650 (data->level == DBUFS_UNSET || data->level == level) && 651 (data->blkid == DBUFS_UNSET || data->blkid == blkid)) { 652 mdb_printf("%#lr\n", addr); 653 } 654 return (WALK_NEXT); 655 } 656 657 /* ARGSUSED */ 658 static int 659 dbufs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 660 { 661 dbufs_data_t data; 662 char *object = NULL; 663 char *blkid = NULL; 664 665 data.objset = data.object = data.level = data.blkid = DBUFS_UNSET; 666 data.osname = NULL; 667 668 if (mdb_getopts(argc, argv, 669 'O', MDB_OPT_UINT64, &data.objset, 670 'n', MDB_OPT_STR, &data.osname, 671 'o', MDB_OPT_STR, &object, 672 'l', MDB_OPT_UINT64, &data.level, 673 'b', MDB_OPT_STR, &blkid) != argc) { 674 return (DCMD_USAGE); 675 } 676 677 if (object) { 678 if (strcmp(object, "mdn") == 0) { 679 data.object = DMU_META_DNODE_OBJECT; 680 } else { 681 data.object = mdb_strtoull(object); 682 } 683 } 684 685 if (blkid) { 686 if (strcmp(blkid, "bonus") == 0) { 687 data.blkid = DB_BONUS_BLKID; 688 } else { 689 data.blkid = mdb_strtoull(blkid); 690 } 691 } 692 693 if (mdb_ctf_lookup_by_name("struct dmu_buf_impl", &data.id) == -1) { 694 mdb_warn("couldn't find struct dmu_buf_impl_t"); 695 return (DCMD_ERR); 696 } 697 698 if (mdb_walk("dmu_buf_impl_t", dbufs_cb, &data) != 0) { 699 mdb_warn("can't walk dbufs"); 700 return (DCMD_ERR); 701 } 702 703 return (DCMD_OK); 704 } 705 706 typedef struct abuf_find_data { 707 dva_t dva; 708 mdb_ctf_id_t id; 709 } abuf_find_data_t; 710 711 /* ARGSUSED */ 712 static int 713 abuf_find_cb(uintptr_t addr, const void *unknown, void *arg) 714 { 715 abuf_find_data_t *data = arg; 716 dva_t dva; 717 718 if (GETMEMBID(addr, &data->id, b_dva, dva)) { 719 return (WALK_ERR); 720 } 721 722 if (dva.dva_word[0] == data->dva.dva_word[0] && 723 dva.dva_word[1] == data->dva.dva_word[1]) { 724 mdb_printf("%#lr\n", addr); 725 } 726 return (WALK_NEXT); 727 } 728 729 /* ARGSUSED */ 730 static int 731 abuf_find(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 732 { 733 abuf_find_data_t data; 734 GElf_Sym sym; 735 int i; 736 const char *syms[] = { 737 "ARC_mru", 738 "ARC_mru_ghost", 739 "ARC_mfu", 740 "ARC_mfu_ghost", 741 }; 742 743 if (argc != 2) 744 return (DCMD_USAGE); 745 746 for (i = 0; i < 2; i ++) { 747 switch (argv[i].a_type) { 748 case MDB_TYPE_STRING: 749 data.dva.dva_word[i] = mdb_strtoull(argv[i].a_un.a_str); 750 break; 751 case MDB_TYPE_IMMEDIATE: 752 data.dva.dva_word[i] = argv[i].a_un.a_val; 753 break; 754 default: 755 return (DCMD_USAGE); 756 } 757 } 758 759 if (mdb_ctf_lookup_by_name("struct arc_buf_hdr", &data.id) == -1) { 760 mdb_warn("couldn't find struct arc_buf_hdr"); 761 return (DCMD_ERR); 762 } 763 764 for (i = 0; i < sizeof (syms) / sizeof (syms[0]); i++) { 765 if (mdb_lookup_by_name(syms[i], &sym)) { 766 mdb_warn("can't find symbol %s", syms[i]); 767 return (DCMD_ERR); 768 } 769 770 if (mdb_pwalk("list", abuf_find_cb, &data, sym.st_value) != 0) { 771 mdb_warn("can't walk %s", syms[i]); 772 return (DCMD_ERR); 773 } 774 } 775 776 return (DCMD_OK); 777 } 778 779 /*ARGSUSED*/ 780 static int 781 arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 782 { 783 kstat_named_t *stats; 784 GElf_Sym sym; 785 int nstats, i; 786 uint_t opt_a = FALSE; 787 uint_t opt_b = FALSE; 788 uint_t shift = 0; 789 const char *suffix; 790 791 static const char *bytestats[] = { 792 "p", "c", "c_min", "c_max", "size", NULL 793 }; 794 795 static const char *extras[] = { 796 "arc_no_grow", "arc_tempreserve", 797 "arc_meta_used", "arc_meta_limit", "arc_meta_max", 798 NULL 799 }; 800 801 if (mdb_lookup_by_name("arc_stats", &sym) == -1) { 802 mdb_warn("failed to find 'arc_stats'"); 803 return (DCMD_ERR); 804 } 805 806 stats = mdb_zalloc(sym.st_size, UM_SLEEP | UM_GC); 807 808 if (mdb_vread(stats, sym.st_size, sym.st_value) == -1) { 809 mdb_warn("couldn't read 'arc_stats' at %p", sym.st_value); 810 return (DCMD_ERR); 811 } 812 813 nstats = sym.st_size / sizeof (kstat_named_t); 814 815 /* NB: -a / opt_a are ignored for backwards compatability */ 816 if (mdb_getopts(argc, argv, 817 'a', MDB_OPT_SETBITS, TRUE, &opt_a, 818 'b', MDB_OPT_SETBITS, TRUE, &opt_b, 819 'k', MDB_OPT_SETBITS, 10, &shift, 820 'm', MDB_OPT_SETBITS, 20, &shift, 821 'g', MDB_OPT_SETBITS, 30, &shift, 822 NULL) != argc) 823 return (DCMD_USAGE); 824 825 if (!opt_b && !shift) 826 shift = 20; 827 828 switch (shift) { 829 case 0: 830 suffix = "B"; 831 break; 832 case 10: 833 suffix = "KB"; 834 break; 835 case 20: 836 suffix = "MB"; 837 break; 838 case 30: 839 suffix = "GB"; 840 break; 841 default: 842 suffix = "XX"; 843 } 844 845 for (i = 0; i < nstats; i++) { 846 int j; 847 boolean_t bytes = B_FALSE; 848 849 for (j = 0; bytestats[j]; j++) { 850 if (strcmp(stats[i].name, bytestats[j]) == 0) { 851 bytes = B_TRUE; 852 break; 853 } 854 } 855 856 if (bytes) { 857 mdb_printf("%-25s = %9llu %s\n", stats[i].name, 858 stats[i].value.ui64 >> shift, suffix); 859 } else { 860 mdb_printf("%-25s = %9llu\n", stats[i].name, 861 stats[i].value.ui64); 862 } 863 } 864 865 for (i = 0; extras[i]; i++) { 866 uint64_t buf; 867 868 if (mdb_lookup_by_name(extras[i], &sym) == -1) { 869 mdb_warn("failed to find '%s'", extras[i]); 870 return (DCMD_ERR); 871 } 872 873 if (sym.st_size != sizeof (uint64_t) && 874 sym.st_size != sizeof (uint32_t)) { 875 mdb_warn("expected scalar for variable '%s'\n", 876 extras[i]); 877 return (DCMD_ERR); 878 } 879 880 if (mdb_vread(&buf, sym.st_size, sym.st_value) == -1) { 881 mdb_warn("couldn't read '%s'", extras[i]); 882 return (DCMD_ERR); 883 } 884 885 mdb_printf("%-25s = ", extras[i]); 886 887 /* NB: all the 64-bit extras happen to be byte counts */ 888 if (sym.st_size == sizeof (uint64_t)) 889 mdb_printf("%9llu %s\n", buf >> shift, suffix); 890 891 if (sym.st_size == sizeof (uint32_t)) 892 mdb_printf("%9d\n", *((uint32_t *)&buf)); 893 } 894 return (DCMD_OK); 895 } 896 897 /* 898 * ::spa 899 * 900 * -c Print configuration information as well 901 * -v Print vdev state 902 * -e Print vdev error stats 903 * 904 * Print a summarized spa_t. When given no arguments, prints out a table of all 905 * active pools on the system. 906 */ 907 /* ARGSUSED */ 908 static int 909 spa_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 910 { 911 spa_t spa; 912 char poolname[MAXNAMELEN]; 913 const char *statetab[] = { "ACTIVE", "EXPORTED", "DESTROYED", 914 "SPARE", "UNINIT", "IOFAILURE", "UNAVAIL" }; 915 const char *state; 916 int config = FALSE; 917 int vdevs = FALSE; 918 int errors = FALSE; 919 920 if (mdb_getopts(argc, argv, 921 'c', MDB_OPT_SETBITS, TRUE, &config, 922 'v', MDB_OPT_SETBITS, TRUE, &vdevs, 923 'e', MDB_OPT_SETBITS, TRUE, &errors, 924 NULL) != argc) 925 return (DCMD_USAGE); 926 927 if (!(flags & DCMD_ADDRSPEC)) { 928 if (mdb_walk_dcmd("spa", "spa", argc, argv) == -1) { 929 mdb_warn("can't walk spa"); 930 return (DCMD_ERR); 931 } 932 933 return (DCMD_OK); 934 } 935 936 if (flags & DCMD_PIPE_OUT) { 937 mdb_printf("%#lr\n", addr); 938 return (DCMD_OK); 939 } 940 941 if (DCMD_HDRSPEC(flags)) 942 mdb_printf("%<u>%-?s %9s %-*s%</u>\n", "ADDR", "STATE", 943 sizeof (uintptr_t) == 4 ? 60 : 52, "NAME"); 944 945 if (mdb_vread(&spa, sizeof (spa), addr) == -1) { 946 mdb_warn("failed to read spa_t at %p", addr); 947 return (DCMD_ERR); 948 } 949 950 if (mdb_readstr(poolname, sizeof (poolname), (uintptr_t)spa.spa_name) 951 == -1) { 952 mdb_warn("failed to read pool name at %p", spa.spa_name); 953 return (DCMD_ERR); 954 } 955 956 if (spa.spa_state < 0 || spa.spa_state > POOL_STATE_UNAVAIL) 957 state = "UNKNOWN"; 958 else 959 state = statetab[spa.spa_state]; 960 961 mdb_printf("%0?p %9s %s\n", addr, state, poolname); 962 963 if (config) { 964 mdb_printf("\n"); 965 mdb_inc_indent(4); 966 if (mdb_call_dcmd("spa_config", addr, flags, 0, 967 NULL) != DCMD_OK) 968 return (DCMD_ERR); 969 mdb_dec_indent(4); 970 } 971 972 if (vdevs || errors) { 973 mdb_arg_t v; 974 975 v.a_type = MDB_TYPE_STRING; 976 v.a_un.a_str = "-e"; 977 978 mdb_printf("\n"); 979 mdb_inc_indent(4); 980 if (mdb_call_dcmd("spa_vdevs", addr, flags, errors ? 1 : 0, 981 &v) != DCMD_OK) 982 return (DCMD_ERR); 983 mdb_dec_indent(4); 984 } 985 986 return (DCMD_OK); 987 } 988 989 /* 990 * ::spa_config 991 * 992 * Given a spa_t, print the configuration information stored in spa_config. 993 * Since it's just an nvlist, format it as an indented list of name=value pairs. 994 * We simply read the value of spa_config and pass off to ::nvlist. 995 */ 996 /* ARGSUSED */ 997 static int 998 spa_print_config(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 999 { 1000 spa_t spa; 1001 1002 if (argc != 0 || !(flags & DCMD_ADDRSPEC)) 1003 return (DCMD_USAGE); 1004 1005 if (mdb_vread(&spa, sizeof (spa), addr) == -1) { 1006 mdb_warn("failed to read spa_t at %p", addr); 1007 return (DCMD_ERR); 1008 } 1009 1010 if (spa.spa_config == NULL) { 1011 mdb_printf("(none)\n"); 1012 return (DCMD_OK); 1013 } 1014 1015 return (mdb_call_dcmd("nvlist", (uintptr_t)spa.spa_config, flags, 1016 0, NULL)); 1017 } 1018 1019 /* 1020 * ::vdev 1021 * 1022 * Print out a summarized vdev_t, in the following form: 1023 * 1024 * ADDR STATE AUX DESC 1025 * fffffffbcde23df0 HEALTHY - /dev/dsk/c0t0d0 1026 * 1027 * If '-r' is specified, recursively visit all children. 1028 * 1029 * With '-e', the statistics associated with the vdev are printed as well. 1030 */ 1031 static int 1032 do_print_vdev(uintptr_t addr, int flags, int depth, int stats, 1033 int recursive) 1034 { 1035 vdev_t vdev; 1036 char desc[MAXNAMELEN]; 1037 int c, children; 1038 uintptr_t *child; 1039 const char *state, *aux; 1040 1041 if (mdb_vread(&vdev, sizeof (vdev), (uintptr_t)addr) == -1) { 1042 mdb_warn("failed to read vdev_t at %p\n", (uintptr_t)addr); 1043 return (DCMD_ERR); 1044 } 1045 1046 if (flags & DCMD_PIPE_OUT) { 1047 mdb_printf("%#lr", addr); 1048 } else { 1049 if (vdev.vdev_path != NULL) { 1050 if (mdb_readstr(desc, sizeof (desc), 1051 (uintptr_t)vdev.vdev_path) == -1) { 1052 mdb_warn("failed to read vdev_path at %p\n", 1053 vdev.vdev_path); 1054 return (DCMD_ERR); 1055 } 1056 } else if (vdev.vdev_ops != NULL) { 1057 vdev_ops_t ops; 1058 if (mdb_vread(&ops, sizeof (ops), 1059 (uintptr_t)vdev.vdev_ops) == -1) { 1060 mdb_warn("failed to read vdev_ops at %p\n", 1061 vdev.vdev_ops); 1062 return (DCMD_ERR); 1063 } 1064 (void) strcpy(desc, ops.vdev_op_type); 1065 } else { 1066 (void) strcpy(desc, "<unknown>"); 1067 } 1068 1069 if (depth == 0 && DCMD_HDRSPEC(flags)) 1070 mdb_printf("%<u>%-?s %-9s %-12s %-*s%</u>\n", 1071 "ADDR", "STATE", "AUX", 1072 sizeof (uintptr_t) == 4 ? 43 : 35, 1073 "DESCRIPTION"); 1074 1075 mdb_printf("%0?p ", addr); 1076 1077 switch (vdev.vdev_state) { 1078 case VDEV_STATE_CLOSED: 1079 state = "CLOSED"; 1080 break; 1081 case VDEV_STATE_OFFLINE: 1082 state = "OFFLINE"; 1083 break; 1084 case VDEV_STATE_CANT_OPEN: 1085 state = "CANT_OPEN"; 1086 break; 1087 case VDEV_STATE_DEGRADED: 1088 state = "DEGRADED"; 1089 break; 1090 case VDEV_STATE_HEALTHY: 1091 state = "HEALTHY"; 1092 break; 1093 case VDEV_STATE_REMOVED: 1094 state = "REMOVED"; 1095 break; 1096 case VDEV_STATE_FAULTED: 1097 state = "FAULTED"; 1098 break; 1099 default: 1100 state = "UNKNOWN"; 1101 break; 1102 } 1103 1104 switch (vdev.vdev_stat.vs_aux) { 1105 case VDEV_AUX_NONE: 1106 aux = "-"; 1107 break; 1108 case VDEV_AUX_OPEN_FAILED: 1109 aux = "OPEN_FAILED"; 1110 break; 1111 case VDEV_AUX_CORRUPT_DATA: 1112 aux = "CORRUPT_DATA"; 1113 break; 1114 case VDEV_AUX_NO_REPLICAS: 1115 aux = "NO_REPLICAS"; 1116 break; 1117 case VDEV_AUX_BAD_GUID_SUM: 1118 aux = "BAD_GUID_SUM"; 1119 break; 1120 case VDEV_AUX_TOO_SMALL: 1121 aux = "TOO_SMALL"; 1122 break; 1123 case VDEV_AUX_BAD_LABEL: 1124 aux = "BAD_LABEL"; 1125 break; 1126 default: 1127 aux = "UNKNOWN"; 1128 break; 1129 } 1130 1131 mdb_printf("%-9s %-12s %*s%s\n", state, aux, depth, "", desc); 1132 1133 if (stats) { 1134 vdev_stat_t *vs = &vdev.vdev_stat; 1135 int i; 1136 1137 mdb_inc_indent(4); 1138 mdb_printf("\n"); 1139 mdb_printf("%<u> %12s %12s %12s %12s " 1140 "%12s%</u>\n", "READ", "WRITE", "FREE", "CLAIM", 1141 "IOCTL"); 1142 mdb_printf("OPS "); 1143 for (i = 1; i < ZIO_TYPES; i++) 1144 mdb_printf("%11#llx%s", vs->vs_ops[i], 1145 i == ZIO_TYPES - 1 ? "" : " "); 1146 mdb_printf("\n"); 1147 mdb_printf("BYTES "); 1148 for (i = 1; i < ZIO_TYPES; i++) 1149 mdb_printf("%11#llx%s", vs->vs_bytes[i], 1150 i == ZIO_TYPES - 1 ? "" : " "); 1151 1152 1153 mdb_printf("\n"); 1154 mdb_printf("EREAD %10#llx\n", vs->vs_read_errors); 1155 mdb_printf("EWRITE %10#llx\n", vs->vs_write_errors); 1156 mdb_printf("ECKSUM %10#llx\n", 1157 vs->vs_checksum_errors); 1158 mdb_dec_indent(4); 1159 } 1160 1161 if (stats) 1162 mdb_printf("\n"); 1163 } 1164 1165 children = vdev.vdev_children; 1166 1167 if (children == 0 || !recursive) 1168 return (DCMD_OK); 1169 1170 child = mdb_alloc(children * sizeof (void *), UM_SLEEP | UM_GC); 1171 if (mdb_vread(child, children * sizeof (void *), 1172 (uintptr_t)vdev.vdev_child) == -1) { 1173 mdb_warn("failed to read vdev children at %p", vdev.vdev_child); 1174 return (DCMD_ERR); 1175 } 1176 1177 for (c = 0; c < children; c++) { 1178 if (do_print_vdev(child[c], flags, depth + 2, stats, 1179 recursive)) 1180 return (DCMD_ERR); 1181 } 1182 1183 return (DCMD_OK); 1184 } 1185 1186 static int 1187 vdev_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1188 { 1189 int recursive = FALSE; 1190 int stats = FALSE; 1191 1192 if (mdb_getopts(argc, argv, 1193 'r', MDB_OPT_SETBITS, TRUE, &recursive, 1194 'e', MDB_OPT_SETBITS, TRUE, &stats, 1195 NULL) != argc) 1196 return (DCMD_USAGE); 1197 1198 if (!(flags & DCMD_ADDRSPEC)) { 1199 mdb_warn("no vdev_t address given\n"); 1200 return (DCMD_ERR); 1201 } 1202 1203 return (do_print_vdev(addr, flags, 0, stats, recursive)); 1204 } 1205 1206 typedef struct metaslab_walk_data { 1207 uint64_t mw_numvdevs; 1208 uintptr_t *mw_vdevs; 1209 int mw_curvdev; 1210 uint64_t mw_nummss; 1211 uintptr_t *mw_mss; 1212 int mw_curms; 1213 } metaslab_walk_data_t; 1214 1215 static int 1216 metaslab_walk_step(mdb_walk_state_t *wsp) 1217 { 1218 metaslab_walk_data_t *mw = wsp->walk_data; 1219 metaslab_t ms; 1220 uintptr_t msp; 1221 1222 if (mw->mw_curvdev >= mw->mw_numvdevs) 1223 return (WALK_DONE); 1224 1225 if (mw->mw_mss == NULL) { 1226 uintptr_t mssp; 1227 uintptr_t vdevp; 1228 1229 ASSERT(mw->mw_curms == 0); 1230 ASSERT(mw->mw_nummss == 0); 1231 1232 vdevp = mw->mw_vdevs[mw->mw_curvdev]; 1233 if (GETMEMB(vdevp, struct vdev, vdev_ms, mssp) || 1234 GETMEMB(vdevp, struct vdev, vdev_ms_count, mw->mw_nummss)) { 1235 return (WALK_ERR); 1236 } 1237 1238 mw->mw_mss = mdb_alloc(mw->mw_nummss * sizeof (void*), 1239 UM_SLEEP | UM_GC); 1240 if (mdb_vread(mw->mw_mss, mw->mw_nummss * sizeof (void*), 1241 mssp) == -1) { 1242 mdb_warn("failed to read vdev_ms at %p", mssp); 1243 return (WALK_ERR); 1244 } 1245 } 1246 1247 if (mw->mw_curms >= mw->mw_nummss) { 1248 mw->mw_mss = NULL; 1249 mw->mw_curms = 0; 1250 mw->mw_nummss = 0; 1251 mw->mw_curvdev++; 1252 return (WALK_NEXT); 1253 } 1254 1255 msp = mw->mw_mss[mw->mw_curms]; 1256 if (mdb_vread(&ms, sizeof (metaslab_t), msp) == -1) { 1257 mdb_warn("failed to read metaslab_t at %p", msp); 1258 return (WALK_ERR); 1259 } 1260 1261 mw->mw_curms++; 1262 1263 return (wsp->walk_callback(msp, &ms, wsp->walk_cbdata)); 1264 } 1265 1266 /* ARGSUSED */ 1267 static int 1268 metaslab_walk_init(mdb_walk_state_t *wsp) 1269 { 1270 metaslab_walk_data_t *mw; 1271 uintptr_t root_vdevp; 1272 uintptr_t childp; 1273 1274 if (wsp->walk_addr == NULL) { 1275 mdb_warn("must supply address of spa_t\n"); 1276 return (WALK_ERR); 1277 } 1278 1279 mw = mdb_zalloc(sizeof (metaslab_walk_data_t), UM_SLEEP | UM_GC); 1280 1281 if (GETMEMB(wsp->walk_addr, struct spa, spa_root_vdev, root_vdevp) || 1282 GETMEMB(root_vdevp, struct vdev, vdev_children, mw->mw_numvdevs) || 1283 GETMEMB(root_vdevp, struct vdev, vdev_child, childp)) { 1284 return (DCMD_ERR); 1285 } 1286 1287 mw->mw_vdevs = mdb_alloc(mw->mw_numvdevs * sizeof (void *), 1288 UM_SLEEP | UM_GC); 1289 if (mdb_vread(mw->mw_vdevs, mw->mw_numvdevs * sizeof (void *), 1290 childp) == -1) { 1291 mdb_warn("failed to read root vdev children at %p", childp); 1292 return (DCMD_ERR); 1293 } 1294 1295 wsp->walk_data = mw; 1296 1297 return (WALK_NEXT); 1298 } 1299 1300 typedef struct mdb_spa { 1301 uintptr_t spa_dsl_pool; 1302 uintptr_t spa_root_vdev; 1303 } mdb_spa_t; 1304 1305 typedef struct mdb_dsl_dir { 1306 uintptr_t dd_phys; 1307 uint64_t dd_used_bytes; 1308 int64_t dd_space_towrite[TXG_SIZE]; 1309 } mdb_dsl_dir_t; 1310 1311 typedef struct mdb_dsl_dir_phys { 1312 uint64_t dd_used_bytes; 1313 uint64_t dd_compressed_bytes; 1314 uint64_t dd_uncompressed_bytes; 1315 } mdb_dsl_dir_phys_t; 1316 1317 typedef struct mdb_vdev { 1318 uintptr_t vdev_parent; 1319 uintptr_t vdev_ms; 1320 uint64_t vdev_ms_count; 1321 vdev_stat_t vdev_stat; 1322 } mdb_vdev_t; 1323 1324 typedef struct mdb_metaslab { 1325 space_map_t ms_allocmap[TXG_SIZE]; 1326 space_map_t ms_freemap[TXG_SIZE]; 1327 space_map_t ms_map; 1328 space_map_obj_t ms_smo; 1329 space_map_obj_t ms_smo_syncing; 1330 } mdb_metaslab_t; 1331 1332 typedef struct space_data { 1333 uint64_t ms_allocmap[TXG_SIZE]; 1334 uint64_t ms_freemap[TXG_SIZE]; 1335 uint64_t ms_map; 1336 uint64_t avail; 1337 uint64_t nowavail; 1338 } space_data_t; 1339 1340 /* ARGSUSED */ 1341 static int 1342 space_cb(uintptr_t addr, const void *unknown, void *arg) 1343 { 1344 space_data_t *sd = arg; 1345 mdb_metaslab_t ms; 1346 1347 if (GETMEMB(addr, struct metaslab, ms_allocmap, ms.ms_allocmap) || 1348 GETMEMB(addr, struct metaslab, ms_freemap, ms.ms_freemap) || 1349 GETMEMB(addr, struct metaslab, ms_map, ms.ms_map) || 1350 GETMEMB(addr, struct metaslab, ms_smo, ms.ms_smo) || 1351 GETMEMB(addr, struct metaslab, ms_smo_syncing, ms.ms_smo_syncing)) { 1352 return (WALK_ERR); 1353 } 1354 1355 sd->ms_allocmap[0] += ms.ms_allocmap[0].sm_space; 1356 sd->ms_allocmap[1] += ms.ms_allocmap[1].sm_space; 1357 sd->ms_allocmap[2] += ms.ms_allocmap[2].sm_space; 1358 sd->ms_allocmap[3] += ms.ms_allocmap[3].sm_space; 1359 sd->ms_freemap[0] += ms.ms_freemap[0].sm_space; 1360 sd->ms_freemap[1] += ms.ms_freemap[1].sm_space; 1361 sd->ms_freemap[2] += ms.ms_freemap[2].sm_space; 1362 sd->ms_freemap[3] += ms.ms_freemap[3].sm_space; 1363 sd->ms_map += ms.ms_map.sm_space; 1364 sd->avail += ms.ms_map.sm_size - ms.ms_smo.smo_alloc; 1365 sd->nowavail += ms.ms_map.sm_size - ms.ms_smo_syncing.smo_alloc; 1366 1367 return (WALK_NEXT); 1368 } 1369 1370 /* 1371 * ::spa_space [-b] 1372 * 1373 * Given a spa_t, print out it's on-disk space usage and in-core 1374 * estimates of future usage. If -b is given, print space in bytes. 1375 * Otherwise print in megabytes. 1376 */ 1377 /* ARGSUSED */ 1378 static int 1379 spa_space(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1380 { 1381 mdb_spa_t spa; 1382 uintptr_t dp_root_dir; 1383 mdb_dsl_dir_t dd; 1384 mdb_dsl_dir_phys_t dsp; 1385 uint64_t children; 1386 uintptr_t childaddr; 1387 space_data_t sd; 1388 int shift = 20; 1389 char *suffix = "M"; 1390 int bits = FALSE; 1391 1392 if (mdb_getopts(argc, argv, 'b', MDB_OPT_SETBITS, TRUE, &bits, NULL) != 1393 argc) 1394 return (DCMD_USAGE); 1395 if (!(flags & DCMD_ADDRSPEC)) 1396 return (DCMD_USAGE); 1397 1398 if (bits) { 1399 shift = 0; 1400 suffix = ""; 1401 } 1402 1403 if (GETMEMB(addr, struct spa, spa_dsl_pool, spa.spa_dsl_pool) || 1404 GETMEMB(addr, struct spa, spa_root_vdev, spa.spa_root_vdev) || 1405 GETMEMB(spa.spa_root_vdev, struct vdev, vdev_children, children) || 1406 GETMEMB(spa.spa_root_vdev, struct vdev, vdev_child, childaddr) || 1407 GETMEMB(spa.spa_dsl_pool, struct dsl_pool, 1408 dp_root_dir, dp_root_dir) || 1409 GETMEMB(dp_root_dir, struct dsl_dir, dd_phys, dd.dd_phys) || 1410 GETMEMB(dp_root_dir, struct dsl_dir, 1411 dd_used_bytes, dd.dd_used_bytes) || 1412 GETMEMB(dp_root_dir, struct dsl_dir, 1413 dd_space_towrite, dd.dd_space_towrite) || 1414 GETMEMB(dd.dd_phys, struct dsl_dir_phys, 1415 dd_used_bytes, dsp.dd_used_bytes) || 1416 GETMEMB(dd.dd_phys, struct dsl_dir_phys, 1417 dd_compressed_bytes, dsp.dd_compressed_bytes) || 1418 GETMEMB(dd.dd_phys, struct dsl_dir_phys, 1419 dd_uncompressed_bytes, dsp.dd_uncompressed_bytes)) { 1420 return (DCMD_ERR); 1421 } 1422 1423 mdb_printf("dd_space_towrite = %llu%s %llu%s %llu%s %llu%s\n", 1424 dd.dd_space_towrite[0] >> shift, suffix, 1425 dd.dd_space_towrite[1] >> shift, suffix, 1426 dd.dd_space_towrite[2] >> shift, suffix, 1427 dd.dd_space_towrite[3] >> shift, suffix); 1428 mdb_printf("dd_used_bytes = %llu%s\n", 1429 dd.dd_used_bytes >> shift, suffix); 1430 1431 mdb_printf("dd_phys.dd_used_bytes = %llu%s\n", 1432 dsp.dd_used_bytes >> shift, suffix); 1433 mdb_printf("dd_phys.dd_compressed_bytes = %llu%s\n", 1434 dsp.dd_compressed_bytes >> shift, suffix); 1435 mdb_printf("dd_phys.dd_uncompressed_bytes = %llu%s\n", 1436 dsp.dd_uncompressed_bytes >> shift, suffix); 1437 1438 bzero(&sd, sizeof (sd)); 1439 if (mdb_pwalk("metaslab", space_cb, &sd, addr) != 0) { 1440 mdb_warn("can't walk metaslabs"); 1441 return (DCMD_ERR); 1442 } 1443 1444 mdb_printf("ms_allocmap = %llu%s %llu%s %llu%s %llu%s\n", 1445 sd.ms_allocmap[0] >> shift, suffix, 1446 sd.ms_allocmap[1] >> shift, suffix, 1447 sd.ms_allocmap[2] >> shift, suffix, 1448 sd.ms_allocmap[3] >> shift, suffix); 1449 mdb_printf("ms_freemap = %llu%s %llu%s %llu%s %llu%s\n", 1450 sd.ms_freemap[0] >> shift, suffix, 1451 sd.ms_freemap[1] >> shift, suffix, 1452 sd.ms_freemap[2] >> shift, suffix, 1453 sd.ms_freemap[3] >> shift, suffix); 1454 mdb_printf("ms_map = %llu%s\n", sd.ms_map >> shift, suffix); 1455 mdb_printf("last synced avail = %llu%s\n", sd.avail >> shift, suffix); 1456 mdb_printf("current syncing avail = %llu%s\n", 1457 sd.nowavail >> shift, suffix); 1458 1459 return (DCMD_OK); 1460 } 1461 1462 /* 1463 * ::spa_verify 1464 * 1465 * Given a spa_t, verify that that the pool is self-consistent. 1466 * Currently, it only checks to make sure that the vdev tree exists. 1467 */ 1468 /* ARGSUSED */ 1469 static int 1470 spa_verify(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1471 { 1472 spa_t spa; 1473 1474 if (argc != 0 || !(flags & DCMD_ADDRSPEC)) 1475 return (DCMD_USAGE); 1476 1477 if (mdb_vread(&spa, sizeof (spa), addr) == -1) { 1478 mdb_warn("failed to read spa_t at %p", addr); 1479 return (DCMD_ERR); 1480 } 1481 1482 if (spa.spa_root_vdev == NULL) { 1483 mdb_printf("no vdev tree present\n"); 1484 return (DCMD_OK); 1485 } 1486 1487 return (DCMD_OK); 1488 } 1489 1490 /* 1491 * ::spa_vdevs 1492 * 1493 * -e Include error stats 1494 * 1495 * Print out a summarized list of vdevs for the given spa_t. 1496 * This is accomplished by invoking "::vdev -re" on the root vdev. 1497 */ 1498 /* ARGSUSED */ 1499 static int 1500 spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1501 { 1502 spa_t spa; 1503 mdb_arg_t v; 1504 int errors = FALSE; 1505 1506 if (mdb_getopts(argc, argv, 1507 'e', MDB_OPT_SETBITS, TRUE, &errors, 1508 NULL) != argc) 1509 return (DCMD_USAGE); 1510 1511 if (!(flags & DCMD_ADDRSPEC)) 1512 return (DCMD_USAGE); 1513 1514 if (mdb_vread(&spa, sizeof (spa), addr) == -1) { 1515 mdb_warn("failed to read spa_t at %p", addr); 1516 return (DCMD_ERR); 1517 } 1518 1519 /* 1520 * Unitialized spa_t structures can have a NULL root vdev. 1521 */ 1522 if (spa.spa_root_vdev == NULL) { 1523 mdb_printf("no associated vdevs\n"); 1524 return (DCMD_OK); 1525 } 1526 1527 v.a_type = MDB_TYPE_STRING; 1528 v.a_un.a_str = errors ? "-re" : "-r"; 1529 1530 return (mdb_call_dcmd("vdev", (uintptr_t)spa.spa_root_vdev, 1531 flags, 1, &v)); 1532 } 1533 1534 /* 1535 * ::zio 1536 * 1537 * Print a summary of zio_t and all its children. This is intended to display a 1538 * zio tree, and hence we only pick the most important pieces of information for 1539 * the main summary. More detailed information can always be found by doing a 1540 * '::print zio' on the underlying zio_t. The columns we display are: 1541 * 1542 * ADDRESS TYPE STAGE WAITER 1543 * 1544 * The 'address' column is indented by one space for each depth level as we 1545 * descend down the tree. 1546 */ 1547 1548 #define ZIO_MAXDEPTH 16 1549 1550 static int 1551 zio_print_cb(uintptr_t addr, const void *data, void *priv) 1552 { 1553 const zio_t *zio = data; 1554 uintptr_t depth = (uintptr_t)priv; 1555 mdb_ctf_id_t type_enum, stage_enum; 1556 const char *type, *stage; 1557 int maxdepth; 1558 1559 maxdepth = sizeof (uintptr_t) * 2 + ZIO_MAXDEPTH; 1560 if (depth > ZIO_MAXDEPTH) 1561 depth = ZIO_MAXDEPTH; 1562 1563 if (mdb_ctf_lookup_by_name("enum zio_type", &type_enum) == -1 || 1564 mdb_ctf_lookup_by_name("enum zio_stage", &stage_enum) == -1) { 1565 mdb_warn("failed to lookup zio enums"); 1566 return (WALK_ERR); 1567 } 1568 1569 if ((type = mdb_ctf_enum_name(type_enum, zio->io_type)) != NULL) 1570 type += sizeof ("ZIO_TYPE_") - 1; 1571 else 1572 type = "?"; 1573 1574 if ((stage = mdb_ctf_enum_name(stage_enum, zio->io_stage)) != NULL) 1575 stage += sizeof ("ZIO_STAGE_") - 1; 1576 else 1577 stage = "?"; 1578 1579 1580 mdb_printf("%*s%-*p %-5s %-22s ", 1581 depth, "", maxdepth - depth, addr, type, stage); 1582 if (zio->io_waiter) 1583 mdb_printf("%?p\n", zio->io_waiter); 1584 else 1585 mdb_printf("-\n"); 1586 1587 if (mdb_pwalk("zio_child", zio_print_cb, (void *)(depth + 1), 1588 addr) != 0) { 1589 mdb_warn("failed to walk zio_t children at %p\n", addr); 1590 return (WALK_ERR); 1591 } 1592 1593 return (WALK_NEXT); 1594 } 1595 1596 /*ARGSUSED*/ 1597 static int 1598 zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1599 { 1600 zio_t zio; 1601 int maxdepth; 1602 1603 maxdepth = sizeof (uintptr_t) * 2 + ZIO_MAXDEPTH; 1604 1605 if (!(flags & DCMD_ADDRSPEC)) 1606 return (DCMD_USAGE); 1607 1608 if (mdb_vread(&zio, sizeof (zio_t), addr) == -1) { 1609 mdb_warn("failed to read zio_t at %p", addr); 1610 return (DCMD_ERR); 1611 } 1612 1613 if (DCMD_HDRSPEC(flags)) 1614 mdb_printf("%<u>%-*s %-5s %-22s %-?s%</u>\n", maxdepth, 1615 "ADDRESS", "TYPE", "STAGE", "WAITER"); 1616 1617 if (zio_print_cb(addr, &zio, NULL) != WALK_NEXT) 1618 return (DCMD_ERR); 1619 1620 return (DCMD_OK); 1621 } 1622 1623 /* 1624 * [addr]::zio_state 1625 * 1626 * Print a summary of all zio_t structures on the system, or for a particular 1627 * pool. This is equivalent to '::walk zio_root | ::zio'. 1628 */ 1629 /*ARGSUSED*/ 1630 static int 1631 zio_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1632 { 1633 /* 1634 * MDB will remember the last address of the pipeline, so if we don't 1635 * zero this we'll end up trying to walk zio structures for a 1636 * non-existent spa_t. 1637 */ 1638 if (!(flags & DCMD_ADDRSPEC)) 1639 addr = 0; 1640 1641 return (mdb_pwalk_dcmd("zio_root", "zio", argc, argv, addr)); 1642 } 1643 1644 typedef struct txg_list_walk_data { 1645 uintptr_t lw_head[TXG_SIZE]; 1646 int lw_txgoff; 1647 int lw_maxoff; 1648 size_t lw_offset; 1649 void *lw_obj; 1650 } txg_list_walk_data_t; 1651 1652 static int 1653 txg_list_walk_init_common(mdb_walk_state_t *wsp, int txg, int maxoff) 1654 { 1655 txg_list_walk_data_t *lwd; 1656 txg_list_t list; 1657 int i; 1658 1659 lwd = mdb_alloc(sizeof (txg_list_walk_data_t), UM_SLEEP | UM_GC); 1660 if (mdb_vread(&list, sizeof (txg_list_t), wsp->walk_addr) == -1) { 1661 mdb_warn("failed to read txg_list_t at %#lx", wsp->walk_addr); 1662 return (WALK_ERR); 1663 } 1664 1665 for (i = 0; i < TXG_SIZE; i++) 1666 lwd->lw_head[i] = (uintptr_t)list.tl_head[i]; 1667 lwd->lw_offset = list.tl_offset; 1668 lwd->lw_obj = mdb_alloc(lwd->lw_offset + sizeof (txg_node_t), 1669 UM_SLEEP | UM_GC); 1670 lwd->lw_txgoff = txg; 1671 lwd->lw_maxoff = maxoff; 1672 1673 wsp->walk_addr = lwd->lw_head[lwd->lw_txgoff]; 1674 wsp->walk_data = lwd; 1675 1676 return (WALK_NEXT); 1677 } 1678 1679 static int 1680 txg_list_walk_init(mdb_walk_state_t *wsp) 1681 { 1682 return (txg_list_walk_init_common(wsp, 0, TXG_SIZE-1)); 1683 } 1684 1685 static int 1686 txg_list0_walk_init(mdb_walk_state_t *wsp) 1687 { 1688 return (txg_list_walk_init_common(wsp, 0, 0)); 1689 } 1690 1691 static int 1692 txg_list1_walk_init(mdb_walk_state_t *wsp) 1693 { 1694 return (txg_list_walk_init_common(wsp, 1, 1)); 1695 } 1696 1697 static int 1698 txg_list2_walk_init(mdb_walk_state_t *wsp) 1699 { 1700 return (txg_list_walk_init_common(wsp, 2, 2)); 1701 } 1702 1703 static int 1704 txg_list3_walk_init(mdb_walk_state_t *wsp) 1705 { 1706 return (txg_list_walk_init_common(wsp, 3, 3)); 1707 } 1708 1709 static int 1710 txg_list_walk_step(mdb_walk_state_t *wsp) 1711 { 1712 txg_list_walk_data_t *lwd = wsp->walk_data; 1713 uintptr_t addr; 1714 txg_node_t *node; 1715 int status; 1716 1717 while (wsp->walk_addr == NULL && lwd->lw_txgoff < lwd->lw_maxoff) { 1718 lwd->lw_txgoff++; 1719 wsp->walk_addr = lwd->lw_head[lwd->lw_txgoff]; 1720 } 1721 1722 if (wsp->walk_addr == NULL) 1723 return (WALK_DONE); 1724 1725 addr = wsp->walk_addr - lwd->lw_offset; 1726 1727 if (mdb_vread(lwd->lw_obj, 1728 lwd->lw_offset + sizeof (txg_node_t), addr) == -1) { 1729 mdb_warn("failed to read list element at %#lx", addr); 1730 return (WALK_ERR); 1731 } 1732 1733 status = wsp->walk_callback(addr, lwd->lw_obj, wsp->walk_cbdata); 1734 node = (txg_node_t *)((uintptr_t)lwd->lw_obj + lwd->lw_offset); 1735 wsp->walk_addr = (uintptr_t)node->tn_next[lwd->lw_txgoff]; 1736 1737 return (status); 1738 } 1739 1740 /* 1741 * ::walk spa 1742 * 1743 * Walk all named spa_t structures in the namespace. This is nothing more than 1744 * a layered avl walk. 1745 */ 1746 static int 1747 spa_walk_init(mdb_walk_state_t *wsp) 1748 { 1749 GElf_Sym sym; 1750 1751 if (wsp->walk_addr != NULL) { 1752 mdb_warn("spa walk only supports global walks\n"); 1753 return (WALK_ERR); 1754 } 1755 1756 if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "spa_namespace_avl", &sym) == -1) { 1757 mdb_warn("failed to find symbol 'spa_namespace_avl'"); 1758 return (WALK_ERR); 1759 } 1760 1761 wsp->walk_addr = (uintptr_t)sym.st_value; 1762 1763 if (mdb_layered_walk("avl", wsp) == -1) { 1764 mdb_warn("failed to walk 'avl'\n"); 1765 return (WALK_ERR); 1766 } 1767 1768 return (WALK_NEXT); 1769 } 1770 1771 static int 1772 spa_walk_step(mdb_walk_state_t *wsp) 1773 { 1774 spa_t spa; 1775 1776 if (mdb_vread(&spa, sizeof (spa), wsp->walk_addr) == -1) { 1777 mdb_warn("failed to read spa_t at %p", wsp->walk_addr); 1778 return (WALK_ERR); 1779 } 1780 1781 return (wsp->walk_callback(wsp->walk_addr, &spa, wsp->walk_cbdata)); 1782 } 1783 1784 /* 1785 * [addr]::walk zio 1786 * 1787 * Walk all active zio_t structures on the system. This is simply a layered 1788 * walk on top of ::walk zio_cache, with the optional ability to limit the 1789 * structures to a particular pool. 1790 */ 1791 static int 1792 zio_walk_init(mdb_walk_state_t *wsp) 1793 { 1794 wsp->walk_data = (void *)wsp->walk_addr; 1795 1796 if (mdb_layered_walk("zio_cache", wsp) == -1) { 1797 mdb_warn("failed to walk 'zio_cache'\n"); 1798 return (WALK_ERR); 1799 } 1800 1801 return (WALK_NEXT); 1802 } 1803 1804 static int 1805 zio_walk_step(mdb_walk_state_t *wsp) 1806 { 1807 zio_t zio; 1808 1809 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { 1810 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); 1811 return (WALK_ERR); 1812 } 1813 1814 if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa) 1815 return (WALK_NEXT); 1816 1817 return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata)); 1818 } 1819 1820 /* 1821 * ::walk zio_child 1822 * 1823 * Walk the children of a zio_t structure. 1824 */ 1825 static int 1826 zio_child_walk_init(mdb_walk_state_t *wsp) 1827 { 1828 zio_t zio; 1829 1830 if (wsp->walk_addr == 0) { 1831 mdb_warn("::walk zio_child doesn't support global walks\n"); 1832 return (WALK_ERR); 1833 } 1834 1835 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { 1836 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); 1837 return (WALK_ERR); 1838 } 1839 1840 wsp->walk_addr = (uintptr_t)zio.io_child; 1841 return (WALK_NEXT); 1842 } 1843 1844 static int 1845 zio_sibling_walk_step(mdb_walk_state_t *wsp) 1846 { 1847 zio_t zio; 1848 int status; 1849 1850 if (wsp->walk_addr == NULL) 1851 return (WALK_DONE); 1852 1853 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { 1854 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); 1855 return (WALK_ERR); 1856 } 1857 1858 status = wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata); 1859 1860 wsp->walk_addr = (uintptr_t)zio.io_sibling_next; 1861 return (status); 1862 } 1863 1864 /* 1865 * [addr]::walk zio_root 1866 * 1867 * Walk only root zio_t structures, optionally for a particular spa_t. 1868 */ 1869 static int 1870 zio_walk_root_step(mdb_walk_state_t *wsp) 1871 { 1872 zio_t zio; 1873 1874 if (mdb_vread(&zio, sizeof (zio), wsp->walk_addr) == -1) { 1875 mdb_warn("failed to read zio_t at %p", wsp->walk_addr); 1876 return (WALK_ERR); 1877 } 1878 1879 if (wsp->walk_data != NULL && wsp->walk_data != zio.io_spa) 1880 return (WALK_NEXT); 1881 1882 if ((uintptr_t)zio.io_root != wsp->walk_addr) 1883 return (WALK_NEXT); 1884 1885 return (wsp->walk_callback(wsp->walk_addr, &zio, wsp->walk_cbdata)); 1886 } 1887 1888 /* 1889 * MDB module linkage information: 1890 * 1891 * We declare a list of structures describing our dcmds, and a function 1892 * named _mdb_init to return a pointer to our module information. 1893 */ 1894 1895 static const mdb_dcmd_t dcmds[] = { 1896 { "arc", "[-bkmg]", "print ARC variables", arc_print }, 1897 { "blkptr", ":", "print blkptr_t", blkptr }, 1898 { "dbuf", ":", "print dmu_buf_impl_t", dbuf }, 1899 { "dbuf_stats", ":", "dbuf stats", dbuf_stats }, 1900 { "dbufs", 1901 "\t[-O objset_impl_t*] [-n objset_name | \"mos\"] " 1902 "[-o object | \"mdn\"] \n" 1903 "\t[-l level] [-b blkid | \"bonus\"]", 1904 "find dmu_buf_impl_t's that match specified criteria", dbufs }, 1905 { "abuf_find", "dva_word[0] dva_word[1]", 1906 "find arc_buf_hdr_t of a specified DVA", 1907 abuf_find }, 1908 { "spa", "?[-cv]", "spa_t summary", spa_print }, 1909 { "spa_config", ":", "print spa_t configuration", spa_print_config }, 1910 { "spa_verify", ":", "verify spa_t consistency", spa_verify }, 1911 { "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space }, 1912 { "spa_vdevs", ":", "given a spa_t, print vdev summary", spa_vdevs }, 1913 { "vdev", ":[-re]\n" 1914 "\t-r display recursively\n" 1915 "\t-e print statistics\n", 1916 "vdev_t summary", vdev_print }, 1917 { "zio", ":", "zio_t summary", zio_print }, 1918 { "zio_state", "?", "print out all zio_t structures on system or " 1919 "for a particular pool", zio_state }, 1920 { "zio_pipeline", ":", "decode a zio pipeline", zio_pipeline }, 1921 { "zfs_params", "", "print zfs tunable parameters", zfs_params }, 1922 { NULL } 1923 }; 1924 1925 static const mdb_walker_t walkers[] = { 1926 /* 1927 * In userland, there is no generic provider of list_t walkers, so we 1928 * need to add it. 1929 */ 1930 #ifndef _KERNEL 1931 { LIST_WALK_NAME, LIST_WALK_DESC, 1932 list_walk_init, list_walk_step, list_walk_fini }, 1933 #endif 1934 { "zms_freelist", "walk ZFS metaslab freelist", 1935 freelist_walk_init, freelist_walk_step, NULL }, 1936 { "txg_list", "given any txg_list_t *, walk all entries in all txgs", 1937 txg_list_walk_init, txg_list_walk_step, NULL }, 1938 { "txg_list0", "given any txg_list_t *, walk all entries in txg 0", 1939 txg_list0_walk_init, txg_list_walk_step, NULL }, 1940 { "txg_list1", "given any txg_list_t *, walk all entries in txg 1", 1941 txg_list1_walk_init, txg_list_walk_step, NULL }, 1942 { "txg_list2", "given any txg_list_t *, walk all entries in txg 2", 1943 txg_list2_walk_init, txg_list_walk_step, NULL }, 1944 { "txg_list3", "given any txg_list_t *, walk all entries in txg 3", 1945 txg_list3_walk_init, txg_list_walk_step, NULL }, 1946 { "zio", "walk all zio structures, optionally for a particular spa_t", 1947 zio_walk_init, zio_walk_step, NULL }, 1948 { "zio_child", "walk children of a zio_t structure", 1949 zio_child_walk_init, zio_sibling_walk_step, NULL }, 1950 { "zio_root", "walk all root zio_t structures, optionally for a " 1951 "particular spa_t", 1952 zio_walk_init, zio_walk_root_step, NULL }, 1953 { "spa", "walk all spa_t entries in the namespace", 1954 spa_walk_init, spa_walk_step, NULL }, 1955 { "metaslab", "given a spa_t *, walk all metaslab_t structures", 1956 metaslab_walk_init, metaslab_walk_step, NULL }, 1957 { NULL } 1958 }; 1959 1960 static const mdb_modinfo_t modinfo = { 1961 MDB_API_VERSION, dcmds, walkers 1962 }; 1963 1964 const mdb_modinfo_t * 1965 _mdb_init(void) 1966 { 1967 return (&modinfo); 1968 } 1969