Lines Matching +full:libblkid +full:- +full:dev

1 // SPDX-License-Identifier: CDDL-1.0
10 * or https://opensource.org/licenses/CDDL-1.0.
32 * Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
85 static int mount_tp_nthr = 512; /* tpool threads for multi-threaded mounting */
367 * Given a cb->cb_flags with a histogram bit set, return the iostat_type.
371 #define IOS_HISTO_IDX(a) (highbit64(a & IOS_ANYHISTO_M) - 1)
455 return (gettext("\tadd [-afgLnP] [-o property=value] " in get_usage()
458 return (gettext("\tattach [-fsw] [-o property=value] " in get_usage()
459 "<pool> <device> <new-device>\n")); in get_usage()
461 return (gettext("\tclear [[--power]|[-nF]] <pool> [device]\n")); in get_usage()
463 return (gettext("\tcreate [-fnd] [-o property=value] ... \n" in get_usage()
464 "\t [-O file-system-property=value] ... \n" in get_usage()
465 "\t [-m mountpoint] [-R root] <pool> <vdev> ...\n")); in get_usage()
467 return (gettext("\tcheckpoint [-d [-w]] <pool> ...\n")); in get_usage()
469 return (gettext("\tdestroy [-f] <pool>\n")); in get_usage()
473 return (gettext("\texport [-af] <pool> ...\n")); in get_usage()
475 return (gettext("\thistory [-il] [<pool>] ...\n")); in get_usage()
477 return (gettext("\timport [-d dir] [-D]\n" in get_usage()
478 "\timport [-o mntopts] [-o property=value] ... \n" in get_usage()
479 "\t [-d dir | -c cachefile] [-D] [-l] [-f] [-m] [-N] " in get_usage()
480 "[-R root] [-F [-n]] -a\n" in get_usage()
481 "\timport [-o mntopts] [-o property=value] ... \n" in get_usage()
482 "\t [-d dir | -c cachefile] [-D] [-l] [-f] [-m] [-N] " in get_usage()
483 "[-R root] [-F [-n]]\n" in get_usage()
484 "\t [--rewind-to-checkpoint] <pool | id> [newpool]\n")); in get_usage()
486 return (gettext("\tiostat [[[-c [script1,script2,...]" in get_usage()
487 "[-lq]]|[-rw]] [-T d | u] [-ghHLpPvy]\n" in get_usage()
489 " [[-n] interval [count]]\n")); in get_usage()
491 return (gettext("\tlabelclear [-f] <vdev>\n")); in get_usage()
493 return (gettext("\tlist [-gHLpPv] [-o property[,...]] [-j " in get_usage()
494 "[--json-int, --json-pool-key-guid]] ...\n" in get_usage()
495 "\t [-T d|u] [pool] [interval [count]]\n")); in get_usage()
497 return (gettext("\tprefetch -t <type> [<type opts>] <pool>\n" in get_usage()
498 "\t -t ddt <pool>\n")); in get_usage()
500 return (gettext("\toffline [--power]|[[-f][-t]] <pool> " in get_usage()
503 return (gettext("\tonline [--power][-e] <pool> <device> " in get_usage()
506 return (gettext("\treplace [-fsw] [-o property=value] " in get_usage()
507 "<pool> <device> [new-device]\n")); in get_usage()
509 return (gettext("\tremove [-npsw] <pool> <device> ...\n")); in get_usage()
511 return (gettext("\treopen [-n] <pool>\n")); in get_usage()
513 return (gettext("\tinitialize [-c | -s | -u] [-w] <pool> " in get_usage()
516 return (gettext("\tscrub [-e | -s | -p | -C] [-w] " in get_usage()
521 return (gettext("\ttrim [-dw] [-r <rate>] [-c | -s] <pool> " in get_usage()
524 return (gettext("\tstatus [-DdegiLPpstvx] " in get_usage()
525 "[-c script1[,script2,...]] ...\n" in get_usage()
526 "\t [-j|--json [--json-flat-vdevs] [--json-int] " in get_usage()
527 "[--json-pool-key-guid]] ...\n" in get_usage()
528 "\t [-T d|u] [--power] [pool] [interval [count]]\n")); in get_usage()
531 "\tupgrade -v\n" in get_usage()
532 "\tupgrade [-V version] <-a | pool ...>\n")); in get_usage()
534 return (gettext("\tevents [-vHf [pool] | -c]\n")); in get_usage()
536 return (gettext("\tget [-Hp] [-j [--json-int, " in get_usage()
537 "--json-pool-key-guid]] ...\n" in get_usage()
538 "\t [-o \"all\" | field[,...]] " in get_usage()
544 return (gettext("\tsplit [-gLnPl] [-R altroot] [-o mntopts]\n" in get_usage()
545 "\t [-o property=value] <pool> <newpool> " in get_usage()
548 return (gettext("\treguid [-g guid] <pool>\n")); in get_usage()
552 return (gettext("\tversion [-j]\n")); in get_usage()
554 return (gettext("\twait [-Hp] [-T d|u] [-t <activity>[,...]] " in get_usage()
557 return (gettext("\tddtprune -d|-p <amount> <pool>\n")); in get_usage()
598 (void) fprintf(fp, "\t%-19s ", zpool_prop_to_name(prop)); in print_pool_prop_cb()
606 (void) fprintf(fp, "-\n"); in print_pool_prop_cb()
621 (void) fprintf(fp, "\t%-19s ", vdev_prop_to_name(prop)); in print_vdev_prop_cb()
629 (void) fprintf(fp, "-\n"); in print_vdev_prop_cb()
638 * '/dev/disk/by-vdev/L5'.
737 (void) fprintf(fp, "%s", get_usage(current_command->usage)); in usage()
742 ((strcmp(current_command->name, "set") == 0) || in usage()
743 (strcmp(current_command->name, "get") == 0) || in usage()
744 (strcmp(current_command->name, "list") == 0))) { in usage()
749 (void) fprintf(fp, "\n\t%-19s %s %s\n\n", in usage()
757 (void) fprintf(fp, "\t%-19s ", "feature@..."); in usage()
763 "See zpool-features(7).\n")); in usage()
782 * zpool initialize [-c | -s | -u] [-w] <pool> [<vdev> ...]
786 * -c Cancel. Ends active initializing.
787 * -s Suspend. Initializing can then be restarted with no flags.
788 * -u Uninitialize. Clears initialization state.
789 * -w Wait. Blocks until initializing has completed.
811 NULL)) != -1) { in zpool_do_initialize()
816 (void) fprintf(stderr, gettext("-c cannot be " in zpool_do_initialize()
825 (void) fprintf(stderr, gettext("-s cannot be " in zpool_do_initialize()
834 (void) fprintf(stderr, gettext("-u cannot be " in zpool_do_initialize()
850 argv[optind - 1]); in zpool_do_initialize()
856 argc -= optind; in zpool_do_initialize()
862 return (-1); in zpool_do_initialize()
866 (void) fprintf(stderr, gettext("-w cannot be used with -c, -s" in zpool_do_initialize()
867 "or -u\n")); in zpool_do_initialize()
874 return (-1); in zpool_do_initialize()
1034 if (find_vdev(nvroot, cbp->cb_guid)) { in find_spare()
1035 cbp->cb_zhp = zhp; in find_spare()
1096 snprintf(cmd, MAX_CMD_LEN, "zpool %s", current_command->name); in zpool_json_schema()
1173 _name = (char *)"root-0"; in fill_vdev_info()
1251 vdev_state_str[vs->vs_state]); in fill_vdev_info()
1269 * Add a property pair (name, string-value) into a property nvlist.
1370 * Set a default property pair (name, string-value) in a property nvlist
1385 * zpool add [-afgLnP] [-o property=value] <pool> <vdev> ...
1387 * -a Disable the ashift validation checks
1388 * -f Force addition of devices, even if they appear in use
1389 * -g Display guid for individual vdev name.
1390 * -L Follow links when resolving vdev path name.
1391 * -n Do not add the devices, but display the resulting layout if
1393 * -o Set property=value.
1394 * -P Display full path for vdev name.
1419 {"allow-in-use", no_argument, NULL, ZPOOL_OPTION_ALLOW_INUSE}, in zpool_do_add()
1420 {"allow-replication-mismatch", no_argument, NULL, in zpool_do_add()
1422 {"allow-ashift-mismatch", no_argument, NULL, in zpool_do_add()
1429 != -1) { in zpool_do_add()
1446 "'=' for -o option\n")); in zpool_do_add()
1475 argc -= optind; in zpool_do_add()
1490 (void) fprintf(stderr, gettext("'-f' option is not " in zpool_do_add()
1491 "allowed with '--allow-replication-mismatch', " in zpool_do_add()
1492 "'--allow-ashift-mismatch', or " in zpool_do_add()
1493 "'--allow-in-use'\n")); in zpool_do_add()
1503 argc--; in zpool_do_add()
1647 * zpool remove [-npsw] <pool> <vdev> ...
1664 while ((c = getopt(argc, argv, "npsw")) != -1) { in zpool_do_remove()
1685 argc -= optind; in zpool_do_remove()
1714 "combination: -w cannot be used with -s\n")); in zpool_do_remove()
1770 return (1); /* cant open O_EXCL - disk is active */ in vdev_is_active()
1778 * zpool labelclear [-f] <vdev>
1780 * -f Force clearing the label for the vdevs which are members of
1791 int c, fd = -1, ret = 0; in zpool_do_labelclear()
1798 while ((c = getopt(argc, argv, "f")) != -1) { in zpool_do_labelclear()
1810 argc -= optind; in zpool_do_labelclear()
1840 if (zfs_append_partition(vdev, MAXPATHLEN) == -1) in zpool_do_labelclear()
1893 * We allow the user to call 'zpool offline -f' in zpool_do_labelclear()
1916 "use '-f' to override the following error:\n" in zpool_do_labelclear()
1926 "use '-f' to override the following error:\n" in zpool_do_labelclear()
1953 * zpool create [-fnd] [-o property=value] ...
1954 * [-O file-system-property=value] ...
1955 * [-R root] [-m mountpoint] <pool> <dev> ...
1957 * -f Force creation, even if devices appear in use
1958 * -n Do not create the pool, but display the resulting layout if it
1960 * -R Create a pool under an alternate root
1961 * -m Set default mountpoint for the root dataset. By default it's
1963 * -o Set property=value.
1964 * -o Set feature@feature=enabled|disabled.
1965 * -d Don't automatically enable all supported pool features
1966 * (individual features can be enabled with -o).
1967 * -O Set fsproperty=value in the pool's root file system
1972 * contents (if '-n' was specified), or pass it to libzfs to do the creation.
1994 while ((c = getopt(argc, argv, ":fndR:m:o:O:t:")) != -1) { in zpool_do_create()
2015 /* Equivalent to -O mountpoint=optarg */ in zpool_do_create()
2021 "'=' for -o option\n")); in zpool_do_create()
2053 "'=' for -O option\n")); in zpool_do_create()
2062 * more than once, to avoid conflict with -m. in zpool_do_create()
2104 argc -= optind; in zpool_do_create()
2133 argc - 1, argv + 1); in zpool_do_create()
2153 * '-m' mountpoint option if it looks like its in use. in zpool_do_create()
2187 (void) fprintf(stderr, gettext("use '-m' " in zpool_do_create()
2200 (void) fprintf(stderr, gettext("use '-m' " in zpool_do_create()
2254 * - remove it if feature@name=disabled in zpool_do_create()
2255 * - leave it there if feature@name=enabled in zpool_do_create()
2256 * - add it if: in zpool_do_create()
2257 * - enable_pool_features (ie: no '-d' or '-o version') in zpool_do_create()
2258 * - it's supported by the kernel module in zpool_do_create()
2259 * - it's in the requested feature set in zpool_do_create()
2260 * - warn if it's enabled but not in compat in zpool_do_create()
2268 "feature@%s", feat->fi_uname); in zpool_do_create()
2282 feat->fi_uname); in zpool_do_create()
2286 feat->fi_zfs_mod_supported && in zpool_do_create()
2328 * -f Forcefully unmount any datasets
2342 while ((c = getopt(argc, argv, "f")) != -1) { in zpool_do_destroy()
2354 argc -= optind; in zpool_do_destroy()
2420 * zpool_disable_datasets() is not thread-safe for mnttab access. in zpool_export_one()
2421 * So we serialize access here for 'zpool export -a' parallel case. in zpool_export_one()
2423 if (cb->tpool != NULL) in zpool_export_one()
2424 pthread_mutex_lock(&cb->mnttab_lock); in zpool_export_one()
2426 int retval = zpool_disable_datasets(zhp, cb->force); in zpool_export_one()
2428 if (cb->tpool != NULL) in zpool_export_one()
2429 pthread_mutex_unlock(&cb->mnttab_lock); in zpool_export_one()
2434 if (cb->hardforce) { in zpool_export_one()
2437 } else if (zpool_export(zhp, cb->force, history_str) != 0) { in zpool_export_one()
2452 zpool_handle_t *zhp = zpool_open(g_zfs, aea->aea_poolname); in zpool_export_task()
2454 int ret = zpool_export_one(zhp, aea->aea_cbdata); in zpool_export_task()
2456 aea->aea_cbdata->retval = ret; in zpool_export_task()
2459 aea->aea_cbdata->retval = 1; in zpool_export_task()
2462 free(aea->aea_poolname); in zpool_export_task()
2472 tpool_t *tpool = ((export_cbdata_t *)data)->tpool; in zpool_export_one_async()
2476 aea->aea_poolname = strdup(zpool_get_name(zhp)); in zpool_export_one_async()
2477 aea->aea_cbdata = data; in zpool_export_one_async()
2487 * zpool export [-f] <pool> ...
2489 * -a Export all pools
2490 * -f Forcefully unmount datasets
2493 * unmount any active datasets within the pool. If the '-f' flag is specified,
2506 while ((c = getopt(argc, argv, "afF")) != -1) { in zpool_do_export()
2528 argc -= optind; in zpool_do_export()
2638 for (i = 0; i < vcdl->count; i++) { in zpool_nvlist_cmd()
2639 if ((strcmp(vcdl->data[i].path, path) != 0) || in zpool_nvlist_cmd()
2640 (strcmp(vcdl->data[i].pool, pool) != 0)) in zpool_nvlist_cmd()
2643 data = &vcdl->data[i]; in zpool_nvlist_cmd()
2644 for (j = 0; j < vcdl->uniq_cols_cnt; j++) { in zpool_nvlist_cmd()
2646 for (int k = 0; k < data->cols_cnt; k++) { in zpool_nvlist_cmd()
2647 if (strcmp(data->cols[k], in zpool_nvlist_cmd()
2648 vcdl->uniq_cols[j]) == 0) { in zpool_nvlist_cmd()
2649 val = data->lines[k]; in zpool_nvlist_cmd()
2654 val = "-"; in zpool_nvlist_cmd()
2655 fnvlist_add_string(item, vcdl->uniq_cols[j], val); in zpool_nvlist_cmd()
2658 for (j = data->cols_cnt; j < data->lines_cnt; j++) { in zpool_nvlist_cmd()
2659 if (data->lines[j]) { in zpool_nvlist_cmd()
2662 data->lines[j]); in zpool_nvlist_cmd()
2677 for (i = 0; i < vcdl->count; i++) { in zpool_print_cmd()
2678 if ((strcmp(vcdl->data[i].path, path) != 0) || in zpool_print_cmd()
2679 (strcmp(vcdl->data[i].pool, pool) != 0)) { in zpool_print_cmd()
2684 data = &vcdl->data[i]; in zpool_print_cmd()
2686 for (j = 0; j < vcdl->uniq_cols_cnt; j++) { in zpool_print_cmd()
2689 for (int k = 0; k < data->cols_cnt; k++) { in zpool_print_cmd()
2690 if (strcmp(data->cols[k], in zpool_print_cmd()
2691 vcdl->uniq_cols[j]) == 0) { in zpool_print_cmd()
2693 val = data->lines[k]; in zpool_print_cmd()
2699 * awk-able. in zpool_print_cmd()
2702 val = "-"; in zpool_print_cmd()
2704 printf("%*s", vcdl->uniq_cols_width[j], val); in zpool_print_cmd()
2705 if (j < vcdl->uniq_cols_cnt - 1) in zpool_print_cmd()
2710 for (j = data->cols_cnt; j < data->lines_cnt; j++) { in zpool_print_cmd()
2712 if (vcdl->uniq_cols_cnt > 0) in zpool_print_cmd()
2715 val = data->lines[j]; in zpool_print_cmd()
2729 if ((vs->vs_initialize_state == VDEV_INITIALIZE_ACTIVE || in print_status_initialize()
2730 vs->vs_initialize_state == VDEV_INITIALIZE_SUSPENDED || in print_status_initialize()
2731 vs->vs_initialize_state == VDEV_INITIALIZE_COMPLETE) && in print_status_initialize()
2732 !vs->vs_scan_removing) { in print_status_initialize()
2736 time_t t = vs->vs_initialize_action_time; in print_status_initialize()
2738 if (vs->vs_initialize_state != in print_status_initialize()
2740 initialize_pct = (vs->vs_initialize_bytes_done * in print_status_initialize()
2741 100 / (vs->vs_initialize_bytes_est + 1)); in print_status_initialize()
2747 switch (vs->vs_initialize_state) { in print_status_initialize()
2767 } else if (vs->vs_initialize_state == VDEV_INITIALIZE_ACTIVE) { in print_status_initialize()
2779 if ((vs->vs_trim_state == VDEV_TRIM_ACTIVE || in print_status_trim()
2780 vs->vs_trim_state == VDEV_TRIM_SUSPENDED || in print_status_trim()
2781 vs->vs_trim_state == VDEV_TRIM_COMPLETE) && in print_status_trim()
2782 !vs->vs_scan_removing) { in print_status_trim()
2786 time_t t = vs->vs_trim_action_time; in print_status_trim()
2788 if (vs->vs_trim_state != VDEV_TRIM_COMPLETE) { in print_status_trim()
2789 trim_pct = (vs->vs_trim_bytes_done * in print_status_trim()
2790 100 / (vs->vs_trim_bytes_est + 1)); in print_status_trim()
2796 switch (vs->vs_trim_state) { in print_status_trim()
2813 } else if (vs->vs_trim_notsup) { in print_status_trim()
2818 } else if (vs->vs_trim_state == VDEV_TRIM_ACTIVE) { in print_status_trim()
2850 * 3) slow IO reporting was requested (-s) and there are slow IOs.
2864 if (vs->vs_checksum_errors || vs->vs_read_errors || in vdev_health_check_cb()
2865 vs->vs_write_errors || vs->vs_state != VDEV_STATE_HEALTHY) in vdev_health_check_cb()
2868 if (cb->cb_print_slow_ios && vs->vs_slow_ios) in vdev_health_check_cb()
2907 state = zpool_state_to_name(vs->vs_state, vs->vs_aux); in print_status_config()
2914 if (vs->vs_aux == VDEV_AUX_SPARED) in print_status_config()
2916 else if (vs->vs_state == VDEV_STATE_HEALTHY) in print_status_config()
2921 * If '-e' is specified then top-level vdevs and their children in print_status_config()
2924 if (cb->cb_print_unhealthy && depth > 0 && in print_status_config()
2930 "\t%*s%-*s %-8s", depth, "", cb->cb_namewidth - depth, in print_status_config()
2934 if (vs->vs_read_errors) in print_status_config()
2937 if (vs->vs_write_errors) in print_status_config()
2940 if (vs->vs_checksum_errors) in print_status_config()
2943 if (vs->vs_slow_ios) in print_status_config()
2946 if (cb->cb_literal) { in print_status_config()
2949 (u_longlong_t)vs->vs_read_errors); in print_status_config()
2952 (u_longlong_t)vs->vs_write_errors); in print_status_config()
2955 (u_longlong_t)vs->vs_checksum_errors); in print_status_config()
2957 zfs_nicenum(vs->vs_read_errors, rbuf, sizeof (rbuf)); in print_status_config()
2958 zfs_nicenum(vs->vs_write_errors, wbuf, sizeof (wbuf)); in print_status_config()
2959 zfs_nicenum(vs->vs_checksum_errors, cbuf, in print_status_config()
2968 if (cb->cb_print_slow_ios) { in print_status_config()
2971 zfs_nicenum(vs->vs_slow_ios, rbuf, in print_status_config()
2974 snprintf(rbuf, sizeof (rbuf), "-"); in print_status_config()
2977 if (cb->cb_literal) in print_status_config()
2979 (u_longlong_t)vs->vs_slow_ios); in print_status_config()
2983 if (cb->cb_print_power) { in print_status_config()
2997 printf(" %5s", "-"); in print_status_config()
3000 printf(" %5s", "-"); in print_status_config()
3004 cb->cb_print_dio_verify) { in print_status_config()
3005 zfs_nicenum(vs->vs_dio_verify_errors, dbuf, in print_status_config()
3008 if (cb->cb_literal) in print_status_config()
3010 (u_longlong_t)vs->vs_dio_verify_errors); in print_status_config()
3020 } else if (vs->vs_aux != 0) { in print_status_config()
3023 switch (vs->vs_aux) { in print_status_config()
3067 if (vs->vs_read_errors + vs->vs_write_errors + in print_status_config()
3068 vs->vs_checksum_errors == 0 && children == 0 && in print_status_config()
3069 vs->vs_slow_ios > 0) { in print_status_config()
3112 vs->vs_configured_ashift < vs->vs_physical_ashift) { in print_status_config()
3115 1 << vs->vs_configured_ashift, 1 << vs->vs_physical_ashift); in print_status_config()
3118 if (vs->vs_scan_removing != 0) { in print_status_config()
3120 } else if (VDEV_STAT_VALID(vs_noalloc, vsc) && vs->vs_noalloc != 0) { in print_status_config()
3121 (void) printf(gettext(" (non-allocating)")); in print_status_config()
3136 if (ps != NULL && ps->pss_state == DSS_SCANNING && children == 0 && in print_status_config()
3137 vs->vs_state == VDEV_STATE_HEALTHY) { in print_status_config()
3138 if (vs->vs_scan_processed != 0) { in print_status_config()
3140 (ps->pss_func == POOL_SCAN_RESILVER) ? in print_status_config()
3142 } else if (vs->vs_resilver_deferred) { in print_status_config()
3147 /* The top-level vdevs have the rebuild stats */ in print_status_config()
3148 if (vrs != NULL && vrs->vrs_state == VDEV_REBUILD_ACTIVE && in print_status_config()
3149 children == 0 && vs->vs_state == VDEV_STATE_HEALTHY) { in print_status_config()
3150 if (vs->vs_rebuild_processed != 0) { in print_status_config()
3155 if (cb->vcdl != NULL) { in print_status_config()
3158 zpool_print_cmd(cb->vcdl, zpool_get_name(zhp), path); in print_status_config()
3164 print_status_initialize(vs, cb->cb_print_vdev_init); in print_status_config()
3165 print_status_trim(vs, cb->cb_print_vdev_trim); in print_status_config()
3192 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in print_status_config()
3221 (void) printf("\t%*s%-*s", depth, "", cb->cb_namewidth - depth, name); in print_import_config()
3222 (void) printf(" %s", zpool_state_to_name(vs->vs_state, vs->vs_aux)); in print_import_config()
3224 if (vs->vs_aux != 0) { in print_import_config()
3227 switch (vs->vs_aux) { in print_import_config()
3286 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in print_import_config()
3296 cb->cb_name_flags); in print_import_config()
3307 cb->cb_name_flags); in print_import_config()
3321 * recursively - which works because only the top level vdev is marked.
3331 assert(zhp != NULL || !cb->cb_verbose); in print_class_vdevs()
3365 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in print_class_vdevs()
3366 if (cb->cb_print_status) in print_class_vdevs()
3409 health = zpool_state_to_name(vs->vs_state, vs->vs_aux); in show_import()
3469 "a legacy on-disk version.\n")); in show_import()
3508 "accessed in read-only mode on this system. It\n" in show_import()
3509 "\t%scannot be accessed in read-write mode because it uses " in show_import()
3560 "configured to use a non-native block size.\n" in show_import()
3574 if (vs->vs_state != VDEV_STATE_HEALTHY || in show_import()
3579 if (vs->vs_state == VDEV_STATE_HEALTHY) { in show_import()
3596 "\t%sthe '-f' flag.\n"), indent); in show_import()
3620 "datasets contain an on-disk " in show_import()
3631 "on-disk\n" in show_import()
3633 "on-disk corruption if they are used\n" in show_import()
3640 "\t%srequired, use a non-raw send to " in show_import()
3656 } else if (vs->vs_state == VDEV_STATE_DEGRADED) { in show_import()
3677 "read-write mode. Import the pool with\n" in show_import()
3678 "\t%s'-o readonly=on', access the pool on a system " in show_import()
3725 if ((vs->vs_state == VDEV_STATE_CLOSED || in show_import()
3726 vs->vs_state == VDEV_STATE_CANT_OPEN) && in show_import()
3727 vs->vs_aux == VDEV_AUX_CORRUPT_DATA) { in show_import()
3730 "but can be imported using the '-Df' flags.\n"), in show_import()
3735 "\t%sthe '-f' flag.\n"), indent, indent); in show_import()
3740 "https://openzfs.github.io/openzfs-docs/msg/%s\n"), in show_import()
3881 "The pool can be imported, use 'zpool import -f' " in do_import()
3935 *ip->ip_err |= do_import(ip->ip_config, NULL, ip->ip_mntopts, in do_import_task()
3936 ip->ip_props, ip->ip_flags, ip->ip_mntthreads); in do_import_task()
3948 boolean_t pool_specified = (import->poolname != NULL || in import_pools()
3949 import->guid != 0); in import_pools()
3954 if (import->do_all) { in import_pools()
3962 * post-process the list to deal with pool state and possible in import_pools()
3968 if (!pool_specified && import->do_all) { in import_pools()
3978 if (!import->do_destroyed && in import_pools()
3981 if (import->do_destroyed && in import_pools()
3986 import->policy) == 0); in import_pools()
3991 else if (!import->do_all) in import_pools()
3994 if (import->do_all) { in import_pools()
3998 ip->ip_config = config; in import_pools()
3999 ip->ip_mntopts = mntopts; in import_pools()
4000 ip->ip_props = props; in import_pools()
4001 ip->ip_flags = flags; in import_pools()
4002 ip->ip_mntthreads = mount_tp_nthr / npools; in import_pools()
4003 ip->ip_err = &err; in import_pools()
4015 if (import->cachefile && !import->scan) in import_pools()
4020 } else if (import->poolname != NULL) { in import_pools()
4029 if (strcmp(name, import->poolname) == 0) { in import_pools()
4034 import->poolname); in import_pools()
4050 if (guid == import->guid) in import_pools()
4054 if (import->do_all) { in import_pools()
4099 if (args->poolname != NULL) { in name_or_guid_exists()
4104 if (strcmp(pool_name, args->poolname) == 0) in name_or_guid_exists()
4111 if (pool_guid == args->poolguid) in name_or_guid_exists()
4120 * checkpoint --discard <pool>
4122 * -d Discard the checkpoint from a checkpointed
4123 * --discard pool.
4125 * -w Wait for discarding a checkpoint to complete.
4126 * --wait
4147 while ((c = getopt_long(argc, argv, ":dw", long_options, NULL)) != -1) { in zpool_do_checkpoint()
4163 (void) fprintf(stderr, gettext("--wait only valid when " in zpool_do_checkpoint()
4164 "--discard also specified\n")); in zpool_do_checkpoint()
4168 argc -= optind; in zpool_do_checkpoint()
4223 while ((c = getopt(argc, argv, "t:")) != -1) { in zpool_do_prefetch()
4239 argc -= optind; in zpool_do_prefetch()
4254 argc--; in zpool_do_prefetch()
4275 * zpool import [-d dir] [-D]
4276 * import [-o mntopts] [-o prop=value] ... [-R root] [-D] [-l]
4277 * [-d dir | -c cachefile | -s] [-f] -a
4278 * import [-o mntopts] [-o prop=value] ... [-R root] [-D] [-l]
4279 * [-d dir | -c cachefile | -s] [-f] [-n] [-F] <pool | id>
4282 * -c Read pool information from a cachefile instead of searching
4287 * -d Scan in a specific directory, other than /dev/. More than
4288 * one directory can be specified using multiple '-d' options.
4290 * -D Scan for previously destroyed pools or import all or only
4293 * -R Temporarily import the pool, with all mountpoints relative to
4297 * -V Import even in the presence of faulted vdevs. This is an
4303 * -f Force import, even if it appears that the pool is active.
4305 * -F Attempt rewind if necessary.
4307 * -n See if rewind would work, but don't actually rewind.
4309 * -N Import the pool but don't mount datasets.
4311 * -T Specify a starting txg to use for import. This option is
4314 * -a Import all pools found.
4316 * -l Load encryption keys while importing.
4318 * -o Set property=value and/or temporary mount options (without '=').
4320 * -s Scan using the default search path, the libblkid cache will
4323 * --rewind-to-checkpoint
4353 uint64_t txg = -1ULL; in zpool_do_import()
4359 {"rewind-to-checkpoint", no_argument, NULL, CHECKPOINT_OPT}, in zpool_do_import()
4365 long_options, NULL)) != -1) { in zpool_do_import()
4459 argc -= optind; in zpool_do_import()
4463 (void) fprintf(stderr, gettext("-c is incompatible with -d\n")); in zpool_do_import()
4468 (void) fprintf(stderr, gettext("-c is incompatible with -s\n")); in zpool_do_import()
4473 (void) fprintf(stderr, gettext("-l is incompatible with -N\n")); in zpool_do_import()
4478 (void) fprintf(stderr, gettext("-l is only meaningful during " in zpool_do_import()
4485 gettext("-n or -X only meaningful with -F\n")); in zpool_do_import()
4535 * -a Iterate through all pools and try to import each one. in zpool_do_import()
4540 * -D Above options applies only to destroyed pools. in zpool_do_import()
4663 * zpool sync [-f] [pool] ...
4665 * -f (undocumented) force uberblock (and config including zpool cache file)
4680 while ((ret = getopt(argc, argv, "f")) != -1) { in zpool_do_sync()
4692 argc -= optind; in zpool_do_sync()
4739 /* Shorthand - if "columns" field not set, default to 1 column */
4764 * Return the number of labels in a null-terminated name_and_columns_t
4780 * Return the number of strings in a null-terminated string array.
4818 if (cb->cb_literal) in default_column_width()
4839 uint64_t flags = cb->cb_flags; in print_iostat_labels()
4845 idx = lowbit64(f) - 1; in print_iostat_labels()
4860 (2 * (columns - 1)); in print_iostat_labels()
4862 text_start = (int)((rw_column_width) / columns - in print_iostat_labels()
4876 spaces_to_end = rw_column_width - text_start - slen; in print_iostat_labels()
4888 * print_cmd_columns - Print custom column titles from -c
4890 * If the user specified the "zpool status|iostat -c" then print their custom
4894 * $ zpool iostat -vc 'echo col1=val1; echo col2=val2'
4898 * ---------- ----- ----- ----- ----- ----- ----- ---- ----
4901 * sdb - - 0 0 102 473 val1 val2
4902 * sdc - - 0 0 5 473 val1 val2
4903 * ---------- ----- ----- ----- ----- ----- ----- ---- ----
4909 vdev_cmd_data_t *data = &vcdl->data[0]; in print_cmd_columns()
4911 if (vcdl->count == 0 || data == NULL) in print_cmd_columns()
4919 for (i = 0; i < vcdl->uniq_cols_cnt; i++) { in print_cmd_columns()
4922 for (j = 0; j < vcdl->uniq_cols_width[i]; j++) in print_cmd_columns()
4923 printf("-"); in print_cmd_columns()
4925 printf_color(ANSI_BOLD, "%*s", vcdl->uniq_cols_width[i], in print_cmd_columns()
4926 vcdl->uniq_cols[i]); in print_cmd_columns()
4935 * -------------------------------- ----- ----- ----- ----- -----
4937 * ...or a dashed named-row line like:
4939 * logs - - - - -
4943 * @force_column_width If non-zero, use the value as the column width.
4946 * @name: Print a dashed named-row line starting
4956 uint64_t flags = cb->cb_flags; in print_iostat_dashes()
4963 if (cb->cb_flags & IOS_ANYHISTO_M) { in print_iostat_dashes()
4964 title = histo_to_title[IOS_HISTO_IDX(cb->cb_flags)]; in print_iostat_dashes()
4965 } else if (cb->cb_vdevs.cb_names_count) { in print_iostat_dashes()
4971 namewidth = MAX(MAX(strlen(title), cb->cb_namewidth), in print_iostat_dashes()
4976 printf("%-*s", namewidth, name); in print_iostat_dashes()
4979 (void) printf("-"); in print_iostat_dashes()
4985 idx = lowbit64(f) - 1; in print_iostat_dashes()
4994 printf(" %*s-", column_width - 1, " "); in print_iostat_dashes()
4997 "--------------------"); in print_iostat_dashes()
5025 if (cb->cb_flags & IOS_ANYHISTO_M) { in print_iostat_header_impl()
5026 title = histo_to_title[IOS_HISTO_IDX(cb->cb_flags)]; in print_iostat_header_impl()
5027 } else if (cb->cb_vdevs.cb_names_count) { in print_iostat_header_impl()
5033 namewidth = MAX(MAX(strlen(title), cb->cb_namewidth), in print_iostat_header_impl()
5037 printf("%-*s", namewidth, histo_vdev_name); in print_iostat_header_impl()
5045 printf("%-*s", namewidth, title); in print_iostat_header_impl()
5048 if (cb->vcdl != NULL) in print_iostat_header_impl()
5049 print_cmd_columns(cb->vcdl, 0); in print_iostat_header_impl()
5055 if (cb->vcdl != NULL) in print_iostat_header_impl()
5056 print_cmd_columns(cb->vcdl, 1); in print_iostat_header_impl()
5080 column_size--; in print_stat_color()
5094 if (--column_size <= 0) in print_stat_color()
5131 for (i = 0; i < ARRAY_SIZE(calcvs->vs_ops); i++) in calc_default_iostats()
5132 calcvs->vs_ops[i] = (newvs->vs_ops[i] - oldvs->vs_ops[i]); in calc_default_iostats()
5134 for (i = 0; i < ARRAY_SIZE(calcvs->vs_bytes); i++) in calc_default_iostats()
5135 calcvs->vs_bytes[i] = (newvs->vs_bytes[i] - oldvs->vs_bytes[i]); in calc_default_iostats()
5179 ret = nvpair_value_uint64_array(tmp, &nva->data, &nva->count); in nvpair64_to_stat_array()
5182 ret = nvpair_value_uint64(tmp, &nva->__data); in nvpair64_to_stat_array()
5183 nva->data = &nva->__data; in nvpair64_to_stat_array()
5184 nva->count = 1; in nvpair64_to_stat_array()
5237 calcnva[j].data[i] -= oldnva[j].data[i]; in calc_and_alloc_stats_ex()
5267 if (cb->cb_literal) in print_iostat_histo()
5275 if (cb->cb_flags & IOS_RQ_HISTO_M) { in print_iostat_histo()
5276 /* Start at 512 - req size should never be lower than this */ in print_iostat_histo()
5284 if (cb->cb_flags & IOS_L_HISTO_M) { in print_iostat_histo()
5286 val = (1UL << (j + 1)) - 1; in print_iostat_histo()
5294 if (cb->cb_scripted) in print_iostat_histo()
5297 printf("%-*s", namewidth, buf); in print_iostat_histo()
5302 column_width, cb->cb_scripted); in print_iostat_histo()
5311 while (length--) in print_solid_separator()
5312 printf("-"); in print_solid_separator()
5329 type = IOS_HISTO_IDX(cb->cb_flags); in print_iostat_histos()
5331 /* Get NULL-terminated array of nvlist names for our histo */ in print_iostat_histos()
5337 if (cb->cb_literal) { in print_iostat_histos()
5344 namewidth = MAX(cb->cb_namewidth, in print_iostat_histos()
5345 strlen(histo_to_title[IOS_HISTO_IDX(cb->cb_flags)])); in print_iostat_histos()
5352 /* ----- ----- */ in print_iostat_histos()
5353 /* |___| <---------- column_width */ in print_iostat_histos()
5355 /* |__________| <--- entire_width */ in print_iostat_histos()
5360 if (cb->cb_scripted) in print_iostat_histos()
5369 if (!cb->cb_scripted) in print_iostat_histos()
5374 * Calculate the average latency of a power-of-two latency histogram
5384 * Our buckets are power-of-two latency ranges. Use the in single_histo_average()
5389 * 8ns-15ns: 12ns in single_histo_average()
5390 * 16ns-31ns: 24ns in single_histo_average()
5430 if (cb->cb_literal) in print_iostat_queues()
5437 print_one_stat(val, format, column_width, cb->cb_scripted); in print_iostat_queues()
5469 if (cb->cb_literal) in print_iostat_latency()
5478 print_one_stat(val, format, column_width, cb->cb_scripted); in print_iostat_latency()
5493 if (cb->cb_literal) { in print_iostat_default()
5498 na = '-'; in print_iostat_default()
5502 if (vs->vs_space == 0) { in print_iostat_default()
5503 if (cb->cb_scripted) in print_iostat_default()
5509 print_one_stat(vs->vs_alloc, format, column_width, in print_iostat_default()
5510 cb->cb_scripted); in print_iostat_default()
5511 print_one_stat(vs->vs_space - vs->vs_alloc, format, in print_iostat_default()
5512 column_width, cb->cb_scripted); in print_iostat_default()
5515 print_one_stat((uint64_t)(vs->vs_ops[ZIO_TYPE_READ] * scale), in print_iostat_default()
5516 format, column_width, cb->cb_scripted); in print_iostat_default()
5517 print_one_stat((uint64_t)(vs->vs_ops[ZIO_TYPE_WRITE] * scale), in print_iostat_default()
5518 format, column_width, cb->cb_scripted); in print_iostat_default()
5519 print_one_stat((uint64_t)(vs->vs_bytes[ZIO_TYPE_READ] * scale), in print_iostat_default()
5520 format, column_width, cb->cb_scripted); in print_iostat_default()
5521 print_one_stat((uint64_t)(vs->vs_bytes[ZIO_TYPE_WRITE] * scale), in print_iostat_default()
5522 format, column_width, cb->cb_scripted); in print_iostat_default()
5565 for (i = 0; i < cb->cb_vdevs.cb_names_count; i++) { in print_vdev_stats()
5567 if (strcmp(name, cb->cb_vdevs.cb_names[i]) == 0) { in print_vdev_stats()
5578 if (cb->cb_vdevs.cb_names_count && (i == cb->cb_vdevs.cb_names_count)) { in print_vdev_stats()
5591 if (!(cb->cb_flags & IOS_ANYHISTO_M)) { in print_vdev_stats()
5592 if (cb->cb_scripted) { in print_vdev_stats()
5595 if (strlen(name) + depth > cb->cb_namewidth) in print_vdev_stats()
5599 (int)(cb->cb_namewidth - strlen(name) - in print_vdev_stats()
5605 tdelta = newvs->vs_timestamp - oldvs->vs_timestamp; in print_vdev_stats()
5606 if ((oldvs->vs_timestamp == 0) && (cb->cb_flags & IOS_ANYHISTO_M)) { in print_vdev_stats()
5620 if (cb->cb_flags & IOS_DEFAULT_M) { in print_vdev_stats()
5624 if (cb->cb_flags & IOS_LATENCY_M) in print_vdev_stats()
5626 if (cb->cb_flags & IOS_QUEUES_M) in print_vdev_stats()
5628 if (cb->cb_flags & IOS_ANYHISTO_M) { in print_vdev_stats()
5633 if (cb->vcdl != NULL) { in print_vdev_stats()
5638 zpool_print_cmd(cb->vcdl, zpool_get_name(zhp), path); in print_vdev_stats()
5642 if (!(cb->cb_flags & IOS_ANYHISTO_M)) in print_vdev_stats()
5651 if (!cb->cb_verbose) in print_vdev_stats()
5667 * print normal top-level devices in print_vdev_stats()
5685 cb->cb_vdevs.cb_name_flags | VDEV_NAME_TYPE_ID); in print_vdev_stats()
5692 * print all other top-level devices in print_vdev_stats()
5718 if ((!(cb->cb_flags & IOS_ANYHISTO_M)) && in print_vdev_stats()
5719 !cb->cb_scripted && in print_vdev_stats()
5720 !cb->cb_vdevs.cb_names) { in print_vdev_stats()
5729 cb->cb_vdevs.cb_name_flags | VDEV_NAME_TYPE_ID); in print_vdev_stats()
5752 if ((!(cb->cb_flags & IOS_ANYHISTO_M)) && !cb->cb_scripted && in print_vdev_stats()
5753 !cb->cb_vdevs.cb_names) { in print_vdev_stats()
5760 cb->cb_vdevs.cb_name_flags); in print_vdev_stats()
5780 return (-1); in refresh_iostat()
5783 pool_list_remove(cb->cb_list, zhp); in refresh_iostat()
5801 if (cb->cb_iteration == 1) in print_iostat()
5815 if ((ret != 0) && !(cb->cb_flags & IOS_ANYHISTO_M) && in print_iostat()
5816 !cb->cb_scripted && cb->cb_verbose && in print_iostat()
5817 !cb->cb_vdevs.cb_names_count) { in print_iostat()
5819 if (cb->vcdl != NULL) { in print_iostat()
5820 print_cmd_columns(cb->vcdl, 1); in print_iostat()
5885 if (argc > 0 && zfs_isnumber(argv[argc - 1])) { in get_interval_count()
5889 interval = strtof(argv[argc - 1], &end); in get_interval_count()
5900 argc--; in get_interval_count()
5915 if (argc > 0 && zfs_isnumber(argv[argc - 1])) { in get_interval_count()
5920 interval = strtof(argv[argc - 1], &end); in get_interval_count()
5932 argc--; in get_interval_count()
6013 uint64_t mask = -1; in get_stat_flags()
6024 * Return 1 if cb_data->cb_names[0] is this vdev's name, 0 otherwise.
6036 return (guid == zpool_vdev_path_to_guid(zhp, cb->cb_names[0])); in is_vdev_cb()
6040 * Returns 1 if cb_data->cb_names[0] is a vdev name, 0 otherwise.
6070 tmp_name = cb->cb_names; in are_vdevs_in_pool()
6074 cb->cb_names = argv + i; in are_vdevs_in_pool()
6085 cb->cb_names = tmp_name; in are_vdevs_in_pool()
6117 while (--argc >= 0) in are_all_pools()
6164 if (*argc >= 1 && !are_vdevs_in_pool(1, &argv[*argc - 1], NULL, in get_interval_count_filter_guids()
6165 &cb->cb_vdevs)) { in get_interval_count_filter_guids()
6173 !are_vdevs_in_pool(1, &argv[*argc - 2], NULL, in get_interval_count_filter_guids()
6174 &cb->cb_vdevs)) { in get_interval_count_filter_guids()
6184 tmpargv = &argv[*argc - argc_for_interval]; in get_interval_count_filter_guids()
6186 *argc = *argc - argc_for_interval; in get_interval_count_filter_guids()
6192 * Terminal height, in rows. Returns -1 if stdout is not connected to a TTY or
6201 return (-1); in terminal_height()
6203 if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 && win.ws_row > 0) in terminal_height()
6206 return (-1); in terminal_height()
6210 * Run one of the zpool status/iostat -c scripts with the help (-h) option and
6219 char *argv[] = {path, (char *)"-h", NULL}; in print_zpool_script_help()
6234 printf(" %-14s %s\n", name, lines[i]); in print_zpool_script_help()
6240 * Go though the zpool status/iostat -c scripts in the user's path, run their
6241 * help option (-h), and print out the results.
6255 dirpath, ent->d_name) >= sizeof (fullpath)) { in print_zpool_dir_scripts()
6266 print_zpool_script_help(ent->d_name, in print_zpool_dir_scripts()
6274 * Print out help text for all zpool status/iostat -c scripts.
6281 printf(gettext("Available 'zpool %s -c' commands:\n"), subcommand); in print_zpool_script_list()
6297 * but may be as large as the column width - 42 so it still fits on one line.
6310 width = get_namewidth(zhp, cb->cb_namewidth, in get_namewidth_iostat()
6311 cb->cb_vdevs.cb_name_flags | VDEV_NAME_TYPE_ID, cb->cb_verbose); in get_namewidth_iostat()
6318 available_width = get_columns() - 42; in get_namewidth_iostat()
6340 cb->cb_namewidth = width; in get_namewidth_iostat()
6346 * zpool iostat [[-c [script1,script2,...]] [-lq]|[-rw]] [-ghHLpPvy] [-n name]
6347 * [-T d|u] [[ pool ...]|[pool vdev ...]|[vdev ...]]
6350 * -c CMD For each vdev, run command CMD
6351 * -g Display guid for individual vdev name.
6352 * -L Follow links when resolving vdev path name.
6353 * -P Display full path for vdev name.
6354 * -v Display statistics for individual vdevs
6355 * -h Display help
6356 * -p Display values in parsable (exact) format.
6357 * -H Scripted mode. Don't display headers, and separate properties
6359 * -l Display average latency
6360 * -q Display queue depths
6361 * -w Display latency histograms
6362 * -r Display request size histogram
6363 * -T Display a timestamp in date(1) or Unix format
6364 * -n Only print headers once
6400 while ((c = getopt(argc, argv, "c:gLPT:vyhplqrwnH")) != -1) { in zpool_do_iostat()
6405 gettext("Can't set -c flag twice\n")); in zpool_do_iostat()
6412 "Can't run -c, disabled by " in zpool_do_iostat()
6420 "Can't run -c with root privileges " in zpool_do_iostat()
6481 argc -= optind; in zpool_do_iostat()
6516 if (are_vdevs_in_pool(argc - 1, argv + 1, argv[0], in zpool_do_iostat()
6520 cb.cb_vdevs.cb_names_count = argc - 1; in zpool_do_iostat()
6527 error_list_unresolved_vdevs(argc - 1, argv + 1, in zpool_do_iostat()
6572 gettext("[-r|-w] isn't allowed with [-c|-l|-q]\n")); in zpool_do_iostat()
6580 gettext("Only one of [-r|-w] can be passed at a time\n")); in zpool_do_iostat()
6619 idx = lowbit64(f) - 1; in zpool_do_iostat()
6620 fprintf(stderr, " -%c", flag_to_arg[idx]); in zpool_do_iostat()
6634 * If this is the first iteration and -y was supplied in zpool_do_iostat()
6734 if (count != 0 && --count == 0) in zpool_do_iostat()
6766 zprop_list_t *pl = cb->cb_proplist; in print_header()
6773 for (; pl != NULL; pl = pl->pl_next) { in print_header()
6774 width = pl->pl_width; in print_header()
6775 if (first && cb->cb_verbose) { in print_header()
6780 width = cb->cb_namewidth; in print_header()
6789 if (pl->pl_prop != ZPROP_USERPROP) { in print_header()
6790 header = zpool_prop_column_name(pl->pl_prop); in print_header()
6791 right_justify = zpool_prop_align_right(pl->pl_prop); in print_header()
6795 for (i = 0; pl->pl_user_prop[i] != '\0'; i++) in print_header()
6796 headerbuf[i] = toupper(pl->pl_user_prop[i]); in print_header()
6801 if (pl->pl_next == NULL && !right_justify) in print_header()
6806 (void) printf("%-*s", (int)width, header); in print_header()
6819 zprop_list_t *pl = cb->cb_proplist; in collect_pool()
6829 if (cb->cb_json) { in collect_pool()
6832 d = fnvlist_lookup_nvlist(cb->cb_jsobj, "pools"); in collect_pool()
6837 fill_pool_info(item, zhp, B_TRUE, cb->cb_json_as_int); in collect_pool()
6840 for (; pl != NULL; pl = pl->pl_next) { in collect_pool()
6842 width = pl->pl_width; in collect_pool()
6843 if (first && cb->cb_verbose) { in collect_pool()
6848 width = cb->cb_namewidth; in collect_pool()
6851 if (!cb->cb_json && !first) { in collect_pool()
6852 if (cb->cb_scripted) in collect_pool()
6861 if (pl->pl_prop != ZPROP_USERPROP) { in collect_pool()
6862 if (zpool_get_prop(zhp, pl->pl_prop, property, in collect_pool()
6864 cb->cb_literal) != 0) in collect_pool()
6865 propstr = "-"; in collect_pool()
6869 right_justify = zpool_prop_align_right(pl->pl_prop); in collect_pool()
6870 } else if ((zpool_prop_feature(pl->pl_user_prop) || in collect_pool()
6871 zpool_prop_unsupported(pl->pl_user_prop)) && in collect_pool()
6872 zpool_prop_get_feature(zhp, pl->pl_user_prop, property, in collect_pool()
6876 } else if (zfs_prop_user(pl->pl_user_prop) && in collect_pool()
6877 zpool_get_userprop(zhp, pl->pl_user_prop, property, in collect_pool()
6881 propstr = "-"; in collect_pool()
6884 if (cb->cb_json) { in collect_pool()
6885 if (pl->pl_prop == ZPOOL_PROP_NAME) in collect_pool()
6888 if (pl->pl_prop != ZPROP_USERPROP) in collect_pool()
6889 prop_name = zpool_prop_to_name(pl->pl_prop); in collect_pool()
6891 prop_name = pl->pl_user_prop; in collect_pool()
6894 sourcetype, NULL, NULL, props, cb->cb_json_as_int); in collect_pool()
6898 * is the last column and it is left-justified, don't in collect_pool()
6901 if (cb->cb_scripted || (pl->pl_next == NULL && in collect_pool()
6907 (void) printf("%-*s", (int)width, propstr); in collect_pool()
6911 if (cb->cb_json) { in collect_pool()
6913 if (cb->cb_json_pool_key_guid) { in collect_pool()
6947 (void) strlcpy(propval, "-", sizeof (propval)); in collect_vdev_prop()
6954 (void) strlcpy(propval, "-", sizeof (propval)); in collect_vdev_prop()
6964 /* capacity value is in parts-per-10,000 (aka permyriad) */ in collect_vdev_prop()
6982 (void) strlcpy(propval, "-", sizeof (propval)); in collect_vdev_prop()
6997 * not compatible with '-o' <proplist> option
7007 boolean_t scripted = cb->cb_scripted; in collect_list_stats()
7011 const char *dashes = "%-*s - - - - " in collect_list_stats()
7012 "- - - - -\n"; in collect_list_stats()
7018 boolean_t toplevel = (vs->vs_space != 0); in collect_list_stats()
7023 if (cb->cb_literal) in collect_list_stats()
7031 if (cb->cb_json) { in collect_list_stats()
7035 cb->cb_json_as_int); in collect_list_stats()
7039 else if (strlen(name) + depth > cb->cb_namewidth) in collect_list_stats()
7043 (int)(cb->cb_namewidth - strlen(name) - in collect_list_stats()
7053 if (VDEV_STAT_VALID(vs_pspace, c) && vs->vs_pspace) { in collect_list_stats()
7054 collect_vdev_prop(ZPOOL_PROP_SIZE, vs->vs_pspace, NULL, in collect_list_stats()
7055 scripted, B_TRUE, format, cb->cb_json, props, in collect_list_stats()
7056 cb->cb_json_as_int); in collect_list_stats()
7058 collect_vdev_prop(ZPOOL_PROP_SIZE, vs->vs_space, NULL, in collect_list_stats()
7059 scripted, toplevel, format, cb->cb_json, props, in collect_list_stats()
7060 cb->cb_json_as_int); in collect_list_stats()
7062 collect_vdev_prop(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, NULL, in collect_list_stats()
7063 scripted, toplevel, format, cb->cb_json, props, in collect_list_stats()
7064 cb->cb_json_as_int); in collect_list_stats()
7065 collect_vdev_prop(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc, in collect_list_stats()
7066 NULL, scripted, toplevel, format, cb->cb_json, props, in collect_list_stats()
7067 cb->cb_json_as_int); in collect_list_stats()
7069 vs->vs_checkpoint_space, NULL, scripted, toplevel, format, in collect_list_stats()
7070 cb->cb_json, props, cb->cb_json_as_int); in collect_list_stats()
7071 collect_vdev_prop(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, NULL, in collect_list_stats()
7072 scripted, B_TRUE, format, cb->cb_json, props, in collect_list_stats()
7073 cb->cb_json_as_int); in collect_list_stats()
7075 vs->vs_fragmentation, NULL, scripted, in collect_list_stats()
7076 (vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel), in collect_list_stats()
7077 format, cb->cb_json, props, cb->cb_json_as_int); in collect_list_stats()
7078 cap = (vs->vs_space == 0) ? 0 : in collect_list_stats()
7079 (vs->vs_alloc * 10000 / vs->vs_space); in collect_list_stats()
7081 scripted, toplevel, format, cb->cb_json, props, in collect_list_stats()
7082 cb->cb_json_as_int); in collect_list_stats()
7084 scripted, toplevel, format, cb->cb_json, props, in collect_list_stats()
7085 cb->cb_json_as_int); in collect_list_stats()
7086 state = zpool_state_to_name(vs->vs_state, vs->vs_aux); in collect_list_stats()
7088 if (vs->vs_aux == VDEV_AUX_SPARED) in collect_list_stats()
7090 else if (vs->vs_state == VDEV_STATE_HEALTHY) in collect_list_stats()
7094 B_TRUE, format, cb->cb_json, props, cb->cb_json_as_int); in collect_list_stats()
7096 if (cb->cb_json) { in collect_list_stats()
7105 if (cb->cb_json) { in collect_list_stats()
7112 if (cb->cb_json) { in collect_list_stats()
7132 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in collect_list_stats()
7134 if (name == NULL || cb->cb_json != B_TRUE) in collect_list_stats()
7137 else if (cb->cb_json) { in collect_list_stats()
7144 if (cb->cb_json) { in collect_list_stats()
7153 if (cb->cb_json) in collect_list_stats()
7173 if (!printed && !cb->cb_json) { in collect_list_stats()
7175 (void) printf(dashes, cb->cb_namewidth, in collect_list_stats()
7180 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in collect_list_stats()
7185 if (cb->cb_json) { in collect_list_stats()
7194 if (cb->cb_json) { in collect_list_stats()
7198 (void) printf(dashes, cb->cb_namewidth, "cache"); in collect_list_stats()
7202 cb->cb_name_flags); in collect_list_stats()
7207 if (cb->cb_json) { in collect_list_stats()
7216 if (cb->cb_json) { in collect_list_stats()
7220 (void) printf(dashes, cb->cb_namewidth, "spare"); in collect_list_stats()
7224 cb->cb_name_flags); in collect_list_stats()
7229 if (cb->cb_json) { in collect_list_stats()
7236 if (name != NULL && cb->cb_json) { in collect_list_stats()
7257 if (cbp->cb_verbose) { in list_callback()
7262 if (cbp->cb_json) { in list_callback()
7263 d = fnvlist_lookup_nvlist(cbp->cb_jsobj, in list_callback()
7265 if (cbp->cb_json_pool_key_guid) { in list_callback()
7277 if (cbp->cb_json) { in list_callback()
7279 if (cbp->cb_json_pool_key_guid) in list_callback()
7283 fnvlist_add_nvlist(cbp->cb_jsobj, "pools", d); in list_callback()
7301 width = get_namewidth(zhp, cb->cb_namewidth, in get_namewidth_list()
7302 cb->cb_name_flags | VDEV_NAME_TYPE_ID, cb->cb_verbose); in get_namewidth_list()
7307 cb->cb_namewidth = width; in get_namewidth_list()
7313 * zpool list [-gHLpP] [-o prop[,prop]*] [-T d|u] [pool] ... [interval [count]]
7315 * -g Display guid for individual vdev name.
7316 * -H Scripted mode. Don't display headers, and separate properties
7318 * -L Follow links when resolving vdev path name.
7319 * -o List of properties to display. Defaults to
7322 * -p Display values in parsable (exact) format.
7323 * -P Display full path for vdev name.
7324 * -T Display a timestamp in date(1) or Unix format
7325 * -j Display the output in JSON format
7326 * --json-int Display the numbers as integer instead of strings.
7327 * --json-pool-key-guid Set pool GUID as key for pool objects.
7351 {"json-int", no_argument, NULL, ZPOOL_OPTION_JSON_NUMS_AS_INT}, in zpool_do_list()
7352 {"json-pool-key-guid", no_argument, NULL, in zpool_do_list()
7359 NULL)) != -1) { in zpool_do_list()
7408 argc -= optind; in zpool_do_list()
7412 (void) fprintf(stderr, gettext("'--json-int' only works with" in zpool_do_list()
7413 " '-j' option\n")); in zpool_do_list()
7418 (void) fprintf(stderr, gettext("'json-pool-key-guid' only" in zpool_do_list()
7419 " works with '-j' option\n")); in zpool_do_list()
7476 if (count != 0 && --count == 0) in zpool_do_list()
7511 while ((c = getopt(argc, argv, "fo:sw")) != -1) { in zpool_do_attach_or_replace()
7519 "'=' for -o option\n")); in zpool_do_attach_or_replace()
7542 argc -= optind; in zpool_do_attach_or_replace()
7568 argc -= 1; in zpool_do_attach_or_replace()
7572 argc -= 2; in zpool_do_attach_or_replace()
7639 * zpool replace [-fsw] [-o property=value] <pool> <device> <new_device>
7641 * -f Force attach, even if <new_device> appears to be in use.
7642 * -s Use sequential instead of healing reconstruction for resilver.
7643 * -o Set property=value.
7644 * -w Wait for replacing to complete before returning
7655 * zpool attach [-fsw] [-o property=value] <pool> <device>|<vdev> <new_device>
7657 * -f Force attach, even if <new_device> appears to be in use.
7658 * -s Use sequential instead of healing reconstruction for resilver.
7659 * -o Set property=value.
7660 * -w Wait for resilvering (mirror) or expansion (raidz) to complete
7678 * zpool detach [-f] <pool> <device>
7680 * -f Force detach of <device>, even if DTLs argue against it
7696 while ((c = getopt(argc, argv, "")) != -1) { in zpool_do_detach()
7705 argc -= optind; in zpool_do_detach()
7734 * zpool split [-gLnP] [-o prop=val] ...
7735 * [-o mntopt] ...
7736 * [-R altroot] <pool> <newpool> [<device> ...]
7738 * -g Display guid for individual vdev name.
7739 * -L Follow links when resolving vdev path name.
7740 * -n Do not split the pool, but display the resulting layout if
7742 * -o Set property=value, or set mount options.
7743 * -P Display full path for vdev name.
7744 * -R Mount the split-off pool under an alternate root.
7745 * -l Load encryption keys while importing.
7749 * per top-level vdev mirror. The newly split pool is left in an exported
7750 * state unless -R is specified.
7752 * Restrictions: the top-level of the pool pool must only be made up of
7773 while ((c = getopt(argc, argv, ":gLR:lno:P")) != -1) { in zpool_do_split()
7837 argc -= optind; in zpool_do_split()
7852 argc -= 2; in zpool_do_split()
7923 * zpool online [--power] <pool> <device> ...
7925 * --power: Power on the enclosure slot to the drive (if possible)
7943 while ((c = getopt_long(argc, argv, "e", long_options, NULL)) != -1) { in zpool_do_online()
7961 argc -= optind; in zpool_do_online()
8007 ZPOOL_CONFIG_VDEV_STATS, &vsc))->vs_state; in zpool_do_online()
8048 * zpool offline [-ft]|[--power] <pool> <device> ...
8051 * -f Force the device into a faulted state.
8053 * -t Only take the device off-line temporarily. The offline/faulted
8056 * --power Power off the enclosure slot to the drive (if possible)
8075 while ((c = getopt_long(argc, argv, "ft", long_options, NULL)) != -1) { in zpool_do_offline()
8095 gettext("-0 and -f cannot be used together\n")); in zpool_do_offline()
8102 gettext("-0 and -t cannot be used together\n")); in zpool_do_offline()
8107 argc -= optind; in zpool_do_offline()
8167 * zpool clear [-nF]|[--power] <pool> [device]
8192 NULL)) != -1) { in zpool_do_clear()
8216 argc -= optind; in zpool_do_clear()
8231 gettext("-n or -X only meaningful with -F\n")); in zpool_do_clear()
8275 * zpool reguid [-g <guid>] <pool>
8289 while ((c = getopt(argc, argv, "g:")) != -1) { in zpool_do_reguid()
8308 argc -= optind; in zpool_do_reguid()
8346 while ((c = getopt(argc, argv, "n")) != -1) { in zpool_do_reopen()
8358 argc -= optind; in zpool_do_reopen()
8388 if (pcs == NULL || pcs->pcs_state == CS_NONE) in zpool_has_checkpoint()
8391 assert(pcs->pcs_state == CS_CHECKPOINT_EXISTS || in zpool_has_checkpoint()
8392 pcs->pcs_state == CS_CHECKPOINT_DISCARDING); in zpool_has_checkpoint()
8414 err = zpool_scan(zhp, cb->cb_type, cb->cb_scrub_cmd); in scrub_callback()
8417 cb->cb_type == POOL_SCAN_SCRUB) { in scrub_callback()
8434 * zpool scrub [-e | -s | -p | -C] [-w] <pool> ...
8436 * -e Only scrub blocks in the error log.
8437 * -s Stop. Stops any in-progress scrub.
8438 * -p Pause. Pause in-progress scrub.
8439 * -w Wait. Blocks until scrub has completed.
8440 * -C Scrub from last saved txg.
8459 while ((c = getopt(argc, argv, "spweC")) != -1) { in zpool_do_scrub()
8485 "combination: -s and -p are mutually exclusive\n")); in zpool_do_scrub()
8489 "combination: -p and -C are mutually exclusive\n")); in zpool_do_scrub()
8493 "combination: -s and -C are mutually exclusive\n")); in zpool_do_scrub()
8497 "combination: -e and -C are mutually exclusive\n")); in zpool_do_scrub()
8517 "-w cannot be used with -p or -s\n")); in zpool_do_scrub()
8521 argc -= optind; in zpool_do_scrub()
8544 * Restarts any in-progress resilver
8556 while ((c = getopt(argc, argv, "")) != -1) { in zpool_do_resilver()
8565 argc -= optind; in zpool_do_resilver()
8578 * zpool trim [-d] [-r <rate>] [-c | -s] <pool> [<device> ...]
8580 * -c Cancel. Ends any in-progress trim.
8581 * -d Secure trim. Requires kernel and device support.
8582 * -r <rate> Sets the TRIM rate in bytes (per second). Supports
8584 * -s Suspend. TRIM can then be restarted with no flags.
8585 * -w Wait. Blocks until trimming has completed.
8606 != -1) { in zpool_do_trim()
8611 (void) fprintf(stderr, gettext("-c cannot be " in zpool_do_trim()
8619 (void) fprintf(stderr, gettext("-d cannot be " in zpool_do_trim()
8620 "combined with the -c or -s options\n")); in zpool_do_trim()
8627 (void) fprintf(stderr, gettext("-r cannot be " in zpool_do_trim()
8628 "combined with the -c or -s options\n")); in zpool_do_trim()
8631 if (zfs_nicestrtonum(g_zfs, optarg, &rate) == -1) { in zpool_do_trim()
8641 (void) fprintf(stderr, gettext("-s cannot be " in zpool_do_trim()
8657 argv[optind - 1]); in zpool_do_trim()
8663 argc -= optind; in zpool_do_trim()
8669 return (-1); in zpool_do_trim()
8673 (void) fprintf(stderr, gettext("-w cannot be used with -c or " in zpool_do_trim()
8674 "-s\n")); in zpool_do_trim()
8681 return (-1); in zpool_do_trim()
8746 if (ps == NULL || ps->pss_error_scrub_func != POOL_SCAN_ERRORSCRUB) { in print_err_scrub_status()
8752 start = ps->pss_error_scrub_start; in print_err_scrub_status()
8753 end = ps->pss_error_scrub_end; in print_err_scrub_status()
8754 pause = ps->pss_pass_error_scrub_pause; in print_err_scrub_status()
8755 examined = ps->pss_error_scrub_examined; in print_err_scrub_status()
8756 to_be_examined = ps->pss_error_scrub_to_be_examined; in print_err_scrub_status()
8758 assert(ps->pss_error_scrub_func == POOL_SCAN_ERRORSCRUB); in print_err_scrub_status()
8760 if (ps->pss_error_scrub_state == DSS_FINISHED) { in print_err_scrub_status()
8761 total_secs_left = end - start; in print_err_scrub_status()
8774 } else if (ps->pss_error_scrub_state == DSS_CANCELED) { in print_err_scrub_status()
8779 assert(ps->pss_error_scrub_state == DSS_ERRORSCRUBBING); in print_err_scrub_status()
8817 if (ps == NULL || ps->pss_func == POOL_SCAN_NONE || in print_scan_scrub_resilver_status()
8818 ps->pss_func >= POOL_SCAN_FUNCS) { in print_scan_scrub_resilver_status()
8823 start = ps->pss_start_time; in print_scan_scrub_resilver_status()
8824 end = ps->pss_end_time; in print_scan_scrub_resilver_status()
8825 pause = ps->pss_pass_scrub_pause; in print_scan_scrub_resilver_status()
8827 zfs_nicebytes(ps->pss_processed, processed_buf, sizeof (processed_buf)); in print_scan_scrub_resilver_status()
8829 int is_resilver = ps->pss_func == POOL_SCAN_RESILVER; in print_scan_scrub_resilver_status()
8830 int is_scrub = ps->pss_func == POOL_SCAN_SCRUB; in print_scan_scrub_resilver_status()
8834 if (ps->pss_state == DSS_FINISHED) { in print_scan_scrub_resilver_status()
8835 secs_to_dhms(end - start, time_buf); in print_scan_scrub_resilver_status()
8840 time_buf, (u_longlong_t)ps->pss_errors, in print_scan_scrub_resilver_status()
8845 time_buf, (u_longlong_t)ps->pss_errors, in print_scan_scrub_resilver_status()
8849 } else if (ps->pss_state == DSS_CANCELED) { in print_scan_scrub_resilver_status()
8860 assert(ps->pss_state == DSS_SCANNING); in print_scan_scrub_resilver_status()
8878 scanned = ps->pss_examined; in print_scan_scrub_resilver_status()
8879 pass_scanned = ps->pss_pass_exam; in print_scan_scrub_resilver_status()
8880 issued = ps->pss_issued; in print_scan_scrub_resilver_status()
8881 pass_issued = ps->pss_pass_issued; in print_scan_scrub_resilver_status()
8882 total_s = ps->pss_to_examine; in print_scan_scrub_resilver_status()
8883 total_i = ps->pss_to_examine - ps->pss_skipped; in print_scan_scrub_resilver_status()
8889 elapsed = time(NULL) - ps->pss_pass_start; in print_scan_scrub_resilver_status()
8890 elapsed -= ps->pss_pass_scrub_spent_paused; in print_scan_scrub_resilver_status()
8933 ((is_resilver && ps->pss_processed > 0) || in print_scan_scrub_resilver_status()
8935 secs_to_dhms((total_i - issued) / issue_rate, time_buf); in print_scan_scrub_resilver_status()
8949 if (vrs == NULL || vrs->vrs_state == VDEV_REBUILD_NONE) in print_rebuild_status_impl()
8956 uint64_t bytes_scanned = vrs->vrs_bytes_scanned; in print_rebuild_status_impl()
8957 uint64_t bytes_issued = vrs->vrs_bytes_issued; in print_rebuild_status_impl()
8958 uint64_t bytes_rebuilt = vrs->vrs_bytes_rebuilt; in print_rebuild_status_impl()
8959 uint64_t bytes_est_s = vrs->vrs_bytes_est; in print_rebuild_status_impl()
8960 uint64_t bytes_est_i = vrs->vrs_bytes_est; in print_rebuild_status_impl()
8962 bytes_est_i -= vrs->vrs_pass_bytes_skipped; in print_rebuild_status_impl()
8963 uint64_t scan_rate = (vrs->vrs_pass_bytes_scanned / in print_rebuild_status_impl()
8964 (vrs->vrs_pass_time_ms + 1)) * 1000; in print_rebuild_status_impl()
8965 uint64_t issue_rate = (vrs->vrs_pass_bytes_issued / in print_rebuild_status_impl()
8966 (vrs->vrs_pass_time_ms + 1)) * 1000; in print_rebuild_status_impl()
8983 time_t start = vrs->vrs_start_time; in print_rebuild_status_impl()
8984 time_t end = vrs->vrs_end_time; in print_rebuild_status_impl()
8987 if (vrs->vrs_state == VDEV_REBUILD_COMPLETE) { in print_rebuild_status_impl()
8988 secs_to_dhms(vrs->vrs_scan_time_ms / 1000, time_buf); in print_rebuild_status_impl()
8991 time_buf, (u_longlong_t)vrs->vrs_errors, ctime(&end)); in print_rebuild_status_impl()
8993 } else if (vrs->vrs_state == VDEV_REBUILD_CANCELED) { in print_rebuild_status_impl()
8997 } else if (vrs->vrs_state == VDEV_REBUILD_ACTIVE) { in print_rebuild_status_impl()
9002 assert(vrs->vrs_state == VDEV_REBUILD_ACTIVE); in print_rebuild_status_impl()
9022 if (vrs->vrs_state == VDEV_REBUILD_ACTIVE) { in print_rebuild_status_impl()
9025 secs_to_dhms((bytes_est_s - bytes_scanned) / scan_rate, in print_rebuild_status_impl()
9038 * Print rebuild status for top-level vdevs.
9077 if (pcs->pcs_state == CS_NONE || in print_checkpoint_scan_warning()
9078 pcs->pcs_state == CS_CHECKPOINT_DISCARDING) in print_checkpoint_scan_warning()
9081 assert(pcs->pcs_state == CS_CHECKPOINT_EXISTS); in print_checkpoint_scan_warning()
9083 if (ps->pss_state == DSS_NONE) in print_checkpoint_scan_warning()
9086 if ((ps->pss_state == DSS_FINISHED || ps->pss_state == DSS_CANCELED) && in print_checkpoint_scan_warning()
9087 ps->pss_end_time < pcs->pcs_start_time) in print_checkpoint_scan_warning()
9090 if (ps->pss_state == DSS_FINISHED || ps->pss_state == DSS_CANCELED) { in print_checkpoint_scan_warning()
9094 assert(ps->pss_state == DSS_SCANNING); in print_checkpoint_scan_warning()
9124 if (vrs->vrs_end_time > end_time) in check_rebuilding()
9125 end_time = vrs->vrs_end_time; in check_rebuilding()
9127 if (vrs->vrs_state == VDEV_REBUILD_ACTIVE) { in check_rebuilding()
9161 if (cb->cb_print_unhealthy && depth > 0 && in vdev_stats_nvlist()
9166 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in vdev_stats_nvlist()
9168 fill_vdev_info(vds, zhp, vname, B_FALSE, cb->cb_json_as_int); in vdev_stats_nvlist()
9169 if (cb->cb_flat_vdevs && parent != NULL) { in vdev_stats_nvlist()
9174 if (vs->vs_aux == VDEV_AUX_SPARED) { in vdev_stats_nvlist()
9177 } else if (vs->vs_state == VDEV_STATE_HEALTHY) in vdev_stats_nvlist()
9180 if (vs->vs_alloc) { in vdev_stats_nvlist()
9181 nice_num_str_nvlist(vds, "alloc_space", vs->vs_alloc, in vdev_stats_nvlist()
9182 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9185 if (vs->vs_space) { in vdev_stats_nvlist()
9186 nice_num_str_nvlist(vds, "total_space", vs->vs_space, in vdev_stats_nvlist()
9187 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9190 if (vs->vs_dspace) { in vdev_stats_nvlist()
9191 nice_num_str_nvlist(vds, "def_space", vs->vs_dspace, in vdev_stats_nvlist()
9192 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9195 if (vs->vs_rsize) { in vdev_stats_nvlist()
9196 nice_num_str_nvlist(vds, "rep_dev_size", vs->vs_rsize, in vdev_stats_nvlist()
9197 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9200 if (vs->vs_esize) { in vdev_stats_nvlist()
9201 nice_num_str_nvlist(vds, "ex_dev_size", vs->vs_esize, in vdev_stats_nvlist()
9202 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9205 if (vs->vs_self_healed) { in vdev_stats_nvlist()
9207 vs->vs_self_healed, cb->cb_literal, in vdev_stats_nvlist()
9208 cb->cb_json_as_int, ZFS_NICENUM_BYTES); in vdev_stats_nvlist()
9210 if (vs->vs_pspace) { in vdev_stats_nvlist()
9211 nice_num_str_nvlist(vds, "phys_space", vs->vs_pspace, in vdev_stats_nvlist()
9212 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9215 nice_num_str_nvlist(vds, "read_errors", vs->vs_read_errors, in vdev_stats_nvlist()
9216 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9217 nice_num_str_nvlist(vds, "write_errors", vs->vs_write_errors, in vdev_stats_nvlist()
9218 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9220 vs->vs_checksum_errors, cb->cb_literal, in vdev_stats_nvlist()
9221 cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9222 if (vs->vs_scan_processed) { in vdev_stats_nvlist()
9224 vs->vs_scan_processed, cb->cb_literal, in vdev_stats_nvlist()
9225 cb->cb_json_as_int, ZFS_NICENUM_BYTES); in vdev_stats_nvlist()
9227 if (vs->vs_checkpoint_space) { in vdev_stats_nvlist()
9229 vs->vs_checkpoint_space, cb->cb_literal, in vdev_stats_nvlist()
9230 cb->cb_json_as_int, ZFS_NICENUM_BYTES); in vdev_stats_nvlist()
9232 if (vs->vs_resilver_deferred) { in vdev_stats_nvlist()
9234 vs->vs_resilver_deferred, B_TRUE, in vdev_stats_nvlist()
9235 cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9238 nice_num_str_nvlist(vds, "slow_ios", vs->vs_slow_ios, in vdev_stats_nvlist()
9239 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9242 if (cb->cb_print_power) { in vdev_stats_nvlist()
9258 "-"); in vdev_stats_nvlist()
9261 fnvlist_add_string(vds, "power_state", "-"); in vdev_stats_nvlist()
9266 if (cb->cb_print_dio_verify) { in vdev_stats_nvlist()
9268 vs->vs_dio_verify_errors, cb->cb_literal, in vdev_stats_nvlist()
9269 cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9275 1, B_TRUE, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in vdev_stats_nvlist()
9278 } else if (vs->vs_aux != VDEV_AUX_NONE) { in vdev_stats_nvlist()
9279 fnvlist_add_string(vds, "aux", vdev_aux_str[vs->vs_aux]); in vdev_stats_nvlist()
9283 vs->vs_configured_ashift < vs->vs_physical_ashift) { in vdev_stats_nvlist()
9285 vs->vs_configured_ashift, B_TRUE, cb->cb_json_as_int, in vdev_stats_nvlist()
9288 vs->vs_physical_ashift, B_TRUE, cb->cb_json_as_int, in vdev_stats_nvlist()
9291 if (vs->vs_scan_removing != 0) { in vdev_stats_nvlist()
9292 nice_num_str_nvlist(vds, "removing", vs->vs_scan_removing, in vdev_stats_nvlist()
9293 B_TRUE, cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9294 } else if (VDEV_STAT_VALID(vs_noalloc, vsc) && vs->vs_noalloc != 0) { in vdev_stats_nvlist()
9295 nice_num_str_nvlist(vds, "noalloc", vs->vs_noalloc, in vdev_stats_nvlist()
9296 B_TRUE, cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9299 if (cb->vcdl != NULL) { in vdev_stats_nvlist()
9301 zpool_nvlist_cmd(cb->vcdl, zpool_get_name(zhp), in vdev_stats_nvlist()
9307 if (cb->cb_print_vdev_init) { in vdev_stats_nvlist()
9308 if (vs->vs_initialize_state != 0) { in vdev_stats_nvlist()
9309 uint64_t st = vs->vs_initialize_state; in vdev_stats_nvlist()
9313 vs->vs_initialize_bytes_done, in vdev_stats_nvlist()
9314 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9317 vs->vs_initialize_bytes_est, in vdev_stats_nvlist()
9318 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9321 vs->vs_initialize_action_time, in vdev_stats_nvlist()
9322 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9325 vs->vs_initialize_errors, in vdev_stats_nvlist()
9326 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9333 if (cb->cb_print_vdev_trim) { in vdev_stats_nvlist()
9334 if (vs->vs_trim_notsup == 0) { in vdev_stats_nvlist()
9335 if (vs->vs_trim_state != 0) { in vdev_stats_nvlist()
9336 uint64_t st = vs->vs_trim_state; in vdev_stats_nvlist()
9340 vs->vs_trim_bytes_done, in vdev_stats_nvlist()
9341 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9344 vs->vs_trim_bytes_est, in vdev_stats_nvlist()
9345 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9348 vs->vs_trim_action_time, in vdev_stats_nvlist()
9349 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9352 vs->vs_trim_errors, in vdev_stats_nvlist()
9353 cb->cb_literal, cb->cb_json_as_int, in vdev_stats_nvlist()
9360 vs->vs_trim_notsup, B_TRUE, in vdev_stats_nvlist()
9361 cb->cb_json_as_int, ZFS_NICENUM_1024); in vdev_stats_nvlist()
9367 if (cb->cb_flat_vdevs && children == 0) { in vdev_stats_nvlist()
9381 if (cb->cb_flat_vdevs) { in vdev_stats_nvlist()
9407 if (!cb->cb_flat_vdevs) in class_vdevs_nvlist()
9410 assert(zhp != NULL || !cb->cb_verbose); in class_vdevs_nvlist()
9421 cb->cb_name_flags | VDEV_NAME_TYPE_ID); in class_vdevs_nvlist()
9440 if (cb->cb_flat_vdevs) { in class_vdevs_nvlist()
9449 if (!cb->cb_flat_vdevs) { in class_vdevs_nvlist()
9466 if (!cb->cb_flat_vdevs) in l2cache_nvlist()
9469 if (cb->cb_flat_vdevs) { in l2cache_nvlist()
9478 if (!cb->cb_flat_vdevs) { in l2cache_nvlist()
9495 if (!cb->cb_flat_vdevs) in spares_nvlist()
9498 if (cb->cb_flat_vdevs) { in spares_nvlist()
9507 if (!cb->cb_flat_vdevs) { in spares_nvlist()
9522 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in errors_nvlist()
9523 if (nerr != 0 && cb->cb_verbose) { in errors_nvlist()
9570 nice_num_str_nvlist(item, "blocks", dds->dds_blocks, in ddt_stats_nvlist()
9571 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in ddt_stats_nvlist()
9572 nice_num_str_nvlist(item, "logical_size", dds->dds_lsize, in ddt_stats_nvlist()
9573 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in ddt_stats_nvlist()
9574 nice_num_str_nvlist(item, "physical_size", dds->dds_psize, in ddt_stats_nvlist()
9575 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in ddt_stats_nvlist()
9576 nice_num_str_nvlist(item, "deflated_size", dds->dds_dsize, in ddt_stats_nvlist()
9577 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in ddt_stats_nvlist()
9578 nice_num_str_nvlist(item, "ref_blocks", dds->dds_ref_blocks, in ddt_stats_nvlist()
9579 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in ddt_stats_nvlist()
9580 nice_num_str_nvlist(item, "ref_lsize", dds->dds_ref_lsize, in ddt_stats_nvlist()
9581 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in ddt_stats_nvlist()
9582 nice_num_str_nvlist(item, "ref_psize", dds->dds_ref_psize, in ddt_stats_nvlist()
9583 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in ddt_stats_nvlist()
9584 nice_num_str_nvlist(item, "ref_dsize", dds->dds_ref_dsize, in ddt_stats_nvlist()
9585 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in ddt_stats_nvlist()
9592 if (cb->cb_dedup_stats) { in dedup_stats_nvlist()
9607 nice_num_str_nvlist(dedup, "obj_count", ddo->ddo_count, in dedup_stats_nvlist()
9608 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in dedup_stats_nvlist()
9609 if (ddo->ddo_count == 0) { in dedup_stats_nvlist()
9617 nice_num_str_nvlist(dedup, "dspace", ddo->ddo_dspace, in dedup_stats_nvlist()
9618 cb->cb_literal, cb->cb_json_as_int, in dedup_stats_nvlist()
9620 nice_num_str_nvlist(dedup, "mspace", ddo->ddo_mspace, in dedup_stats_nvlist()
9621 cb->cb_literal, cb->cb_json_as_int, in dedup_stats_nvlist()
9624 * Squash cached size into in-core size to handle race. in dedup_stats_nvlist()
9629 cspace_prop = MIN(cspace_prop, ddo->ddo_mspace); in dedup_stats_nvlist()
9631 cb->cb_literal, cb->cb_json_as_int, in dedup_stats_nvlist()
9639 if (dds->dds_blocks == 0) in dedup_stats_nvlist()
9652 if (ddh->ddh_stat[h].dds_blocks != 0) { in dedup_stats_nvlist()
9654 ddt_stats_nvlist(&ddh->ddh_stat[h], cb, in dedup_stats_nvlist()
9695 assert(pres->pres_expanding_vdev < children); in raidz_expand_status_nvlist()
9698 child[pres->pres_expanding_vdev], 0); in raidz_expand_status_nvlist()
9699 fill_vdev_info(nv, zhp, name, B_FALSE, cb->cb_json_as_int); in raidz_expand_status_nvlist()
9701 pool_scan_state_str[pres->pres_state]); in raidz_expand_status_nvlist()
9703 pres->pres_expanding_vdev, B_TRUE, cb->cb_json_as_int, in raidz_expand_status_nvlist()
9705 nice_num_str_nvlist(nv, "start_time", pres->pres_start_time, in raidz_expand_status_nvlist()
9706 cb->cb_literal, cb->cb_json_as_int, ZFS_NICE_TIMESTAMP); in raidz_expand_status_nvlist()
9707 nice_num_str_nvlist(nv, "end_time", pres->pres_end_time, in raidz_expand_status_nvlist()
9708 cb->cb_literal, cb->cb_json_as_int, ZFS_NICE_TIMESTAMP); in raidz_expand_status_nvlist()
9709 nice_num_str_nvlist(nv, "to_reflow", pres->pres_to_reflow, in raidz_expand_status_nvlist()
9710 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in raidz_expand_status_nvlist()
9711 nice_num_str_nvlist(nv, "reflowed", pres->pres_reflowed, in raidz_expand_status_nvlist()
9712 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in raidz_expand_status_nvlist()
9714 pres->pres_waiting_for_resilver, B_TRUE, in raidz_expand_status_nvlist()
9715 cb->cb_json_as_int, ZFS_NICENUM_1024); in raidz_expand_status_nvlist()
9732 checkpoint_state_str[pcs->pcs_state]); in checkpoint_status_nvlist()
9734 pcs->pcs_start_time, cb->cb_literal, cb->cb_json_as_int, in checkpoint_status_nvlist()
9737 pcs->pcs_space, cb->cb_literal, cb->cb_json_as_int, in checkpoint_status_nvlist()
9752 if (prs->prs_state != DSS_NONE) { in removal_status_nvlist()
9757 assert(prs->prs_removing_vdev < children); in removal_status_nvlist()
9759 child[prs->prs_removing_vdev], B_TRUE); in removal_status_nvlist()
9762 cb->cb_json_as_int); in removal_status_nvlist()
9764 pool_scan_state_str[prs->prs_state]); in removal_status_nvlist()
9766 prs->prs_removing_vdev, B_TRUE, cb->cb_json_as_int, in removal_status_nvlist()
9769 prs->prs_start_time, cb->cb_literal, in removal_status_nvlist()
9770 cb->cb_json_as_int, ZFS_NICE_TIMESTAMP); in removal_status_nvlist()
9771 nice_num_str_nvlist(nv, "end_time", prs->prs_end_time, in removal_status_nvlist()
9772 cb->cb_literal, cb->cb_json_as_int, in removal_status_nvlist()
9774 nice_num_str_nvlist(nv, "to_copy", prs->prs_to_copy, in removal_status_nvlist()
9775 cb->cb_literal, cb->cb_json_as_int, in removal_status_nvlist()
9777 nice_num_str_nvlist(nv, "copied", prs->prs_copied, in removal_status_nvlist()
9778 cb->cb_literal, cb->cb_json_as_int, in removal_status_nvlist()
9781 prs->prs_mapping_memory, cb->cb_literal, in removal_status_nvlist()
9782 cb->cb_json_as_int, ZFS_NICENUM_BYTES); in removal_status_nvlist()
9804 pool_scan_func_str[ps->pss_func]); in scan_status_nvlist()
9806 pool_scan_state_str[ps->pss_state]); in scan_status_nvlist()
9807 nice_num_str_nvlist(scan, "start_time", ps->pss_start_time, in scan_status_nvlist()
9808 cb->cb_literal, cb->cb_json_as_int, ZFS_NICE_TIMESTAMP); in scan_status_nvlist()
9809 nice_num_str_nvlist(scan, "end_time", ps->pss_end_time, in scan_status_nvlist()
9810 cb->cb_literal, cb->cb_json_as_int, ZFS_NICE_TIMESTAMP); in scan_status_nvlist()
9811 nice_num_str_nvlist(scan, "to_examine", ps->pss_to_examine, in scan_status_nvlist()
9812 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9813 nice_num_str_nvlist(scan, "examined", ps->pss_examined, in scan_status_nvlist()
9814 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9815 nice_num_str_nvlist(scan, "skipped", ps->pss_skipped, in scan_status_nvlist()
9816 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9817 nice_num_str_nvlist(scan, "processed", ps->pss_processed, in scan_status_nvlist()
9818 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9819 nice_num_str_nvlist(scan, "errors", ps->pss_errors, in scan_status_nvlist()
9820 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_1024); in scan_status_nvlist()
9821 nice_num_str_nvlist(scan, "bytes_per_scan", ps->pss_pass_exam, in scan_status_nvlist()
9822 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9823 nice_num_str_nvlist(scan, "pass_start", ps->pss_pass_start, in scan_status_nvlist()
9824 B_TRUE, cb->cb_json_as_int, ZFS_NICENUM_1024); in scan_status_nvlist()
9826 ps->pss_pass_scrub_pause, cb->cb_literal, in scan_status_nvlist()
9827 cb->cb_json_as_int, ZFS_NICE_TIMESTAMP); in scan_status_nvlist()
9829 ps->pss_pass_scrub_spent_paused, in scan_status_nvlist()
9830 B_TRUE, cb->cb_json_as_int, ZFS_NICENUM_1024); in scan_status_nvlist()
9832 ps->pss_pass_issued, cb->cb_literal, in scan_status_nvlist()
9833 cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9834 nice_num_str_nvlist(scan, "issued", ps->pss_issued, in scan_status_nvlist()
9835 cb->cb_literal, cb->cb_json_as_int, ZFS_NICENUM_BYTES); in scan_status_nvlist()
9836 if (ps->pss_error_scrub_func == POOL_SCAN_ERRORSCRUB && in scan_status_nvlist()
9837 ps->pss_error_scrub_start > ps->pss_start_time) { in scan_status_nvlist()
9839 pool_scan_func_str[ps->pss_error_scrub_func]); in scan_status_nvlist()
9841 pool_scan_state_str[ps->pss_error_scrub_state]); in scan_status_nvlist()
9843 ps->pss_error_scrub_start, in scan_status_nvlist()
9844 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9847 ps->pss_error_scrub_end, in scan_status_nvlist()
9848 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9851 ps->pss_error_scrub_examined, in scan_status_nvlist()
9852 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9855 ps->pss_error_scrub_to_be_examined, in scan_status_nvlist()
9856 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9859 ps->pss_pass_error_scrub_pause, in scan_status_nvlist()
9860 B_TRUE, cb->cb_json_as_int, ZFS_NICENUM_1024); in scan_status_nvlist()
9876 if (vrs->vrs_state != VDEV_REBUILD_NONE) { in scan_status_nvlist()
9881 cb->cb_json_as_int); in scan_status_nvlist()
9882 st = vrs->vrs_state; in scan_status_nvlist()
9886 vrs->vrs_start_time, cb->cb_literal, in scan_status_nvlist()
9887 cb->cb_json_as_int, in scan_status_nvlist()
9890 vrs->vrs_end_time, cb->cb_literal, in scan_status_nvlist()
9891 cb->cb_json_as_int, in scan_status_nvlist()
9894 vrs->vrs_scan_time_ms * 1000000, in scan_status_nvlist()
9895 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9898 vrs->vrs_bytes_scanned, in scan_status_nvlist()
9899 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9902 vrs->vrs_bytes_issued, in scan_status_nvlist()
9903 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9906 vrs->vrs_bytes_rebuilt, in scan_status_nvlist()
9907 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9910 vrs->vrs_bytes_est, cb->cb_literal, in scan_status_nvlist()
9911 cb->cb_json_as_int, in scan_status_nvlist()
9914 vrs->vrs_errors, cb->cb_literal, in scan_status_nvlist()
9915 cb->cb_json_as_int, in scan_status_nvlist()
9918 vrs->vrs_pass_time_ms * 1000000, in scan_status_nvlist()
9919 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9922 vrs->vrs_pass_bytes_scanned, in scan_status_nvlist()
9923 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9926 vrs->vrs_pass_bytes_issued, in scan_status_nvlist()
9927 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9930 vrs->vrs_pass_bytes_skipped, in scan_status_nvlist()
9931 cb->cb_literal, cb->cb_json_as_int, in scan_status_nvlist()
9965 if (ps->pss_func == POOL_SCAN_RESILVER) { in print_scan_status()
9966 resilver_end_time = ps->pss_end_time; in print_scan_status()
9967 active_resilver = (ps->pss_state == DSS_SCANNING); in print_scan_status()
9970 have_resilver = (ps->pss_func == POOL_SCAN_RESILVER); in print_scan_status()
9971 have_scrub = (ps->pss_func == POOL_SCAN_SCRUB); in print_scan_status()
9972 scrub_start = ps->pss_start_time; in print_scan_status()
9975 have_errorscrub = (ps->pss_error_scrub_func == in print_scan_status()
9977 errorscrub_start = ps->pss_error_scrub_start; in print_scan_status()
10020 if (prs == NULL || prs->prs_state == DSS_NONE) in print_removal_status()
10031 assert(prs->prs_removing_vdev < children); in print_removal_status()
10033 child[prs->prs_removing_vdev], B_TRUE); in print_removal_status()
10037 start = prs->prs_start_time; in print_removal_status()
10038 end = prs->prs_end_time; in print_removal_status()
10039 zfs_nicenum(prs->prs_copied, copied_buf, sizeof (copied_buf)); in print_removal_status()
10044 if (prs->prs_state == DSS_FINISHED) { in print_removal_status()
10045 uint64_t minutes_taken = (end - start) / 60; in print_removal_status()
10049 (longlong_t)prs->prs_removing_vdev, in print_removal_status()
10054 } else if (prs->prs_state == DSS_CANCELED) { in print_removal_status()
10061 assert(prs->prs_state == DSS_SCANNING); in print_removal_status()
10070 copied = prs->prs_copied > 0 ? prs->prs_copied : 1; in print_removal_status()
10071 total = prs->prs_to_copy; in print_removal_status()
10075 elapsed = time(NULL) - prs->prs_start_time; in print_removal_status()
10079 mins_left = ((total - copied) / rate) / 60; in print_removal_status()
10103 if (prs->prs_mapping_memory > 0) { in print_removal_status()
10105 zfs_nicenum(prs->prs_mapping_memory, mem_buf, sizeof (mem_buf)); in print_removal_status()
10120 if (pres == NULL || pres->pres_state == DSS_NONE) in print_raidz_expand_status()
10133 assert(pres->pres_expanding_vdev < children); in print_raidz_expand_status()
10137 time_t start = pres->pres_start_time; in print_raidz_expand_status()
10138 time_t end = pres->pres_end_time; in print_raidz_expand_status()
10140 zpool_vdev_name(g_zfs, zhp, child[pres->pres_expanding_vdev], 0); in print_raidz_expand_status()
10141 zfs_nicenum(pres->pres_reflowed, copied_buf, sizeof (copied_buf)); in print_raidz_expand_status()
10146 if (pres->pres_state == DSS_FINISHED) { in print_raidz_expand_status()
10148 secs_to_dhms(end - start, time_buf); in print_raidz_expand_status()
10150 (void) printf(gettext("expanded %s-%u copied %s in %s, " in print_raidz_expand_status()
10151 "on %s"), vname, (int)pres->pres_expanding_vdev, in print_raidz_expand_status()
10158 assert(pres->pres_state == DSS_SCANNING); in print_raidz_expand_status()
10164 "expansion of %s-%u in progress since %s"), in print_raidz_expand_status()
10165 vname, (int)pres->pres_expanding_vdev, ctime(&start)); in print_raidz_expand_status()
10167 copied = pres->pres_reflowed > 0 ? pres->pres_reflowed : 1; in print_raidz_expand_status()
10168 total = pres->pres_to_reflow; in print_raidz_expand_status()
10172 elapsed = time(NULL) - pres->pres_start_time; in print_raidz_expand_status()
10176 secs_left = (total - copied) / rate; in print_raidz_expand_status()
10188 if (pres->pres_waiting_for_resilver) { in print_raidz_expand_status()
10208 if (pcs == NULL || pcs->pcs_state == CS_NONE) in print_checkpoint_status()
10213 start = pcs->pcs_start_time; in print_checkpoint_status()
10214 zfs_nicenum(pcs->pcs_space, space_buf, sizeof (space_buf)); in print_checkpoint_status()
10216 if (pcs->pcs_state == CS_CHECKPOINT_EXISTS) { in print_checkpoint_status()
10225 (int)(strlen(date) - 1), date, space_buf); in print_checkpoint_status()
10229 assert(pcs->pcs_state == CS_CHECKPOINT_DISCARDING); in print_checkpoint_status()
10281 cb->cb_name_flags); in print_spares()
10301 cb->cb_name_flags); in print_l2cache()
10332 if (ddo->ddo_count == 0) { in print_dedup_stats()
10338 * Squash cached size into in-core size to handle race. in print_dedup_stats()
10342 cspace_prop = MIN(cspace_prop, ddo->ddo_mspace); in print_dedup_stats()
10345 zfs_nicenum_format(ddo->ddo_dspace, dspace, sizeof (dspace), format); in print_dedup_stats()
10346 zfs_nicenum_format(ddo->ddo_mspace, mspace, sizeof (mspace), format); in print_dedup_stats()
10348 (u_longlong_t)ddo->ddo_count, in print_dedup_stats()
10354 (double)cspace_prop / (double)ddo->ddo_mspace * 100.0); in print_dedup_stats()
10479 "a legacy on-disk format. The pool can\n\tstill be used, " in print_status_reason()
10489 "to a newer, incompatible on-disk version.\n\tThe pool " in print_status_reason()
10504 "the features. See zpool-features(7) for details.\n")); in print_status_reason()
10541 "accessed in read-only mode on this system. It\n\tcannot be" in print_status_reason()
10542 " accessed in read-write mode because it uses the " in print_status_reason()
10547 "in read-write mode. Import the pool with\n" in print_status_reason()
10548 "\t\"-o readonly=on\", access the pool from a system that " in print_status_reason()
10567 snprintf(action, AC_SIZE, gettext("Destroy and re-create the " in print_status_reason()
10603 "configured to use a non-native block size.\n" in print_status_reason()
10635 "datasets contain an on-disk incompatibility\n\t " in print_status_reason()
10640 "'zfs mount -o ro' can\n\tbe used to temporarily " in print_status_reason()
10646 "snapshots and bookmarks contain an on-disk\n\t" in print_status_reason()
10647 "incompatibility. This may cause on-disk " in print_status_reason()
10655 " use\n\ta non-raw send to backup and restore them." in print_status_reason()
10677 if (cbp->cb_json) in print_status_reason()
10686 if (cbp->cb_json) in print_status_reason()
10712 if (cbp->cb_dedup_stats > 1) in status_callback_json()
10716 * If we were given 'zpool status -x', only report those pools with in status_callback_json()
10719 if (cbp->cb_explain && in status_callback_json()
10728 d = fnvlist_lookup_nvlist(cbp->cb_jsobj, "pools"); in status_callback_json()
10731 fill_pool_info(item, zhp, B_FALSE, cbp->cb_json_as_int); in status_callback_json()
10738 if (cbp->cb_json_pool_key_guid) { in status_callback_json()
10743 cbp->cb_count++; in status_callback_json()
10748 "https://openzfs.github.io/openzfs-docs/msg/%s", in status_callback_json()
10765 if (cbp->cb_flat_vdevs) { in status_callback_json()
10793 if (cbp->cb_json_pool_key_guid) { in status_callback_json()
10809 * see: https://openzfs.github.io/openzfs-docs/msg/ZFS-xxxx-01
10815 * When given the '-v' option, we print out the complete config. If the '-e'
10831 if (cbp->cb_dedup_stats > 1) in status_callback()
10837 cbp->cb_count++; in status_callback()
10840 * If we were given 'zpool status -x', only report those pools with in status_callback()
10843 if (cbp->cb_explain && in status_callback()
10849 if (!cbp->cb_allpools) { in status_callback()
10852 if (cbp->cb_first) in status_callback()
10853 cbp->cb_first = B_FALSE; in status_callback()
10858 if (cbp->cb_first) in status_callback()
10859 cbp->cb_first = B_FALSE; in status_callback()
10884 " https://openzfs.github.io/openzfs-docs/msg/%s\n"), in status_callback()
10910 cbp->cb_namewidth = max_width(zhp, nvroot, 0, 0, in status_callback()
10911 cbp->cb_name_flags | VDEV_NAME_TYPE_ID); in status_callback()
10912 if (cbp->cb_namewidth < 10) in status_callback()
10913 cbp->cb_namewidth = 10; in status_callback()
10917 (void) printf(gettext("\t%-*s %-8s %5s %5s %5s"), in status_callback()
10918 cbp->cb_namewidth, "NAME", "STATE", "READ", "WRITE", in status_callback()
10922 if (cbp->cb_print_slow_ios) { in status_callback()
10926 if (cbp->cb_print_power) { in status_callback()
10930 if (cbp->cb_print_dio_verify) { in status_callback()
10934 if (cbp->vcdl != NULL) in status_callback()
10935 print_cmd_columns(cbp->vcdl, 0); in status_callback()
10960 } else if (!cbp->cb_verbose) { in status_callback()
10963 "errors, use '-v' for a list\n"), in status_callback()
10971 if (cbp->cb_dedup_stats) in status_callback()
10972 print_dedup_stats(zhp, config, cbp->cb_literal); in status_callback()
10982 * zpool status [-dDegiLpPstvx] [-c [script1,script2,...]] ...
10983 * [-j|--json [--json-flat-vdevs] [--json-int] ...
10984 * [--json-pool-key-guid]] [--power] [-T d|u] ...
10987 * -c CMD For each vdev, run command CMD
10988 * -D Display dedup status (undocumented)
10989 * -d Display Direct I/O write verify errors
10990 * -e Display only unhealthy vdevs
10991 * -g Display guid for individual vdev name.
10992 * -i Display vdev initialization status.
10993 * -j [...] Display output in JSON format
10994 * --json-flat-vdevs Display vdevs in flat hierarchy
10995 * --json-int Display numbers in integer format instead of string
10996 * --json-pool-key-guid Use pool GUID as key for pool objects
10997 * -L Follow links when resolving vdev path name.
10998 * -P Display full path for vdev name.
10999 * -p Display values in parsable (exact) format.
11000 * --power Display vdev enclosure slot power status
11001 * -s Display slow IOs column.
11002 * -T Display a timestamp in date(1) or Unix format
11003 * -t Display vdev TRIM status.
11004 * -v Display complete error logs
11005 * -x Display only pools with potential problems
11023 {"json-int", no_argument, NULL, ZPOOL_OPTION_JSON_NUMS_AS_INT}, in zpool_do_status()
11024 {"json-flat-vdevs", no_argument, NULL, in zpool_do_status()
11026 {"json-pool-key-guid", no_argument, NULL, in zpool_do_status()
11033 NULL)) != -1) { in zpool_do_status()
11038 gettext("Can't set -c flag twice\n")); in zpool_do_status()
11045 "Can't run -c, disabled by " in zpool_do_status()
11053 "Can't run -c with root privileges " in zpool_do_status()
11127 argc -= optind; in zpool_do_status()
11139 fprintf(stderr, gettext("'--json-flat-vdevs' only works with" in zpool_do_status()
11140 " '-j' option\n")); in zpool_do_status()
11145 (void) fprintf(stderr, gettext("'--json-int' only works with" in zpool_do_status()
11146 " '-j' option\n")); in zpool_do_status()
11151 (void) fprintf(stderr, gettext("'json-pool-key-guid' only" in zpool_do_status()
11152 " works with '-j' option\n")); in zpool_do_status()
11218 if (count != 0 && --count == 0) in zpool_do_status()
11326 return (-1); in upgrade_enable_all()
11338 verify(-1 != asprintf(&propname, "feature@%s", fname)); in upgrade_enable_all()
11378 if (version < cbp->cb_version) { in upgrade_cb()
11379 cbp->cb_first = B_FALSE; in upgrade_cb()
11380 ret = upgrade_version(zhp, cbp->cb_version); in upgrade_cb()
11386 * If they did "zpool upgrade -a", then we could in upgrade_cb()
11395 if (cbp->cb_version >= SPA_VERSION_FEATURES) { in upgrade_cb()
11402 cbp->cb_first = B_FALSE; in upgrade_cb()
11429 if (cbp->cb_first) { in upgrade_list_older_cb()
11440 (void) printf(gettext("--- ------------\n")); in upgrade_list_older_cb()
11441 cbp->cb_first = B_FALSE; in upgrade_list_older_cb()
11475 if (cbp->cb_first) { in upgrade_list_disabled_cb()
11483 "zpool-features(7) for " in upgrade_list_disabled_cb()
11491 (void) printf(gettext("------" in upgrade_list_disabled_cb()
11492 "---------\n")); in upgrade_list_disabled_cb()
11493 cbp->cb_first = B_FALSE; in upgrade_list_disabled_cb()
11505 * If they did "zpool upgrade -a", then we could in upgrade_list_disabled_cb()
11534 if (cur_version > cbp->cb_version) { in upgrade_one()
11541 if (cbp->cb_version != SPA_VERSION && cur_version == cbp->cb_version) { in upgrade_one()
11544 (u_longlong_t)cbp->cb_version); in upgrade_one()
11548 if (cur_version != cbp->cb_version) { in upgrade_one()
11550 ret = upgrade_version(zhp, cbp->cb_version); in upgrade_one()
11555 if (cbp->cb_version >= SPA_VERSION_FEATURES) { in upgrade_one()
11580 * zpool upgrade -v
11581 * zpool upgrade [-V version] <-a | pool ...>
11584 * Individual pools can be upgraded by specifying the pool, and '-a' will
11599 while ((c = getopt(argc, argv, ":avV:")) != -1) { in zpool_do_upgrade()
11630 argc -= optind; in zpool_do_upgrade()
11636 (void) fprintf(stderr, gettext("-V option is " in zpool_do_upgrade()
11643 (void) fprintf(stderr, gettext("-v option is " in zpool_do_upgrade()
11649 (void) fprintf(stderr, gettext("-a option should not " in zpool_do_upgrade()
11663 (void) printf("----------------------------------------------" in zpool_do_upgrade()
11664 "---------------\n"); in zpool_do_upgrade()
11667 if (!fi->fi_zfs_mod_supported) in zpool_do_upgrade()
11670 (fi->fi_flags & ZFEATURE_FLAG_READONLY_COMPAT) ? in zpool_do_upgrade()
11671 " (read-only compatible)" : ""; in zpool_do_upgrade()
11673 (void) printf("%-37s%s\n", fi->fi_uname, ro); in zpool_do_upgrade()
11674 (void) printf(" %s\n", fi->fi_desc); in zpool_do_upgrade()
11681 (void) printf("--- -----------------------------------------" in zpool_do_upgrade()
11682 "---------------\n"); in zpool_do_upgrade()
11687 "RAID-Z\n")); in zpool_do_upgrade()
11700 (void) printf(gettext(" 14 passthrough-x aclinherit\n")); in zpool_do_upgrade()
11703 (void) printf(gettext(" 17 Triple-parity RAID-Z\n")); in zpool_do_upgrade()
11707 "(zero-length encoding)\n")); in zpool_do_upgrade()
11746 (void) printf(gettext("\nUse 'zpool upgrade -v' " in zpool_do_upgrade()
11801 sizeof (tbuf) - strlen(tbuf), in print_history_records()
11811 if (!cb->internal) in print_history_records()
11825 if (!cb->internal) in print_history_records()
11841 if (!cb->internal) in print_history_records()
11867 if (!cb->internal) in print_history_records()
11873 if (!cb->longfmt) { in print_history_records()
11883 (void) printf("(%s) ", pwd->pw_name); in print_history_records()
11911 cb->first = B_FALSE; in get_history_one()
11941 while ((c = getopt(argc, argv, "li")) != -1) { in zpool_do_history()
11955 argc -= optind; in zpool_do_history()
11992 if (opts->scripted) in zpool_do_events_short()
12275 if (!opts->scripted) in zpool_do_events_next()
12276 (void) printf(gettext("%-30s %s\n"), "TIME", "CLASS"); in zpool_do_events_next()
12280 (opts->follow ? ZEVENT_NONE : ZEVENT_NONBLOCK), zevent_fd); in zpool_do_events_next()
12287 if (strlen(opts->poolname) > 0 && in zpool_do_events_next()
12289 strcmp(opts->poolname, pool) != 0) in zpool_do_events_next()
12294 if (opts->verbose) { in zpool_do_events_next()
12321 * zpool events [-vHf [pool] | -c]
12333 while ((c = getopt(argc, argv, "vHfc")) != -1) { in zpool_do_events()
12353 argc -= optind; in zpool_do_events()
12371 gettext("invalid options combined with -c\n")); in zpool_do_events()
12392 if (cbp->cb_json) { in get_callback_vdev()
12393 d = fnvlist_lookup_nvlist(cbp->cb_jsobj, "vdevs"); in get_callback_vdev()
12401 for (zprop_list_t *pl = cbp->cb_proplist; pl != NULL; in get_callback_vdev()
12402 pl = pl->pl_next) { in get_callback_vdev()
12409 if (pl->pl_prop == ZPOOL_PROP_NAME && in get_callback_vdev()
12410 pl == cbp->cb_proplist) in get_callback_vdev()
12413 if (pl->pl_prop == ZPROP_INVAL) { in get_callback_vdev()
12414 prop_name = pl->pl_user_prop; in get_callback_vdev()
12416 prop_name = (char *)vdev_prop_to_name(pl->pl_prop); in get_callback_vdev()
12418 if (zpool_get_vdev_prop(zhp, vdevname, pl->pl_prop, in get_callback_vdev()
12420 cbp->cb_literal) == 0) { in get_callback_vdev()
12426 if (cbp->cb_json) { in get_callback_vdev()
12430 cbp->cb_json_as_int); in get_callback_vdev()
12433 fnvlist_add_nvlist(cbp->cb_jsobj, "vdevs", d); in get_callback_vdev()
12452 * zpool_vdev_name() transforms the root vdev name (i.e., root-0) to the in get_callback_vdev_cb()
12458 vdevname = strdup("root-0"); in get_callback_vdev_cb()
12461 cbp->cb_vdevs.cb_name_flags); in get_callback_vdev_cb()
12463 (void) vdev_expand_proplist(zhp, vdevname, &cbp->cb_proplist); in get_callback_vdev_cb()
12484 if (cbp->cb_type == ZFS_TYPE_VDEV) { in get_callback()
12485 if (cbp->cb_json) { in get_callback()
12487 fill_pool_info(pool, zhp, B_FALSE, cbp->cb_json_as_int); in get_callback()
12488 fnvlist_add_nvlist(cbp->cb_jsobj, "pool", pool); in get_callback()
12492 if (strcmp(cbp->cb_vdevs.cb_names[0], "all-vdevs") == 0) { in get_callback()
12496 for (vid = 0; vid < cbp->cb_vdevs.cb_names_count; in get_callback()
12499 cbp->cb_vdevs.cb_names[vid], in get_callback()
12500 &cbp->cb_proplist); in get_callback()
12503 for (vid = 0; vid < cbp->cb_vdevs.cb_names_count; in get_callback()
12506 cbp->cb_vdevs.cb_names[vid], data); in get_callback()
12510 assert(cbp->cb_type == ZFS_TYPE_POOL); in get_callback()
12511 if (cbp->cb_json) { in get_callback()
12512 d = fnvlist_lookup_nvlist(cbp->cb_jsobj, "pools"); in get_callback()
12519 for (pl = cbp->cb_proplist; pl != NULL; pl = pl->pl_next) { in get_callback()
12524 if (pl->pl_prop == ZPOOL_PROP_NAME && in get_callback()
12525 pl == cbp->cb_proplist) in get_callback()
12528 if (pl->pl_prop == ZPROP_INVAL && in get_callback()
12529 zfs_prop_user(pl->pl_user_prop)) { in get_callback()
12532 if (zpool_get_userprop(zhp, pl->pl_user_prop, in get_callback()
12537 zpool_get_name(zhp), cbp, pl->pl_user_prop, in get_callback()
12539 } else if (pl->pl_prop == ZPROP_INVAL && in get_callback()
12540 (zpool_prop_feature(pl->pl_user_prop) || in get_callback()
12541 zpool_prop_unsupported(pl->pl_user_prop))) { in get_callback()
12545 pl->pl_user_prop, value, in get_callback()
12549 pl->pl_user_prop, value, srctype, in get_callback()
12553 if (zpool_get_prop(zhp, pl->pl_prop, value, in get_callback()
12555 cbp->cb_literal) != 0) in get_callback()
12560 zpool_prop_to_name(pl->pl_prop), in get_callback()
12567 if (cbp->cb_json) { in get_callback()
12571 cbp->cb_json_as_int); in get_callback()
12573 if (cbp->cb_json_pool_key_guid) { in get_callback()
12585 fnvlist_add_nvlist(cbp->cb_jsobj, "pools", d); in get_callback()
12596 * zpool get [-Hp] [-o "all" | field[,...]] <"all" | property[,...]> <pool> ...
12598 * -H Scripted mode. Don't display headers, and separate properties
12600 * -o List of columns to display. Defaults to
12602 * -p Display values in parsable (exact) format.
12603 * -j Display output in JSON format.
12604 * --json-int Display numbers as integers instead of strings.
12605 * --json-pool-key-guid Set pool GUID as key for pool objects.
12637 {"json-int", no_argument, NULL, ZPOOL_OPTION_JSON_NUMS_AS_INT}, in zpool_do_get()
12638 {"json-pool-key-guid", no_argument, NULL, in zpool_do_get()
12645 NULL)) != -1) { in zpool_do_get()
12677 if (i == ZFS_GET_NCOLS - 1) { in zpool_do_get()
12679 "many fields given to -o " in zpool_do_get()
12698 "given to -o option\n")); in zpool_do_get()
12704 i = ZFS_GET_NCOLS - 1; in zpool_do_get()
12716 argc -= optind; in zpool_do_get()
12720 (void) fprintf(stderr, gettext("'--json-int' only works with" in zpool_do_get()
12721 " '-j' option\n")); in zpool_do_get()
12726 (void) fprintf(stderr, gettext("'json-pool-key-guid' only" in zpool_do_get()
12727 " works with '-j' option\n")); in zpool_do_get()
12740 argc--; in zpool_do_get()
12749 if ((argc == 2 && strcmp(argv[1], "all-vdevs") == 0) || in zpool_do_get()
12751 are_vdevs_in_pool(argc - 1, argv + 1, argv[0], in zpool_do_get()
12755 vdev = strdup("root-0"); in zpool_do_get()
12763 cb.cb_vdevs.cb_names_count = argc - 1; in zpool_do_get()
12773 error_list_unresolved_vdevs(argc - 1, argv + 1, in zpool_do_get()
12846 /* Check if we have out-of-bounds features */ in set_pool_callback()
12847 if (strcmp(cb->cb_propname, ZPOOL_CONFIG_COMPATIBILITY) == 0) { in set_pool_callback()
12849 if (zpool_do_load_compat(cb->cb_value, features) != in set_pool_callback()
12851 return (-1); in set_pool_callback()
12868 if (zpool_prop_feature(cb->cb_propname) && in set_pool_callback()
12869 strcmp(cb->cb_value, ZFS_FEATURE_ENABLED) == 0) { in set_pool_callback()
12870 char *fname = strchr(cb->cb_propname, '@') + 1; in set_pool_callback()
12887 return (-1); in set_pool_callback()
12898 return (-1); in set_pool_callback()
12903 error = zpool_set_prop(zhp, cb->cb_propname, cb->cb_value); in set_pool_callback()
12914 if (cb->cb_type == ZFS_TYPE_VDEV) { in set_callback()
12915 error = zpool_set_vdev_prop(zhp, *cb->cb_vdevs.cb_names, in set_callback()
12916 cb->cb_propname, cb->cb_value); in set_callback()
12918 assert(cb->cb_type == ZFS_TYPE_POOL); in set_callback()
12922 cb->cb_any_successful = !error; in set_callback()
12934 if (argc > 1 && argv[1][0] == '-') { in zpool_do_set()
12968 argc -= 2; in zpool_do_set()
12982 vdev = strdup("root-0"); in zpool_do_set()
13023 vs->vs_initialize_state == VDEV_INITIALIZE_ACTIVE) in vdev_activity_remaining()
13024 bytes_remaining = vs->vs_initialize_bytes_est - in vdev_activity_remaining()
13025 vs->vs_initialize_bytes_done; in vdev_activity_remaining()
13027 vs->vs_trim_state == VDEV_TRIM_ACTIVE) in vdev_activity_remaining()
13028 bytes_remaining = vs->vs_trim_bytes_est - in vdev_activity_remaining()
13029 vs->vs_trim_bytes_done; in vdev_activity_remaining()
13043 /* Add up the total number of bytes left to rebuild across top-level vdevs */
13063 if (vrs->vrs_state == VDEV_REBUILD_ACTIVE) { in vdev_activity_top_remaining()
13064 bytes_remaining += (vrs->vrs_bytes_est - in vdev_activity_top_remaining()
13065 vrs->vrs_bytes_rebuilt); in vdev_activity_top_remaining()
13136 * Make sure we have enough space in the col for pretty-printed in print_wait_status_row()
13148 boolean_t reprint_header = (!wd->wd_headers_once && term_height > 0 && in print_wait_status_row()
13149 row % (term_height-1) == 0); in print_wait_status_row()
13150 if (!wd->wd_scripted && (row == 0 || reprint_header)) { in print_wait_status_row()
13152 if (wd->wd_enabled[i]) in print_wait_status_row()
13169 if (pcs != NULL && pcs->pcs_state == CS_CHECKPOINT_DISCARDING) in print_wait_status_row()
13170 bytes_rem[ZPOOL_WAIT_CKPT_DISCARD] = pcs->pcs_space; in print_wait_status_row()
13174 if (prs != NULL && prs->prs_state == DSS_SCANNING) in print_wait_status_row()
13175 bytes_rem[ZPOOL_WAIT_REMOVE] = prs->prs_to_copy - in print_wait_status_row()
13176 prs->prs_copied; in print_wait_status_row()
13180 if (pss != NULL && pss->pss_state == DSS_SCANNING && in print_wait_status_row()
13181 pss->pss_pass_scrub_pause == 0) { in print_wait_status_row()
13182 int64_t rem = pss->pss_to_examine - pss->pss_issued; in print_wait_status_row()
13183 if (pss->pss_func == POOL_SCAN_SCRUB) in print_wait_status_row()
13194 if (pres != NULL && pres->pres_state == DSS_SCANNING) { in print_wait_status_row()
13195 int64_t rem = pres->pres_to_reflow - pres->pres_reflowed; in print_wait_status_row()
13222 if (!wd->wd_enabled[i]) in print_wait_status_row()
13225 if (wd->wd_exact) { in print_wait_status_row()
13232 if (wd->wd_scripted) in print_wait_status_row()
13235 (void) printf(" %*s", col_widths[i] - 1, buf); in print_wait_status_row()
13247 if ((zhp = zpool_open(g_zfs, wd->wd_poolname)) == NULL) in wait_status_thread()
13264 timeout.tv_sec += floor(wd->wd_interval); in wait_status_thread()
13266 (wd->wd_interval - floor(wd->wd_interval)) * NANOSEC; in wait_status_thread()
13269 timeout.tv_nsec = nanos - NANOSEC; in wait_status_thread()
13273 pthread_mutex_lock(&wd->wd_mutex); in wait_status_thread()
13274 if (!wd->wd_should_exit) in wait_status_thread()
13275 ret = pthread_cond_timedwait(&wd->wd_cv, &wd->wd_mutex, in wait_status_thread()
13277 pthread_mutex_unlock(&wd->wd_mutex); in wait_status_thread()
13315 while ((c = getopt(argc, argv, "HpT:t:")) != -1) { in zpool_do_wait()
13358 argc -= optind; in zpool_do_wait()
13448 * zpool ddtprune -d|-p <amount> <pool>
13450 * -d <days> Prune entries <days> old and older
13451 * -p <percent> Prune <percent> amount of entries
13464 while ((c = getopt(argc, argv, "d:p:")) != -1) { in zpool_do_ddt_prune()
13468 (void) fprintf(stderr, gettext("-d cannot be " in zpool_do_ddt_prune()
13469 "combined with -p option\n")); in zpool_do_ddt_prune()
13484 (void) fprintf(stderr, gettext("-p cannot be " in zpool_do_ddt_prune()
13485 "combined with -d option\n")); in zpool_do_ddt_prune()
13504 argc -= optind; in zpool_do_ddt_prune()
13509 gettext("missing amount option (-d|-p <value>)\n")); in zpool_do_ddt_prune()
13520 return (-1); in zpool_do_ddt_prune()
13558 while ((c = getopt_long(argc, argv, "j", long_options, NULL)) != -1) { in zpool_do_version()
13571 argc -= optind; in zpool_do_version()
13585 return (-1); in zpool_do_version()
13601 snprintf(page, sizeof (page), "zpool-%s", argv[2]); in zpool_do_help()
13606 return (-1); in zpool_do_help()
13665 * Special case '-?' in main()
13667 if ((strcmp(cmdname, "-?") == 0) || strcmp(cmdname, "--help") == 0) in main()
13671 * Special case '-V|--version' in main()
13673 if ((strcmp(cmdname, "-V") == 0) || (strcmp(cmdname, "--version") == 0)) in main()
13705 ret = command_table[i].func(argc - 1, newargv + 1); in main()