summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2015-01-26 13:59:39 +0000
committersmh <smh@FreeBSD.org>2015-01-26 13:59:39 +0000
commitc46b18f753630842dacd0134e3fd1b1dde1ecbc0 (patch)
tree45a075e764bd5879eb3483671281d39605430f7f /cddl
parent641c621b1721ac6a15806f4e07f701c8ad9aa77b (diff)
downloadFreeBSD-src-c46b18f753630842dacd0134e3fd1b1dde1ecbc0.zip
FreeBSD-src-c46b18f753630842dacd0134e3fd1b1dde1ecbc0.tar.gz
MFC r276226:
Enhancements to zpool upgrade processing Sponsored by: Multiplay
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_main.c93
1 files changed, 72 insertions, 21 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
index 8251989..2985d0f 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
@@ -4509,11 +4509,12 @@ zpool_do_status(int argc, char **argv)
}
typedef struct upgrade_cbdata {
- int cb_first;
- char cb_poolname[ZPOOL_MAXNAMELEN];
- int cb_argc;
- uint64_t cb_version;
- char **cb_argv;
+ boolean_t cb_first;
+ boolean_t cb_unavail;
+ char cb_poolname[ZPOOL_MAXNAMELEN];
+ int cb_argc;
+ uint64_t cb_version;
+ char **cb_argv;
} upgrade_cbdata_t;
#ifdef __FreeBSD__
@@ -4631,7 +4632,8 @@ upgrade_cb(zpool_handle_t *zhp, void *arg)
if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
(void) fprintf(stderr, gettext("cannot upgrade '%s': pool is "
- "currently unavailable\n\n"), zpool_get_name(zhp));
+ "currently unavailable.\n\n"), zpool_get_name(zhp));
+ cbp->cb_unavail = B_TRUE;
/* Allow iteration to continue. */
return (0);
}
@@ -4697,12 +4699,41 @@ upgrade_cb(zpool_handle_t *zhp, void *arg)
}
static int
+upgrade_list_unavail(zpool_handle_t *zhp, void *arg)
+{
+ upgrade_cbdata_t *cbp = arg;
+
+ if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
+ if (cbp->cb_first) {
+ (void) fprintf(stderr, gettext("The following pools "
+ "are unavailable and cannot be upgraded as this "
+ "time.\n\n"));
+ (void) fprintf(stderr, gettext("POOL\n"));
+ (void) fprintf(stderr, gettext("------------\n"));
+ cbp->cb_first = B_FALSE;
+ }
+ (void) printf(gettext("%s\n"), zpool_get_name(zhp));
+ cbp->cb_unavail = B_TRUE;
+ }
+ return (0);
+}
+
+static int
upgrade_list_older_cb(zpool_handle_t *zhp, void *arg)
{
upgrade_cbdata_t *cbp = arg;
nvlist_t *config;
uint64_t version;
+ if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
+ /*
+ * This will have been reported by upgrade_list_unavail so
+ * just allow iteration to continue.
+ */
+ cbp->cb_unavail = B_TRUE;
+ return (0);
+ }
+
config = zpool_get_config(zhp, NULL);
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
&version) == 0);
@@ -4737,10 +4768,11 @@ upgrade_list_disabled_cb(zpool_handle_t *zhp, void *arg)
uint64_t version;
if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
- (void) fprintf(stderr, gettext("cannot check supported "
- "features on '%s': pool is currently unavailable\n\n"),
- zpool_get_name(zhp));
- /* Allow iteration to continue. */
+ /*
+ * This will have been reported by upgrade_list_unavail so
+ * just allow iteration to continue.
+ */
+ cbp->cb_unavail = B_TRUE;
return (0);
}
@@ -4797,10 +4829,17 @@ upgrade_one(zpool_handle_t *zhp, void *data)
uint64_t cur_version;
int ret;
+ if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
+ (void) fprintf(stderr, gettext("cannot upgrade '%s': pool is "
+ "is currently unavailable.\n\n"), zpool_get_name(zhp));
+ cbp->cb_unavail = B_TRUE;
+ return (1);
+ }
+
if (strcmp("log", zpool_get_name(zhp)) == 0) {
(void) printf(gettext("'log' is now a reserved word\n"
"Pool 'log' must be renamed using export and import"
- " to upgrade.\n"));
+ " to upgrade.\n\n"));
return (1);
}
@@ -4844,7 +4883,7 @@ upgrade_one(zpool_handle_t *zhp, void *data)
#endif /* __FreeBSD __*/
} else if (cur_version == SPA_VERSION) {
(void) printf(gettext("Pool '%s' already has all "
- "supported features enabled.\n"),
+ "supported features enabled.\n\n"),
zpool_get_name(zhp));
}
}
@@ -5001,11 +5040,13 @@ zpool_do_upgrade(int argc, char **argv)
ret = zpool_iter(g_zfs, upgrade_cb, &cb);
if (ret == 0 && cb.cb_first) {
if (cb.cb_version == SPA_VERSION) {
- (void) printf(gettext("All pools are already "
- "formatted using feature flags.\n\n"));
- (void) printf(gettext("Every feature flags "
+ (void) printf(gettext("All %spools are already "
+ "formatted using feature flags.\n\n"),
+ cb.cb_unavail ? gettext("available ") : "");
+ (void) printf(gettext("Every %sfeature flags "
"pool already has all supported features "
- "enabled.\n"));
+ "enabled.\n"),
+ cb.cb_unavail ? gettext("available ") : "");
} else {
(void) printf(gettext("All pools are already "
"formatted with version %llu or higher.\n"),
@@ -5014,12 +5055,21 @@ zpool_do_upgrade(int argc, char **argv)
}
} else if (argc == 0) {
cb.cb_first = B_TRUE;
+ ret = zpool_iter(g_zfs, upgrade_list_unavail, &cb);
+ assert(ret == 0);
+
+ if (!cb.cb_first) {
+ (void) fprintf(stderr, "\n");
+ }
+
+ cb.cb_first = B_TRUE;
ret = zpool_iter(g_zfs, upgrade_list_older_cb, &cb);
assert(ret == 0);
if (cb.cb_first) {
- (void) printf(gettext("All pools are formatted "
- "using feature flags.\n\n"));
+ (void) printf(gettext("All %spools are formatted using "
+ "feature flags.\n\n"), cb.cb_unavail ?
+ gettext("available ") : "");
} else {
(void) printf(gettext("\nUse 'zpool upgrade -v' "
"for a list of available legacy versions.\n"));
@@ -5030,13 +5080,14 @@ zpool_do_upgrade(int argc, char **argv)
assert(ret == 0);
if (cb.cb_first) {
- (void) printf(gettext("Every feature flags pool has "
- "all supported features enabled.\n"));
+ (void) printf(gettext("Every %sfeature flags pool has "
+ "all supported features enabled.\n"),
+ cb.cb_unavail ? gettext("available ") : "");
} else {
(void) printf(gettext("\n"));
}
} else {
- ret = for_each_pool(argc, argv, B_FALSE, NULL,
+ ret = for_each_pool(argc, argv, B_TRUE, NULL,
upgrade_one, &cb);
}
OpenPOWER on IntegriCloud