257
258 if ((cp = mdb_ctf_enum_name(id, val)) != NULL) {
259 if (strncmp(cp, prefix, len) == 0)
260 cp += len;
261 (void) strncpy(out, cp, size);
262 } else {
263 mdb_snprintf(out, size, "? (%d)", val);
264 }
265 }
266
267 /* ARGSUSED */
268 static int
269 zfs_params(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
270 {
271 /*
272 * This table can be approximately generated by running:
273 * egrep "^[a-z0-9_]+ [a-z0-9_]+( =.*)?;" *.c | cut -d ' ' -f 2
274 */
275 static const char *params[] = {
276 "arc_reduce_dnlc_percent",
277 "zfs_arc_max",
278 "zfs_arc_min",
279 "arc_shrink_shift",
280 "zfs_mdcomp_disable",
281 "zfs_prefetch_disable",
282 "zfetch_max_streams",
283 "zfetch_min_sec_reap",
284 "zfetch_block_cap",
285 "zfetch_array_rd_sz",
286 "zfs_default_bs",
287 "zfs_default_ibs",
288 "metaslab_aliquot",
289 "reference_tracking_enable",
290 "reference_history",
291 "spa_max_replication_override",
292 "spa_mode_global",
293 "zfs_flags",
294 "zfs_txg_synctime_ms",
295 "zfs_txg_timeout",
296 "zfs_write_limit_min",
297 "zfs_write_limit_max",
298 "zfs_write_limit_shift",
299 "zfs_write_limit_override",
300 "zfs_no_write_throttle",
301 "zfs_vdev_cache_max",
302 "zfs_vdev_cache_size",
303 "zfs_vdev_cache_bshift",
304 "vdev_mirror_shift",
305 "zfs_vdev_max_pending",
306 "zfs_vdev_min_pending",
307 "zfs_scrub_limit",
308 "zfs_no_scrub_io",
309 "zfs_no_scrub_prefetch",
310 "zfs_vdev_time_shift",
311 "zfs_vdev_ramp_rate",
312 "zfs_vdev_aggregation_limit",
313 "fzap_default_block_shift",
314 "zfs_immediate_write_sz",
315 "zfs_read_chunk_size",
316 "zfs_nocacheflush",
317 "zil_replay_disable",
318 "metaslab_gang_bang",
319 "metaslab_df_alloc_threshold",
320 "metaslab_df_free_pct",
321 "zio_injection_enabled",
322 "zvol_immediate_write_sz",
323 };
324
325 for (int i = 0; i < sizeof (params) / sizeof (params[0]); i++) {
326 int sz;
327 uint64_t val64;
328 uint32_t *val32p = (uint32_t *)&val64;
329
330 sz = mdb_readvar(&val64, params[i]);
331 if (sz == 4) {
1819 }
1820
1821 /* ARGSUSED */
1822 static int
1823 zio_child_cb(uintptr_t addr, const void *unknown, void *arg)
1824 {
1825 zio_link_t zl;
1826 uintptr_t ziop;
1827 zio_print_args_t *zpa = arg;
1828
1829 if (mdb_vread(&zl, sizeof (zl), addr) == -1) {
1830 mdb_warn("failed to read zio_link_t at %p", addr);
1831 return (WALK_ERR);
1832 }
1833
1834 if (zpa->zpa_type == ZIO_WALK_PARENT)
1835 ziop = (uintptr_t)zl.zl_parent;
1836 else
1837 ziop = (uintptr_t)zl.zl_child;
1838
1839 return (zio_print_cb(ziop, arg));
1840 }
1841
1842 /* ARGSUSED */
1843 static int
1844 zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1845 {
1846 zio_print_args_t zpa = { 0 };
1847
1848 if (!(flags & DCMD_ADDRSPEC))
1849 return (DCMD_USAGE);
1850
1851 if (mdb_getopts(argc, argv,
1852 'r', MDB_OPT_SETBITS, INT_MAX, &zpa.zpa_max_depth,
1853 'c', MDB_OPT_SETBITS, ZIO_WALK_CHILD, &zpa.zpa_type,
1854 'p', MDB_OPT_SETBITS, ZIO_WALK_PARENT, &zpa.zpa_type,
1855 NULL) != argc)
1856 return (DCMD_USAGE);
1857
1858 zpa.zpa_flags = flags;
1859 if (zpa.zpa_max_depth != 0) {
|
257
258 if ((cp = mdb_ctf_enum_name(id, val)) != NULL) {
259 if (strncmp(cp, prefix, len) == 0)
260 cp += len;
261 (void) strncpy(out, cp, size);
262 } else {
263 mdb_snprintf(out, size, "? (%d)", val);
264 }
265 }
266
267 /* ARGSUSED */
268 static int
269 zfs_params(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
270 {
271 /*
272 * This table can be approximately generated by running:
273 * egrep "^[a-z0-9_]+ [a-z0-9_]+( =.*)?;" *.c | cut -d ' ' -f 2
274 */
275 static const char *params[] = {
276 "arc_reduce_dnlc_percent",
277 "arc_lotsfree_percent",
278 "zfs_dirty_data_max",
279 "zfs_dirty_data_sync",
280 "zfs_delay_max_ns",
281 "zfs_delay_min_dirty_percent",
282 "zfs_delay_scale",
283 "zfs_vdev_max_active",
284 "zfs_vdev_sync_read_min_active",
285 "zfs_vdev_sync_read_max_active",
286 "zfs_vdev_sync_write_min_active",
287 "zfs_vdev_sync_write_max_active",
288 "zfs_vdev_async_read_min_active",
289 "zfs_vdev_async_read_max_active",
290 "zfs_vdev_async_write_min_active",
291 "zfs_vdev_async_write_max_active",
292 "zfs_vdev_scrub_min_active",
293 "zfs_vdev_scrub_max_active",
294 "zfs_vdev_async_write_active_min_dirty_percent",
295 "zfs_vdev_async_write_active_max_dirty_percent",
296 "spa_asize_inflation",
297 "zfs_arc_max",
298 "zfs_arc_min",
299 "arc_shrink_shift",
300 "zfs_mdcomp_disable",
301 "zfs_prefetch_disable",
302 "zfetch_max_streams",
303 "zfetch_min_sec_reap",
304 "zfetch_block_cap",
305 "zfetch_array_rd_sz",
306 "zfs_default_bs",
307 "zfs_default_ibs",
308 "metaslab_aliquot",
309 "reference_tracking_enable",
310 "reference_history",
311 "spa_max_replication_override",
312 "spa_mode_global",
313 "zfs_flags",
314 "zfs_txg_timeout",
315 "zfs_vdev_cache_max",
316 "zfs_vdev_cache_size",
317 "zfs_vdev_cache_bshift",
318 "vdev_mirror_shift",
319 "zfs_scrub_limit",
320 "zfs_no_scrub_io",
321 "zfs_no_scrub_prefetch",
322 "zfs_vdev_aggregation_limit",
323 "fzap_default_block_shift",
324 "zfs_immediate_write_sz",
325 "zfs_read_chunk_size",
326 "zfs_nocacheflush",
327 "zil_replay_disable",
328 "metaslab_gang_bang",
329 "metaslab_df_alloc_threshold",
330 "metaslab_df_free_pct",
331 "zio_injection_enabled",
332 "zvol_immediate_write_sz",
333 };
334
335 for (int i = 0; i < sizeof (params) / sizeof (params[0]); i++) {
336 int sz;
337 uint64_t val64;
338 uint32_t *val32p = (uint32_t *)&val64;
339
340 sz = mdb_readvar(&val64, params[i]);
341 if (sz == 4) {
1829 }
1830
1831 /* ARGSUSED */
1832 static int
1833 zio_child_cb(uintptr_t addr, const void *unknown, void *arg)
1834 {
1835 zio_link_t zl;
1836 uintptr_t ziop;
1837 zio_print_args_t *zpa = arg;
1838
1839 if (mdb_vread(&zl, sizeof (zl), addr) == -1) {
1840 mdb_warn("failed to read zio_link_t at %p", addr);
1841 return (WALK_ERR);
1842 }
1843
1844 if (zpa->zpa_type == ZIO_WALK_PARENT)
1845 ziop = (uintptr_t)zl.zl_parent;
1846 else
1847 ziop = (uintptr_t)zl.zl_child;
1848
1849 return (zio_print_cb(ziop, zpa));
1850 }
1851
1852 /* ARGSUSED */
1853 static int
1854 zio_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1855 {
1856 zio_print_args_t zpa = { 0 };
1857
1858 if (!(flags & DCMD_ADDRSPEC))
1859 return (DCMD_USAGE);
1860
1861 if (mdb_getopts(argc, argv,
1862 'r', MDB_OPT_SETBITS, INT_MAX, &zpa.zpa_max_depth,
1863 'c', MDB_OPT_SETBITS, ZIO_WALK_CHILD, &zpa.zpa_type,
1864 'p', MDB_OPT_SETBITS, ZIO_WALK_PARENT, &zpa.zpa_type,
1865 NULL) != argc)
1866 return (DCMD_USAGE);
1867
1868 zpa.zpa_flags = flags;
1869 if (zpa.zpa_max_depth != 0) {
|