aboutsummaryrefslogtreecommitdiff
path: root/cmd/zpool/zpool_main.c
diff options
context:
space:
mode:
authorMatt Macy <mmacy@FreeBSD.org>2021-01-07 23:19:59 +0000
committerMatt Macy <mmacy@FreeBSD.org>2021-01-07 23:19:59 +0000
commit42385c279bad198701badabdab661df49f2acb9a (patch)
tree529931aeb217bb13f5cbfb4eb38fd75163d251ba /cmd/zpool/zpool_main.c
parent0be360124f8f108f73365e31448e7550f877f3ac (diff)
downloadsrc-42385c279bad198701badabdab661df49f2acb9a.tar.gz
src-42385c279bad198701badabdab661df49f2acb9a.zip
Update OpenZFS to master-f11b09vendor/openzfs/20210107
Diffstat (limited to 'cmd/zpool/zpool_main.c')
-rw-r--r--cmd/zpool/zpool_main.c155
1 files changed, 129 insertions, 26 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index f612db48d4f9..e00fdb7ae1b0 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -669,9 +669,16 @@ print_vdev_tree(zpool_handle_t *zhp, const char *name, nvlist_t *nv, int indent,
}
for (c = 0; c < children; c++) {
- uint64_t is_log = B_FALSE;
+ uint64_t is_log = B_FALSE, is_hole = B_FALSE;
char *class = "";
+ (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_HOLE,
+ &is_hole);
+
+ if (is_hole == B_TRUE) {
+ continue;
+ }
+
(void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
&is_log);
if (is_log)
@@ -692,6 +699,54 @@ print_vdev_tree(zpool_handle_t *zhp, const char *name, nvlist_t *nv, int indent,
}
}
+/*
+ * Print the list of l2cache devices for dry runs.
+ */
+static void
+print_cache_list(nvlist_t *nv, int indent)
+{
+ nvlist_t **child;
+ uint_t c, children;
+
+ if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE,
+ &child, &children) == 0 && children > 0) {
+ (void) printf("\t%*s%s\n", indent, "", "cache");
+ } else {
+ return;
+ }
+ for (c = 0; c < children; c++) {
+ char *vname;
+
+ vname = zpool_vdev_name(g_zfs, NULL, child[c], 0);
+ (void) printf("\t%*s%s\n", indent + 2, "", vname);
+ free(vname);
+ }
+}
+
+/*
+ * Print the list of spares for dry runs.
+ */
+static void
+print_spare_list(nvlist_t *nv, int indent)
+{
+ nvlist_t **child;
+ uint_t c, children;
+
+ if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES,
+ &child, &children) == 0 && children > 0) {
+ (void) printf("\t%*s%s\n", indent, "", "spares");
+ } else {
+ return;
+ }
+ for (c = 0; c < children; c++) {
+ char *vname;
+
+ vname = zpool_vdev_name(g_zfs, NULL, child[c], 0);
+ (void) printf("\t%*s%s\n", indent + 2, "", vname);
+ free(vname);
+ }
+}
+
static boolean_t
prop_list_contains_feature(nvlist_t *proplist)
{
@@ -921,16 +976,16 @@ zpool_do_add(int argc, char **argv)
if (dryrun) {
nvlist_t *poolnvroot;
- nvlist_t **l2child;
- uint_t l2children, c;
+ nvlist_t **l2child, **sparechild;
+ uint_t l2children, sparechildren, c;
char *vname;
- boolean_t hadcache = B_FALSE;
+ boolean_t hadcache = B_FALSE, hadspare = B_FALSE;
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&poolnvroot) == 0);
(void) printf(gettext("would update '%s' to the following "
- "configuration:\n"), zpool_get_name(zhp));
+ "configuration:\n\n"), zpool_get_name(zhp));
/* print original main pool and new tree */
print_vdev_tree(zhp, poolname, poolnvroot, 0, "",
@@ -991,6 +1046,29 @@ zpool_do_add(int argc, char **argv)
free(vname);
}
}
+ /* And finaly the spares */
+ if (nvlist_lookup_nvlist_array(poolnvroot, ZPOOL_CONFIG_SPARES,
+ &sparechild, &sparechildren) == 0 && sparechildren > 0) {
+ hadspare = B_TRUE;
+ (void) printf(gettext("\tspares\n"));
+ for (c = 0; c < sparechildren; c++) {
+ vname = zpool_vdev_name(g_zfs, NULL,
+ sparechild[c], name_flags);
+ (void) printf("\t %s\n", vname);
+ free(vname);
+ }
+ }
+ if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_SPARES,
+ &sparechild, &sparechildren) == 0 && sparechildren > 0) {
+ if (!hadspare)
+ (void) printf(gettext("\tspares\n"));
+ for (c = 0; c < sparechildren; c++) {
+ vname = zpool_vdev_name(g_zfs, NULL,
+ sparechild[c], name_flags);
+ (void) printf("\t %s\n", vname);
+ free(vname);
+ }
+ }
ret = 0;
} else {
@@ -1548,6 +1626,8 @@ zpool_do_create(int argc, char **argv)
VDEV_ALLOC_BIAS_SPECIAL, 0);
print_vdev_tree(NULL, "logs", nvroot, 0,
VDEV_ALLOC_BIAS_LOG, 0);
+ print_cache_list(nvroot, 0);
+ print_spare_list(nvroot, 0);
ret = 0;
} else {
@@ -1762,7 +1842,7 @@ zpool_do_export(int argc, char **argv)
}
return (for_each_pool(argc, argv, B_TRUE, NULL,
- zpool_export_one, &cb));
+ B_FALSE, zpool_export_one, &cb));
}
/* check arguments */
@@ -1771,7 +1851,8 @@ zpool_do_export(int argc, char **argv)
usage(B_FALSE);
}
- ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_export_one, &cb);
+ ret = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, zpool_export_one,
+ &cb);
return (ret);
}
@@ -2254,6 +2335,13 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name,
break;
}
color_end();
+ } else if (children == 0 && !isspare &&
+ getenv("ZPOOL_STATUS_NON_NATIVE_ASHIFT_IGNORE") == NULL &&
+ VDEV_STAT_VALID(vs_physical_ashift, vsc) &&
+ vs->vs_configured_ashift < vs->vs_physical_ashift) {
+ (void) printf(
+ gettext(" block size: %dB configured, %dB native"),
+ 1 << vs->vs_configured_ashift, 1 << vs->vs_physical_ashift);
}
/* The root vdev has the scrub/resilver stats */
@@ -2287,7 +2375,7 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name,
}
}
- /* Display vdev initialization and trim status for leaves */
+ /* Display vdev initialization and trim status for leaves. */
if (children == 0) {
print_status_initialize(vs, cb->cb_print_vdev_init);
print_status_trim(vs, cb->cb_print_vdev_trim);
@@ -3606,7 +3694,8 @@ zpool_do_sync(int argc, char **argv)
argv += optind;
/* if argc == 0 we will execute zpool_sync_one on all pools */
- ret = for_each_pool(argc, argv, B_FALSE, NULL, zpool_sync_one, &force);
+ ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, zpool_sync_one,
+ &force);
return (ret);
}
@@ -4951,7 +5040,7 @@ are_vdevs_in_pool(int argc, char **argv, char *pool_name,
/* Is this name a vdev in our pools? */
ret = for_each_pool(pool_count, &pool_name, B_TRUE, NULL,
- is_vdev, cb);
+ B_FALSE, is_vdev, cb);
if (!ret) {
/* No match */
break;
@@ -4979,7 +5068,8 @@ is_pool_cb(zpool_handle_t *zhp, void *data)
static int
is_pool(char *name)
{
- return (for_each_pool(0, NULL, B_TRUE, NULL, is_pool_cb, name));
+ return (for_each_pool(0, NULL, B_TRUE, NULL, B_FALSE, is_pool_cb,
+ name));
}
/* Are all our argv[] strings pool names? If so return 1, 0 otherwise. */
@@ -5431,7 +5521,7 @@ zpool_do_iostat(int argc, char **argv)
* Construct the list of all interesting pools.
*/
ret = 0;
- if ((list = pool_list_get(argc, argv, NULL, &ret)) == NULL)
+ if ((list = pool_list_get(argc, argv, NULL, parsable, &ret)) == NULL)
return (1);
if (pool_list_count(list) == 0 && argc != 0) {
@@ -6105,7 +6195,7 @@ zpool_do_list(int argc, char **argv)
for (;;) {
if ((list = pool_list_get(argc, argv, &cb.cb_proplist,
- &ret)) == NULL)
+ cb.cb_literal, &ret)) == NULL)
return (1);
if (pool_list_count(list) == 0)
@@ -6505,6 +6595,10 @@ zpool_do_split(int argc, char **argv)
"following layout:\n\n"), newpool);
print_vdev_tree(NULL, newpool, config, 0, "",
flags.name_flags);
+ print_vdev_tree(NULL, "dedup", config, 0,
+ VDEV_ALLOC_BIAS_DEDUP, 0);
+ print_vdev_tree(NULL, "special", config, 0,
+ VDEV_ALLOC_BIAS_SPECIAL, 0);
}
}
@@ -6857,7 +6951,7 @@ zpool_do_reopen(int argc, char **argv)
argv += optind;
/* if argc == 0 we will execute zpool_reopen_one on all pools */
- ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_reopen_one,
+ ret = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE, zpool_reopen_one,
&scrub_restart);
return (ret);
@@ -6987,12 +7081,13 @@ zpool_do_scrub(int argc, char **argv)
usage(B_FALSE);
}
- error = for_each_pool(argc, argv, B_TRUE, NULL, scrub_callback, &cb);
+ error = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
+ scrub_callback, &cb);
if (wait && !error) {
zpool_wait_activity_t act = ZPOOL_WAIT_SCRUB;
- error = for_each_pool(argc, argv, B_TRUE, NULL, wait_callback,
- &act);
+ error = for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
+ wait_callback, &act);
}
return (error);
@@ -7030,7 +7125,8 @@ zpool_do_resilver(int argc, char **argv)
usage(B_FALSE);
}
- return (for_each_pool(argc, argv, B_TRUE, NULL, scrub_callback, &cb));
+ return (for_each_pool(argc, argv, B_TRUE, NULL, B_FALSE,
+ scrub_callback, &cb));
}
/*
@@ -7583,7 +7679,7 @@ print_removal_status(zpool_handle_t *zhp, pool_removal_stat_t *prs)
vdev_name = zpool_vdev_name(g_zfs, zhp,
child[prs->prs_removing_vdev], B_TRUE);
- (void) printf(gettext("remove: "));
+ printf_color(ANSI_BOLD, gettext("remove: "));
start = prs->prs_start_time;
end = prs->prs_end_time;
@@ -8424,7 +8520,7 @@ zpool_do_status(int argc, char **argv)
cb.vcdl = all_pools_for_each_vdev_run(argc, argv, cmd,
NULL, NULL, 0, 0);
- ret = for_each_pool(argc, argv, B_TRUE, NULL,
+ ret = for_each_pool(argc, argv, B_TRUE, NULL, cb.cb_literal,
status_callback, &cb);
if (cb.vcdl != NULL)
@@ -8943,7 +9039,7 @@ zpool_do_upgrade(int argc, char **argv)
(void) printf(gettext("\n"));
}
} else {
- ret = for_each_pool(argc, argv, B_FALSE, NULL,
+ ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE,
upgrade_one, &cb);
}
@@ -9029,6 +9125,12 @@ print_history_records(nvlist_t *nvhis, hist_cbdata_t *cb)
dump_nvlist(fnvlist_lookup_nvlist(rec,
ZPOOL_HIST_OUTPUT_NVL), 8);
}
+ if (nvlist_exists(rec, ZPOOL_HIST_OUTPUT_SIZE)) {
+ (void) printf(" output nvlist omitted; "
+ "original size: %lldKB\n",
+ (longlong_t)fnvlist_lookup_int64(rec,
+ ZPOOL_HIST_OUTPUT_SIZE) / 1024);
+ }
if (nvlist_exists(rec, ZPOOL_HIST_ERRNO)) {
(void) printf(" errno: %lld\n",
(longlong_t)fnvlist_lookup_int64(rec,
@@ -9126,7 +9228,7 @@ zpool_do_history(int argc, char **argv)
argc -= optind;
argv += optind;
- ret = for_each_pool(argc, argv, B_FALSE, NULL, get_history_one,
+ ret = for_each_pool(argc, argv, B_FALSE, NULL, B_FALSE, get_history_one,
&cbdata);
if (argc == 0 && cbdata.first == B_TRUE) {
@@ -9689,7 +9791,7 @@ zpool_do_get(int argc, char **argv)
cb.cb_proplist = &fake_name;
}
- ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist,
+ ret = for_each_pool(argc, argv, B_TRUE, &cb.cb_proplist, cb.cb_literal,
get_callback, &cb);
if (cb.cb_proplist == &fake_name)
@@ -9759,7 +9861,7 @@ zpool_do_set(int argc, char **argv)
*(cb.cb_value) = '\0';
cb.cb_value++;
- error = for_each_pool(argc - 2, argv + 2, B_TRUE, NULL,
+ error = for_each_pool(argc - 2, argv + 2, B_TRUE, NULL, B_FALSE,
set_callback, &cb);
return (error);
@@ -9842,7 +9944,8 @@ vdev_any_spare_replacing(nvlist_t *nv)
(void) nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &vdev_type);
if (strcmp(vdev_type, VDEV_TYPE_REPLACING) == 0 ||
- strcmp(vdev_type, VDEV_TYPE_SPARE) == 0) {
+ strcmp(vdev_type, VDEV_TYPE_SPARE) == 0 ||
+ strcmp(vdev_type, VDEV_TYPE_DRAID_SPARE) == 0) {
return (B_TRUE);
}
@@ -10044,7 +10147,7 @@ int
zpool_do_wait(int argc, char **argv)
{
boolean_t verbose = B_FALSE;
- char c;
+ int c;
char *value;
int i;
unsigned long count;