Print this page
NEX-19993 mdb zfs_params output contains obsolete symbols
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-9752 backport illumos 6950 ARC should cache compressed data
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
6950 ARC should cache compressed data
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Don Brady <don.brady@intel.com>
Reviewed by: Richard Elling <Richard.Elling@RichardElling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
6289 ::dbuf dcmd misaligned output
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
NEX-3165 need some dedup improvements
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
NEX-3165 segregate ddt in arc
NEX-3079 port illumos ARC improvements
4370 avoid transmitting holes during zfs send
4371 DMU code clean up
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Garrett D'Amore <garrett@damore.org>
Fix up some merges where we wanted the upstream version.
Fixup merge results
re #13660 rb4549 ALUA mode: `/usr/demo/comstar/bin/aluaadm enable 1` sets "ALUA Node" = 0
re 13697 update ::zfs_params dcmd
Reviewed by: <Boris.Protopopov@nexenta.com>


   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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  24  * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
  25  * Copyright (c) 2017, Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 /* Portions Copyright 2010 Robert Milkowski */
  29 
  30 #include <mdb/mdb_ctf.h>
  31 #include <sys/zfs_context.h>
  32 #include <sys/mdb_modapi.h>
  33 #include <sys/dbuf.h>
  34 #include <sys/dmu_objset.h>
  35 #include <sys/dsl_dir.h>
  36 #include <sys/dsl_pool.h>
  37 #include <sys/metaslab_impl.h>
  38 #include <sys/space_map.h>
  39 #include <sys/list.h>
  40 #include <sys/vdev_impl.h>
  41 #include <sys/zap_leaf.h>
  42 #include <sys/zap_impl.h>
  43 #include <ctype.h>


 327 
 328         if ((cp = mdb_ctf_enum_name(enum_type, val)) != NULL) {
 329                 if (strncmp(cp, prefix, len) == 0)
 330                         cp += len;
 331                 (void) strncpy(out, cp, size);
 332         } else {
 333                 mdb_snprintf(out, size, "? (%d)", val);
 334         }
 335         return (0);
 336 }
 337 
 338 /* ARGSUSED */
 339 static int
 340 zfs_params(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 341 {
 342         /*
 343          * This table can be approximately generated by running:
 344          * egrep "^[a-z0-9_]+ [a-z0-9_]+( =.*)?;" *.c | cut -d ' ' -f 2
 345          */
 346         static const char *params[] = {
 347                 "arc_reduce_dnlc_percent",
 348                 "arc_lotsfree_percent",
 349                 "zfs_dirty_data_max",
 350                 "zfs_dirty_data_sync",
 351                 "zfs_delay_max_ns",
 352                 "zfs_delay_min_dirty_percent",
 353                 "zfs_delay_scale",
 354                 "zfs_vdev_max_active",
 355                 "zfs_vdev_sync_read_min_active",
 356                 "zfs_vdev_sync_read_max_active",
 357                 "zfs_vdev_sync_write_min_active",
 358                 "zfs_vdev_sync_write_max_active",
 359                 "zfs_vdev_async_read_min_active",
 360                 "zfs_vdev_async_read_max_active",
 361                 "zfs_vdev_async_write_min_active",
 362                 "zfs_vdev_async_write_max_active",
 363                 "zfs_vdev_scrub_min_active",
 364                 "zfs_vdev_scrub_max_active",
 365                 "zfs_vdev_async_write_active_min_dirty_percent",
 366                 "zfs_vdev_async_write_active_max_dirty_percent",



































 367                 "spa_asize_inflation",









































 368                 "zfs_arc_max",


 369                 "zfs_arc_min",
 370                 "arc_shrink_shift",
 371                 "zfs_mdcomp_disable",
 372                 "zfs_prefetch_disable",
 373                 "zfetch_max_streams",
 374                 "zfetch_min_sec_reap",
 375                 "zfetch_block_cap",
 376                 "zfetch_array_rd_sz",









 377                 "zfs_default_bs",
 378                 "zfs_default_ibs",
 379                 "metaslab_aliquot",
 380                 "reference_tracking_enable",
 381                 "reference_history",
 382                 "spa_max_replication_override",
 383                 "spa_mode_global",






 384                 "zfs_flags",
 385                 "zfs_txg_timeout",
 386                 "zfs_vdev_cache_max",
 387                 "zfs_vdev_cache_size",
 388                 "zfs_vdev_cache_bshift",
 389                 "vdev_mirror_shift",
 390                 "zfs_scrub_limit",
















 391                 "zfs_no_scrub_io",
 392                 "zfs_no_scrub_prefetch",
 393                 "zfs_vdev_aggregation_limit",
 394                 "fzap_default_block_shift",
 395                 "zfs_immediate_write_sz",
 396                 "zfs_read_chunk_size",
 397                 "zfs_nocacheflush",




































































 398                 "zil_replay_disable",
 399                 "metaslab_gang_bang",
 400                 "metaslab_df_alloc_threshold",
 401                 "metaslab_df_free_pct",



 402                 "zio_injection_enabled",
 403                 "zvol_immediate_write_sz",



 404         };
 405 
 406         for (int i = 0; i < sizeof (params) / sizeof (params[0]); i++) {
 407                 int sz;
 408                 uint64_t val64;
 409                 uint32_t *val32p = (uint32_t *)&val64;
 410 
 411                 sz = mdb_readvar(&val64, params[i]);
 412                 if (sz == 4) {
 413                         mdb_printf("%s = 0x%x\n", params[i], *val32p);
 414                 } else if (sz == 8) {
 415                         mdb_printf("%s = 0x%llx\n", params[i], val64);
 416                 } else {
 417                         mdb_warn("variable %s not found", params[i]);
 418                 }
 419         }
 420 
 421         return (DCMD_OK);
 422 }
 423 
 424 /* ARGSUSED */
 425 static int
 426 dva(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 427 {
 428         dva_t dva;
 429         if (mdb_vread(&dva, sizeof (dva_t), addr) == -1) {
 430                 mdb_warn("failed to read dva_t");
 431                 return (DCMD_ERR);
 432         }
 433         mdb_printf("<%llu:%llx:%llx>\n",
 434             (u_longlong_t)DVA_GET_VDEV(&dva),
 435             (u_longlong_t)DVA_GET_OFFSET(&dva),
 436             (u_longlong_t)DVA_GET_ASIZE(&dva));
 437 
 438         return (DCMD_OK);
 439 }
 440 
 441 /* ARGSUSED */
 442 static int
 443 blkptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 444 {
 445         char type[80], checksum[80], compress[80];
 446         blkptr_t blk, *bp = &blk;
 447         char buf[BP_SPRINTF_LEN];
 448 
 449         if (mdb_vread(&blk, sizeof (blkptr_t), addr) == -1) {
 450                 mdb_warn("failed to read blkptr_t");
 451                 return (DCMD_ERR);
 452         }
 453 
 454         if (enum_lookup("enum dmu_object_type", BP_GET_TYPE(bp), "DMU_OT_",
 455             sizeof (type), type) == -1 ||
 456             enum_lookup("enum zio_checksum", BP_GET_CHECKSUM(bp),
 457             "ZIO_CHECKSUM_", sizeof (checksum), checksum) == -1 ||
 458             enum_lookup("enum zio_compress", BP_GET_COMPRESS(bp),
 459             "ZIO_COMPRESS_", sizeof (compress), compress) == -1) {
 460                 mdb_warn("Could not find blkptr enumerated types");
 461                 return (DCMD_ERR);
 462         }


 970 
 971         return (DCMD_OK);
 972 }
 973 
 974 /*ARGSUSED*/
 975 static int
 976 arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 977 {
 978         kstat_named_t *stats;
 979         GElf_Sym sym;
 980         int nstats, i;
 981         uint_t opt_a = FALSE;
 982         uint_t opt_b = FALSE;
 983         uint_t shift = 0;
 984         const char *suffix;
 985 
 986         static const char *bytestats[] = {
 987                 "p", "c", "c_min", "c_max", "size", "duplicate_buffers_size",
 988                 "arc_meta_used", "arc_meta_limit", "arc_meta_max",
 989                 "arc_meta_min", "hdr_size", "data_size", "metadata_size",
 990                 "other_size", "anon_size", "anon_evictable_data",
 991                 "anon_evictable_metadata", "mru_size", "mru_evictable_data",
 992                 "mru_evictable_metadata", "mru_ghost_size",

 993                 "mru_ghost_evictable_data", "mru_ghost_evictable_metadata",
 994                 "mfu_size", "mfu_evictable_data", "mfu_evictable_metadata",

 995                 "mfu_ghost_size", "mfu_ghost_evictable_data",
 996                 "mfu_ghost_evictable_metadata", "evict_l2_cached",
 997                 "evict_l2_eligible", "evict_l2_ineligible", "l2_read_bytes",
 998                 "l2_write_bytes", "l2_size", "l2_asize", "l2_hdr_size",
 999                 "compressed_size", "uncompressed_size", "overhead_size",


1000                 NULL
1001         };
1002 
1003         static const char *extras[] = {
1004                 "arc_no_grow", "arc_tempreserve",
1005                 NULL
1006         };
1007 
1008         if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "arc_stats", &sym) == -1) {
1009                 mdb_warn("failed to find 'arc_stats'");
1010                 return (DCMD_ERR);
1011         }
1012 
1013         stats = mdb_zalloc(sym.st_size, UM_SLEEP | UM_GC);
1014 
1015         if (mdb_vread(stats, sym.st_size, sym.st_value) == -1) {
1016                 mdb_warn("couldn't read 'arc_stats' at %p", sym.st_value);
1017                 return (DCMD_ERR);
1018         }
1019 


1552                         aux = "UNSUP_FEAT";
1553                         break;
1554                 case VDEV_AUX_SPARED:
1555                         aux = "SPARED";
1556                         break;
1557                 case VDEV_AUX_ERR_EXCEEDED:
1558                         aux = "ERR_EXCEEDED";
1559                         break;
1560                 case VDEV_AUX_IO_FAILURE:
1561                         aux = "IO_FAILURE";
1562                         break;
1563                 case VDEV_AUX_BAD_LOG:
1564                         aux = "BAD_LOG";
1565                         break;
1566                 case VDEV_AUX_EXTERNAL:
1567                         aux = "EXTERNAL";
1568                         break;
1569                 case VDEV_AUX_SPLIT_POOL:
1570                         aux = "SPLIT_POOL";
1571                         break;
1572                 case VDEV_AUX_CHILDREN_OFFLINE:
1573                         aux = "CHILDREN_OFFLINE";
1574                         break;
1575                 default:
1576                         aux = "UNKNOWN";
1577                         break;
1578                 }
1579 
1580                 mdb_printf("%-9s %-12s %*s%s\n", state, aux, depth, "", desc);
1581 
1582                 if (spa_flags & SPA_FLAG_ERRORS) {
1583                         vdev_stat_t *vs = &vdev.vdev_stat;
1584                         int i;
1585 
1586                         mdb_inc_indent(4);
1587                         mdb_printf("\n");
1588                         mdb_printf("%<u>       %12s %12s %12s %12s "
1589                             "%12s%</u>\n", "READ", "WRITE", "FREE", "CLAIM",
1590                             "IOCTL");
1591                         mdb_printf("OPS     ");
1592                         for (i = 1; i < ZIO_TYPES; i++)
1593                                 mdb_printf("%11#llx%s", vs->vs_ops[i],
1594                                     i == ZIO_TYPES - 1 ? "" : "  ");


2058         mdb_printf("dd_phys.dd_compressed_bytes = %llu%s\n",
2059             dsp.dd_compressed_bytes >> shift, suffix);
2060         mdb_printf("dd_phys.dd_uncompressed_bytes = %llu%s\n",
2061             dsp.dd_uncompressed_bytes >> shift, suffix);
2062 
2063         bzero(&sd, sizeof (sd));
2064         if (mdb_pwalk("metaslab", space_cb, &sd, addr) != 0) {
2065                 mdb_warn("can't walk metaslabs");
2066                 return (DCMD_ERR);
2067         }
2068 
2069         mdb_printf("ms_allocmap = %llu%s %llu%s %llu%s %llu%s\n",
2070             sd.ms_alloctree[0] >> shift, suffix,
2071             sd.ms_alloctree[1] >> shift, suffix,
2072             sd.ms_alloctree[2] >> shift, suffix,
2073             sd.ms_alloctree[3] >> shift, suffix);
2074         mdb_printf("ms_freeingtree = %llu%s\n",
2075             sd.ms_freeingtree >> shift, suffix);
2076         mdb_printf("ms_freedtree = %llu%s\n",
2077             sd.ms_freedtree >> shift, suffix);
2078         mdb_printf("ms_tree = %llu%s\n",
2079             sd.ms_tree >> shift, suffix);
2080         mdb_printf("ms_deferspace = %llu%s\n",
2081             sd.ms_deferspace >> shift, suffix);
2082         mdb_printf("last synced avail = %llu%s\n",
2083             sd.avail >> shift, suffix);
2084         mdb_printf("current syncing avail = %llu%s\n",
2085             sd.nowavail >> shift, suffix);
2086 
2087         return (DCMD_OK);
2088 }
2089 
2090 typedef struct mdb_spa_aux_vdev {
2091         int sav_count;
2092         uintptr_t sav_vdevs;
2093 } mdb_spa_aux_vdev_t;
2094 
2095 typedef struct mdb_spa_vdevs {
2096         uintptr_t spa_root_vdev;
2097         mdb_spa_aux_vdev_t spa_l2cache;
2098         mdb_spa_aux_vdev_t spa_spares;
2099 } mdb_spa_vdevs_t;
2100 
2101 static int
2102 spa_print_aux(mdb_spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
2103     const char *name)


3921         mdb_free(data.mfu_u_hist, hist_size);
3922         mdb_free(data.mfu_bufs, hist_size);
3923 
3924         mdb_free(data.all_c_hist, hist_size);
3925         mdb_free(data.all_u_hist, hist_size);
3926         mdb_free(data.all_bufs, hist_size);
3927 
3928         return (rc);
3929 }
3930 
3931 /*
3932  * MDB module linkage information:
3933  *
3934  * We declare a list of structures describing our dcmds, and a function
3935  * named _mdb_init to return a pointer to our module information.
3936  */
3937 
3938 static const mdb_dcmd_t dcmds[] = {
3939         { "arc", "[-bkmg]", "print ARC variables", arc_print },
3940         { "blkptr", ":", "print blkptr_t", blkptr },
3941         { "dva", ":", "print dva_t", dva },
3942         { "dbuf", ":", "print dmu_buf_impl_t", dbuf },
3943         { "dbuf_stats", ":", "dbuf stats", dbuf_stats },
3944         { "dbufs",
3945             "\t[-O objset_t*] [-n objset_name | \"mos\"] "
3946             "[-o object | \"mdn\"] \n"
3947             "\t[-l level] [-b blkid | \"bonus\"]",
3948             "find dmu_buf_impl_t's that match specified criteria", dbufs },
3949         { "abuf_find", "dva_word[0] dva_word[1]",
3950             "find arc_buf_hdr_t of a specified DVA",
3951             abuf_find },
3952         { "spa", "?[-cevmMh]\n"
3953             "\t-c display spa config\n"
3954             "\t-e display vdev statistics\n"
3955             "\t-v display vdev information\n"
3956             "\t-m display metaslab statistics\n"
3957             "\t-M display metaslab group statistics\n"
3958             "\t-h display histogram (requires -m or -M)\n",
3959             "spa_t summary", spa_print },
3960         { "spa_config", ":", "print spa_t configuration", spa_print_config },
3961         { "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space },




   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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2019 Nexenta Systems, Inc.
  24  * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
  25  * Copyright (c) 2017, Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 /* Portions Copyright 2010 Robert Milkowski */
  29 
  30 #include <mdb/mdb_ctf.h>
  31 #include <sys/zfs_context.h>
  32 #include <sys/mdb_modapi.h>
  33 #include <sys/dbuf.h>
  34 #include <sys/dmu_objset.h>
  35 #include <sys/dsl_dir.h>
  36 #include <sys/dsl_pool.h>
  37 #include <sys/metaslab_impl.h>
  38 #include <sys/space_map.h>
  39 #include <sys/list.h>
  40 #include <sys/vdev_impl.h>
  41 #include <sys/zap_leaf.h>
  42 #include <sys/zap_impl.h>
  43 #include <ctype.h>


 327 
 328         if ((cp = mdb_ctf_enum_name(enum_type, val)) != NULL) {
 329                 if (strncmp(cp, prefix, len) == 0)
 330                         cp += len;
 331                 (void) strncpy(out, cp, size);
 332         } else {
 333                 mdb_snprintf(out, size, "? (%d)", val);
 334         }
 335         return (0);
 336 }
 337 
 338 /* ARGSUSED */
 339 static int
 340 zfs_params(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 341 {
 342         /*
 343          * This table can be approximately generated by running:
 344          * egrep "^[a-z0-9_]+ [a-z0-9_]+( =.*)?;" *.c | cut -d ' ' -f 2
 345          */
 346         static const char *params[] = {

 347                 "arc_lotsfree_percent",
 348                 "arc_pages_pp_reserve",
 349                 "arc_reduce_dnlc_percent",
 350                 "arc_swapfs_reserve",
 351                 "arc_zio_arena_free_shift",
 352                 "dbuf_cache_hiwater_pct",
 353                 "dbuf_cache_lowater_pct",
 354                 "dbuf_cache_max_bytes",
 355                 "dbuf_cache_shift",
 356                 "dbuf_metadata_cache_max_bytes",
 357                 "dbuf_metadata_cache_overflow",
 358                 "dbuf_metadata_cache_shift",
 359                 "ddt_zap_indirect_blockshift",
 360                 "ddt_zap_leaf_blockshift",
 361                 "ditto_same_vdev_distance_shift",
 362                 "dmu_find_threads",
 363                 "dmu_rescan_dnode_threshold",
 364                 "dsl_scan_delay_completion",
 365                 "fzap_default_block_shift",
 366                 "krrp_debug",
 367                 "l2arc_feed_again",
 368                 "l2arc_feed_min_ms",
 369                 "l2arc_feed_secs",
 370                 "l2arc_headroom",
 371                 "l2arc_headroom_boost",
 372                 "l2arc_noprefetch",
 373                 "l2arc_norw",
 374                 "l2arc_rebuild_enabled",
 375                 "l2arc_write_boost",
 376                 "l2arc_write_max",
 377                 "last_free_memory",
 378                 "last_free_reason",
 379                 "metaslab_aliquot",
 380                 "metaslab_alloc_dva_algorithm",
 381                 "metaslab_bias_enabled",
 382                 "metaslab_debug_load",
 383                 "metaslab_debug_unload",
 384                 "metaslab_df_alloc_threshold",
 385                 "metaslab_df_free_pct",
 386                 "metaslab_fragmentation_factor_enabled",
 387                 "metaslab_gang_bang",
 388                 "metaslab_lba_weighting_enabled",
 389                 "metaslab_load_pct",
 390                 "metaslab_min_alloc_size",
 391                 "metaslab_ndf_clump_shift",
 392                 "metaslab_preload_enabled",
 393                 "metaslab_preload_limit",
 394                 "metaslab_trace_enabled",
 395                 "metaslab_trace_max_entries",
 396                 "metaslab_unload_delay",
 397                 "metaslabs_per_vdev",
 398                 "nms_worm_transition_time",
 399                 "rrw_tsd_key",
 400                 "send_holes_without_birth_time",
 401                 "spa_asize_inflation",
 402                 "spa_avg_stat_update_ticks",
 403                 "spa_load_verify_data",
 404                 "spa_load_verify_maxinflight",
 405                 "spa_load_verify_metadata",
 406                 "spa_max_replication_override",
 407                 "spa_min_latency_delta",
 408                 "spa_min_slop",
 409                 "spa_mode_global",
 410                 "spa_namespace_lock",
 411                 "spa_obj_mtx_sz",
 412                 "spa_rotor_load_adjusting",
 413                 "spa_rotor_use_weight",
 414                 "spa_slop_shift",
 415                 "spa_special_factor",
 416                 "spa_special_to_normal_delta",
 417                 "spa_special_to_normal_ratio",
 418                 "spa_static_routing_percentage",
 419                 "space_map_blksz",
 420                 "vdev_mirror_shift",
 421                 "vdev_raidz_default_to_general",
 422                 "wbc_arc_enabled",
 423                 "wbc_force_trigger",
 424                 "wbc_idle_delay_ms",
 425                 "wbc_max_move_tasks_count",
 426                 "wbc_min_move_tasks_count",
 427                 "wbc_mv_cancel_threshold_cap",
 428                 "wbc_mv_cancel_threshold_initial",
 429                 "wbc_mv_cancel_threshold_step",
 430                 "wbc_spa_util_high_wm",
 431                 "wbc_spa_util_low_wm",
 432                 "wbc_throttle_move_delay_ms",
 433                 "wbc_update_statistics_interval_ms",
 434                 "wbc_window_roll_delay_ms",
 435                 "zcr_blksz_max",
 436                 "zcr_blksz_min",
 437                 "zfs_abd_chunk_size",
 438                 "zfs_abd_scatter_enabled",
 439                 "zfs_arc_average_blocksize",
 440                 "zfs_arc_ddt_limit",
 441                 "zfs_arc_evict_batch_limit",
 442                 "zfs_arc_grow_retry",
 443                 "zfs_arc_max",
 444                 "zfs_arc_meta_limit",
 445                 "zfs_arc_meta_min",
 446                 "zfs_arc_min",
 447                 "zfs_arc_p_min_shift",
 448                 "zfs_arc_segregate_ddt",
 449                 "zfs_arc_shrink_shift",
 450                 "zfs_commit_timeout_pct",
 451                 "zfs_compressed_arc_enabled",
 452                 "zfs_condense_pct",
 453                 "zfs_dbgmsg_maxsize",
 454                 "zfs_dbgmsg_size",
 455                 "zfs_dbuf_evict_key",
 456                 "zfs_ddt_byte_ceiling",
 457                 "zfs_ddt_limit_type",
 458                 "zfs_ddts_msize",
 459                 "zfs_deadman_checktime_ms",
 460                 "zfs_deadman_enabled",
 461                 "zfs_deadman_synctime_ms",
 462                 "zfs_dedup_prefetch",
 463                 "zfs_default_bs",
 464                 "zfs_default_ibs",
 465                 "zfs_delay_max_ns",
 466                 "zfs_delay_min_dirty_percent",
 467                 "zfs_delay_resolution_ns",
 468                 "zfs_delay_scale",
 469                 "zfs_dequeue_run_bonus_ms",
 470                 "zfs_dirty_data_max",
 471                 "zfs_dirty_data_max_max",
 472                 "zfs_dirty_data_max_percent",
 473                 "zfs_dirty_data_sync",
 474                 "zfs_do_async_free",
 475                 "zfs_fastflush",
 476                 "zfs_flags",
 477                 "zfs_flush_ntasks",
 478                 "zfs_free_bpobj_enabled",
 479                 "zfs_free_leak_on_eio",
 480                 "zfs_free_max_blocks",
 481                 "zfs_free_min_time_ms",
 482                 "zfs_fsync_sync_cnt",
 483                 "zfs_fsyncer_key",
 484                 "zfs_immediate_write_sz",
 485                 "zfs_l2arc_async_evict",
 486                 "zfs_li",
 487                 "zfs_lua_check_instrlimit_interval",
 488                 "zfs_lua_max_instrlimit",
 489                 "zfs_lua_max_memlimit",
 490                 "zfs_max_recordsize",
 491                 "zfs_mdcomp_disable",
 492                 "zfs_metaslab_condense_block_threshold",
 493                 "zfs_metaslab_fragmentation_threshold",
 494                 "zfs_metaslab_segment_weight_enabled",
 495                 "zfs_metaslab_switch_threshold",
 496                 "zfs_mg_fragmentation_threshold",
 497                 "zfs_mg_noalloc_threshold",
 498                 "zfs_multilist_num_sublists",
 499                 "zfs_no_scrub_io",
 500                 "zfs_no_scrub_prefetch",




 501                 "zfs_nocacheflush",
 502                 "zfs_nopwrite_enabled",
 503                 "zfs_pd_bytes_max",
 504                 "zfs_per_txg_dirty_frees_percent",
 505                 "zfs_prefetch_disable",
 506                 "zfs_read_chunk_size",
 507                 "zfs_recover",
 508                 "zfs_recv_queue_length",
 509                 "zfs_redundant_metadata_most_ditto_level",
 510                 "zfs_resilver_min_time_ms",
 511                 "zfs_root_latency_alpha",
 512                 "zfs_scan_checkpoint_intval",
 513                 "zfs_scan_dequeue_min",
 514                 "zfs_scan_dequeue_run_target_ms",
 515                 "zfs_scan_direct",
 516                 "zfs_scan_fill_weight",
 517                 "zfs_scan_max_ext_gap",
 518                 "zfs_scan_mem_lim_fact",
 519                 "zfs_scan_mem_lim_min",
 520                 "zfs_scan_mem_lim_soft_fact",
 521                 "zfs_scan_mem_lim_soft_max",
 522                 "zfs_scan_min_time_ms",
 523                 "zfs_scrub_limit",
 524                 "zfs_send_corrupt_data",
 525                 "zfs_send_queue_length",
 526                 "zfs_send_set_freerecords_bit",
 527                 "zfs_send_timeout",
 528                 "zfs_share_lock",
 529                 "zfs_smartcomp_interval",
 530                 "zfs_smartcomp_interval_exp",
 531                 "zfs_smartcomp_threshold_factor",
 532                 "zfs_sync_pass_deferred_free",
 533                 "zfs_sync_pass_dont_compress",
 534                 "zfs_sync_pass_rewrite",
 535                 "zfs_sync_taskq_batch_pct",
 536                 "zfs_top_maxinflight",
 537                 "zfs_trim",
 538                 "zfs_trim_min_ext_sz",
 539                 "zfs_txg_timeout",
 540                 "zfs_vdev_aggregation_limit",
 541                 "zfs_vdev_async_read_max_active",
 542                 "zfs_vdev_async_read_min_active",
 543                 "zfs_vdev_async_write_active_max_dirty_percent",
 544                 "zfs_vdev_async_write_active_min_dirty_percent",
 545                 "zfs_vdev_async_write_max_active",
 546                 "zfs_vdev_async_write_min_active",
 547                 "zfs_vdev_cache_bshift",
 548                 "zfs_vdev_cache_max",
 549                 "zfs_vdev_cache_size",
 550                 "zfs_vdev_max_active",
 551                 "zfs_vdev_queue_depth_pct",
 552                 "zfs_vdev_read_gap_limit",
 553                 "zfs_vdev_resilver_max_active",
 554                 "zfs_vdev_resilver_min_active",
 555                 "zfs_vdev_scrub_max_active",
 556                 "zfs_vdev_scrub_min_active",
 557                 "zfs_vdev_sync_read_max_active",
 558                 "zfs_vdev_sync_read_min_active",
 559                 "zfs_vdev_sync_write_max_active",
 560                 "zfs_vdev_sync_write_min_active",
 561                 "zfs_vdev_write_gap_limit",
 562                 "zfs_vn_rele_max_tasks",
 563                 "zfs_vs_latency_alpha",
 564                 "zfs_wbc_data_max",
 565                 "zfs_wbc_schedtmo",
 566                 "zfs_write_implies_delete_child",
 567                 "zfs_zil_clean_taskq_maxalloc",
 568                 "zfs_zil_clean_taskq_minalloc",
 569                 "zfs_zil_clean_taskq_nthr_pct",
 570                 "zil_replay_disable",
 571                 "zil_slog_bulk",
 572                 "zio_buf_debug_limit",
 573                 "zio_dva_throttle_enabled",
 574                 "zio_faulty_vdev_delay_us",
 575                 "zio_faulty_vdev_enabled",
 576                 "zio_faulty_vdev_guid",
 577                 "zio_injection_enabled",
 578                 "zvol_immediate_write_sz",
 579                 "zvol_maxphys",
 580                 "zvol_unmap_enabled",
 581                 "zvol_unmap_sync_enabled",
 582         };
 583 
 584         for (int i = 0; i < sizeof (params) / sizeof (params[0]); i++) {
 585                 int sz;
 586                 uint64_t val64;
 587                 uint32_t *val32p = (uint32_t *)&val64;
 588 
 589                 sz = mdb_readvar(&val64, params[i]);
 590                 if (sz == 4) {
 591                         mdb_printf("%s = 0x%x\n", params[i], *val32p);
 592                 } else if (sz == 8) {
 593                         mdb_printf("%s = 0x%llx\n", params[i], val64);
 594                 } else {
 595                         mdb_warn("variable %s not found", params[i]);
 596                 }
 597         }
 598 
 599         return (DCMD_OK);
 600 }
 601 
 602 /* ARGSUSED */
 603 static int

















 604 blkptr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 605 {
 606         char type[80], checksum[80], compress[80];
 607         blkptr_t blk, *bp = &blk;
 608         char buf[BP_SPRINTF_LEN];
 609 
 610         if (mdb_vread(&blk, sizeof (blkptr_t), addr) == -1) {
 611                 mdb_warn("failed to read blkptr_t");
 612                 return (DCMD_ERR);
 613         }
 614 
 615         if (enum_lookup("enum dmu_object_type", BP_GET_TYPE(bp), "DMU_OT_",
 616             sizeof (type), type) == -1 ||
 617             enum_lookup("enum zio_checksum", BP_GET_CHECKSUM(bp),
 618             "ZIO_CHECKSUM_", sizeof (checksum), checksum) == -1 ||
 619             enum_lookup("enum zio_compress", BP_GET_COMPRESS(bp),
 620             "ZIO_COMPRESS_", sizeof (compress), compress) == -1) {
 621                 mdb_warn("Could not find blkptr enumerated types");
 622                 return (DCMD_ERR);
 623         }


1131 
1132         return (DCMD_OK);
1133 }
1134 
1135 /*ARGSUSED*/
1136 static int
1137 arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1138 {
1139         kstat_named_t *stats;
1140         GElf_Sym sym;
1141         int nstats, i;
1142         uint_t opt_a = FALSE;
1143         uint_t opt_b = FALSE;
1144         uint_t shift = 0;
1145         const char *suffix;
1146 
1147         static const char *bytestats[] = {
1148                 "p", "c", "c_min", "c_max", "size", "duplicate_buffers_size",
1149                 "arc_meta_used", "arc_meta_limit", "arc_meta_max",
1150                 "arc_meta_min", "hdr_size", "data_size", "metadata_size",
1151                 "ddt_size", "other_size", "anon_size", "anon_evictable_data",
1152                 "anon_evictable_metadata", "anon_evictable_ddt", "mru_size",
1153                 "mru_evictable_data", "mru_evictable_metadata",
1154                 "mru_evictable_ddt",  "mru_ghost_size",
1155                 "mru_ghost_evictable_data", "mru_ghost_evictable_metadata",
1156                 "mru_ghost_evictable_ddt", "mfu_size", "mfu_evictable_data",
1157                 "mfu_evictable_metadata", "mfu_evictable_ddt",
1158                 "mfu_ghost_size", "mfu_ghost_evictable_data",
1159                 "mfu_ghost_evictable_metadata", "mfu_ghost_evictable_ddt",
1160                 "evict_l2_cached", "evict_l2_eligible", "evict_l2_ineligible",
1161                 "l2_read_bytes", "l2_ddt_read_bytes", "l2_write_bytes",
1162                 "l2_ddt_write_bytes", "l2_size", "l2_asize",
1163                 "l2_hdr_size", "compressed_size", "uncompressed_size",
1164                 "overhead_size",
1165                 NULL
1166         };
1167 
1168         static const char *extras[] = {
1169                 "arc_no_grow", "arc_tempreserve",
1170                 NULL
1171         };
1172 
1173         if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "arc_stats", &sym) == -1) {
1174                 mdb_warn("failed to find 'arc_stats'");
1175                 return (DCMD_ERR);
1176         }
1177 
1178         stats = mdb_zalloc(sym.st_size, UM_SLEEP | UM_GC);
1179 
1180         if (mdb_vread(stats, sym.st_size, sym.st_value) == -1) {
1181                 mdb_warn("couldn't read 'arc_stats' at %p", sym.st_value);
1182                 return (DCMD_ERR);
1183         }
1184 


1717                         aux = "UNSUP_FEAT";
1718                         break;
1719                 case VDEV_AUX_SPARED:
1720                         aux = "SPARED";
1721                         break;
1722                 case VDEV_AUX_ERR_EXCEEDED:
1723                         aux = "ERR_EXCEEDED";
1724                         break;
1725                 case VDEV_AUX_IO_FAILURE:
1726                         aux = "IO_FAILURE";
1727                         break;
1728                 case VDEV_AUX_BAD_LOG:
1729                         aux = "BAD_LOG";
1730                         break;
1731                 case VDEV_AUX_EXTERNAL:
1732                         aux = "EXTERNAL";
1733                         break;
1734                 case VDEV_AUX_SPLIT_POOL:
1735                         aux = "SPLIT_POOL";
1736                         break;



1737                 default:
1738                         aux = "UNKNOWN";
1739                         break;
1740                 }
1741 
1742                 mdb_printf("%-9s %-12s %*s%s\n", state, aux, depth, "", desc);
1743 
1744                 if (spa_flags & SPA_FLAG_ERRORS) {
1745                         vdev_stat_t *vs = &vdev.vdev_stat;
1746                         int i;
1747 
1748                         mdb_inc_indent(4);
1749                         mdb_printf("\n");
1750                         mdb_printf("%<u>       %12s %12s %12s %12s "
1751                             "%12s%</u>\n", "READ", "WRITE", "FREE", "CLAIM",
1752                             "IOCTL");
1753                         mdb_printf("OPS     ");
1754                         for (i = 1; i < ZIO_TYPES; i++)
1755                                 mdb_printf("%11#llx%s", vs->vs_ops[i],
1756                                     i == ZIO_TYPES - 1 ? "" : "  ");


2220         mdb_printf("dd_phys.dd_compressed_bytes = %llu%s\n",
2221             dsp.dd_compressed_bytes >> shift, suffix);
2222         mdb_printf("dd_phys.dd_uncompressed_bytes = %llu%s\n",
2223             dsp.dd_uncompressed_bytes >> shift, suffix);
2224 
2225         bzero(&sd, sizeof (sd));
2226         if (mdb_pwalk("metaslab", space_cb, &sd, addr) != 0) {
2227                 mdb_warn("can't walk metaslabs");
2228                 return (DCMD_ERR);
2229         }
2230 
2231         mdb_printf("ms_allocmap = %llu%s %llu%s %llu%s %llu%s\n",
2232             sd.ms_alloctree[0] >> shift, suffix,
2233             sd.ms_alloctree[1] >> shift, suffix,
2234             sd.ms_alloctree[2] >> shift, suffix,
2235             sd.ms_alloctree[3] >> shift, suffix);
2236         mdb_printf("ms_freeingtree = %llu%s\n",
2237             sd.ms_freeingtree >> shift, suffix);
2238         mdb_printf("ms_freedtree = %llu%s\n",
2239             sd.ms_freedtree >> shift, suffix);
2240         mdb_printf("ms_tree = %llu%s\n", sd.ms_tree >> shift, suffix);

2241         mdb_printf("ms_deferspace = %llu%s\n",
2242             sd.ms_deferspace >> shift, suffix);
2243         mdb_printf("last synced avail = %llu%s\n", sd.avail >> shift, suffix);

2244         mdb_printf("current syncing avail = %llu%s\n",
2245             sd.nowavail >> shift, suffix);
2246 
2247         return (DCMD_OK);
2248 }
2249 
2250 typedef struct mdb_spa_aux_vdev {
2251         int sav_count;
2252         uintptr_t sav_vdevs;
2253 } mdb_spa_aux_vdev_t;
2254 
2255 typedef struct mdb_spa_vdevs {
2256         uintptr_t spa_root_vdev;
2257         mdb_spa_aux_vdev_t spa_l2cache;
2258         mdb_spa_aux_vdev_t spa_spares;
2259 } mdb_spa_vdevs_t;
2260 
2261 static int
2262 spa_print_aux(mdb_spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
2263     const char *name)


4081         mdb_free(data.mfu_u_hist, hist_size);
4082         mdb_free(data.mfu_bufs, hist_size);
4083 
4084         mdb_free(data.all_c_hist, hist_size);
4085         mdb_free(data.all_u_hist, hist_size);
4086         mdb_free(data.all_bufs, hist_size);
4087 
4088         return (rc);
4089 }
4090 
4091 /*
4092  * MDB module linkage information:
4093  *
4094  * We declare a list of structures describing our dcmds, and a function
4095  * named _mdb_init to return a pointer to our module information.
4096  */
4097 
4098 static const mdb_dcmd_t dcmds[] = {
4099         { "arc", "[-bkmg]", "print ARC variables", arc_print },
4100         { "blkptr", ":", "print blkptr_t", blkptr },

4101         { "dbuf", ":", "print dmu_buf_impl_t", dbuf },
4102         { "dbuf_stats", ":", "dbuf stats", dbuf_stats },
4103         { "dbufs",
4104             "\t[-O objset_t*] [-n objset_name | \"mos\"] "
4105             "[-o object | \"mdn\"] \n"
4106             "\t[-l level] [-b blkid | \"bonus\"]",
4107             "find dmu_buf_impl_t's that match specified criteria", dbufs },
4108         { "abuf_find", "dva_word[0] dva_word[1]",
4109             "find arc_buf_hdr_t of a specified DVA",
4110             abuf_find },
4111         { "spa", "?[-cevmMh]\n"
4112             "\t-c display spa config\n"
4113             "\t-e display vdev statistics\n"
4114             "\t-v display vdev information\n"
4115             "\t-m display metaslab statistics\n"
4116             "\t-M display metaslab group statistics\n"
4117             "\t-h display histogram (requires -m or -M)\n",
4118             "spa_t summary", spa_print },
4119         { "spa_config", ":", "print spa_t configuration", spa_print_config },
4120         { "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space },