From owner-svn-src-stable@FreeBSD.ORG Mon Jan 26 13:59:40 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0DDBCD89; Mon, 26 Jan 2015 13:59:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC9A96A6; Mon, 26 Jan 2015 13:59:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0QDxdm1063113; Mon, 26 Jan 2015 13:59:39 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0QDxddU063112; Mon, 26 Jan 2015 13:59:39 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201501261359.t0QDxddU063112@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Mon, 26 Jan 2015 13:59:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r277757 - stable/10/cddl/contrib/opensolaris/cmd/zpool X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2015 13:59:40 -0000 Author: smh Date: Mon Jan 26 13:59:39 2015 New Revision: 277757 URL: https://svnweb.freebsd.org/changeset/base/277757 Log: MFC r276226: Enhancements to zpool upgrade processing Sponsored by: Multiplay Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Mon Jan 26 13:39:35 2015 (r277756) +++ stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Mon Jan 26 13:59:39 2015 (r277757) @@ -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 *ar 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 *ar } 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 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 *d 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 *d #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); }