/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012 by Frederik Wessels. All rights reserved.
* Copyright (c) 2012 by Cyril Plisko. All rights reserved.
*/
#include <sys/stat.h>
#include <sys/fm/util.h>
#include <sys/fm/protocol.h>
+#include <sys/zfs_ioctl.h>
#include <libzfs.h>
case HELP_ONLINE:
return (gettext("\tonline <pool> <device> ...\n"));
case HELP_REPLACE:
- return (gettext("\treplace [-f] <pool> <device> "
- "[new-device]\n"));
+ return (gettext("\treplace [-f] [-o property=value] "
+ "<pool> <device> [new-device]\n"));
case HELP_REMOVE:
return (gettext("\tremove <pool> <device> ...\n"));
case HELP_REOPEN:
case HELP_EVENTS:
return (gettext("\tevents [-vHfc]\n"));
case HELP_GET:
- return (gettext("\tget [-p] <\"all\" | property[,...]> "
+ return (gettext("\tget [-pH] <\"all\" | property[,...]> "
"<pool> ...\n"));
case HELP_SET:
return (gettext("\tset <property=value> <pool> \n"));
* Hand off to libzfs.
*/
if (enable_all_pool_feat) {
- int i;
+ spa_feature_t i;
for (i = 0; i < SPA_FEATURES; i++) {
char propname[MAXPATHLEN];
zfeature_info_t *feat = &spa_feature_table[i];
case ZPOOL_ERRATA_NONE:
break;
+ case ZPOOL_ERRATA_ZOL_2094_SCRUB:
+ (void) printf(gettext(" action: The pool can "
+ "be imported using its name or numeric "
+ "identifier,\n\thowever there is a compat"
+ "ibility issue which should be corrected"
+ "\n\tby running 'zpool scrub'\n"));
+ break;
+
+ case ZPOOL_ERRATA_ZOL_2094_ASYNC_DESTROY:
+ (void) printf(gettext(" action: The pool can"
+ "not be imported with this version of ZFS "
+ "due to\n\tan active asynchronous destroy. "
+ "Revert to an earlier version\n\tand "
+ "allow the destroy to complete before "
+ "updating.\n"));
+ break;
+
default:
/*
* All errata must contain an action message.
char *endptr;
/* check options */
- while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:rR:T:VX")) != -1) {
+ while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:R:tT:VX")) != -1) {
switch (c) {
case 'a':
do_all = B_TRUE;
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
goto error;
break;
+ case 't':
+ flags |= ZFS_IMPORT_TEMP_NAME;
+ break;
+
case 'T':
errno = 0;
txg = strtoull(optarg, &endptr, 10);
boolean_t fixed;
size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
- zfs_nicenum(value, propval, sizeof (propval));
if (prop == ZPOOL_PROP_EXPANDSZ && value == 0)
(void) strlcpy(propval, "-", sizeof (propval));
+ else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID)
+ (void) strlcpy(propval, "-", sizeof (propval));
+ else if (prop == ZPOOL_PROP_FRAGMENTATION)
+ (void) snprintf(propval, sizeof (propval), "%llu%%",
+ (unsigned long long)value);
+ else
+ zfs_nicenum(value, propval, sizeof (propval));
if (scripted)
(void) printf("\t%s", propval);
/* only toplevel vdevs have capacity stats */
if (vs->vs_space == 0) {
if (scripted)
- (void) printf("\t-\t-\t-");
+ (void) printf("\t-\t-\t-\t-");
else
- (void) printf(" - - -");
+ (void) printf(" - - - -");
} else {
print_one_column(ZPOOL_PROP_SIZE, vs->vs_space,
scripted);
scripted);
print_one_column(ZPOOL_PROP_FREE,
vs->vs_space - vs->vs_alloc, scripted);
+ print_one_column(ZPOOL_PROP_FRAGMENTATION,
+ vs->vs_fragmentation, scripted);
}
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize,
scripted);
int ret = 0;
list_cbdata_t cb = { 0 };
static char default_props[] =
- "name,size,allocated,free,capacity,dedupratio,"
- "health,altroot";
+ "name,size,allocated,free,fragmentation,capacity,"
+ "dedupratio,health,altroot";
char *props = default_props;
unsigned long interval = 0, count = 0;
zpool_list_t *list;
"'zpool clear'.\n"));
break;
+ case ZPOOL_STATUS_HOSTID_MISMATCH:
+ (void) printf(gettext("status: Mismatch between pool hostid "
+ "and system hostid on imported pool.\n\tThis pool was "
+ "previously imported into a system with a different "
+ "hostid,\n\tand then was verbatim imported into this "
+ "system.\n"));
+ (void) printf(gettext("action: Export this pool on all systems "
+ "on which it is imported.\n"
+ "\tThen import it to correct the mismatch.\n"));
+ break;
+
case ZPOOL_STATUS_ERRATA:
(void) printf(gettext("status: Errata #%d detected.\n"),
errata);
case ZPOOL_ERRATA_NONE:
break;
+ case ZPOOL_ERRATA_ZOL_2094_SCRUB:
+ (void) printf(gettext("action: To correct the issue "
+ "run 'zpool scrub'.\n"));
+ break;
+
default:
/*
* All errata which allow the pool to be imported
break;
}
- case DATA_TYPE_STRING_ARRAY:
+ case DATA_TYPE_STRING_ARRAY: {
+ char **str;
+ uint_t i, nelem;
+
+ (void) nvpair_value_string_array(nvp, &str, &nelem);
+ for (i = 0; i < nelem; i++)
+ printf(gettext("\"%s\" "),
+ str[i] ? str[i] : "<NULL>");
+
+ break;
+ }
+
case DATA_TYPE_BOOLEAN_ARRAY:
case DATA_TYPE_BYTE_ARRAY:
case DATA_TYPE_DOUBLE:
zpool_do_events_next(ev_opts_t *opts)
{
nvlist_t *nvl;
- int cleanup_fd, ret, dropped;
+ int zevent_fd, ret, dropped;
- cleanup_fd = open(ZFS_DEV, O_RDWR);
- VERIFY(cleanup_fd >= 0);
+ zevent_fd = open(ZFS_DEV, O_RDWR);
+ VERIFY(zevent_fd >= 0);
if (!opts->scripted)
(void) printf(gettext("%-30s %s\n"), "TIME", "CLASS");
while (1) {
ret = zpool_events_next(g_zfs, &nvl, &dropped,
- !!opts->follow, cleanup_fd);
+ (opts->follow ? ZEVENT_NONE : ZEVENT_NONBLOCK), zevent_fd);
if (ret || nvl == NULL)
break;
nvlist_free(nvl);
}
- VERIFY(0 == close(cleanup_fd));
+ VERIFY(0 == close(zevent_fd));
return (ret);
}
int c, ret;
/* check options */
- while ((c = getopt(argc, argv, "p")) != -1) {
+ while ((c = getopt(argc, argv, "pH")) != -1) {
switch (c) {
case 'p':
cb.cb_literal = B_TRUE;
break;
+ case 'H':
+ cb.cb_scripted = B_TRUE;
+ break;
+
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);