summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authormmusante <none@none>2007-03-01 06:09:49 -0800
committermmusante <none@none>2007-03-01 06:09:49 -0800
commit46657f8d750bdb71753495ce2919170f126b8e34 (patch)
tree37c4c3f3b39f8024dc8d1a42ea0f7a8f9b7b838e /usr
parented19839e9b6280e7c496bbf23396ad0adb5a6ca7 (diff)
downloadillumos-gate-46657f8d750bdb71753495ce2919170f126b8e34.tar.gz
6441384 zpool import action message is not correctly localized
6473418 setting user defined property on full filesystem should report error 6513953 Unable to create global hotspare in ja locale
Diffstat (limited to 'usr')
-rw-r--r--usr/src/cmd/zpool/zpool_main.c59
-rw-r--r--usr/src/cmd/zpool/zpool_vdev.c14
-rw-r--r--usr/src/lib/libdiskmgt/common/entry.c13
-rw-r--r--usr/src/lib/libdiskmgt/common/libdiskmgt.h5
-rw-r--r--usr/src/lib/libzfs/common/libzfs_config.c7
-rw-r--r--usr/src/lib/libzfs/common/libzfs_impl.h1
-rw-r--r--usr/src/lib/libzfs/common/libzfs_import.c3
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c39
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_ioctl.c2
-rw-r--r--usr/src/uts/common/sys/fs/zfs.h1
10 files changed, 62 insertions, 82 deletions
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index cb3d335d34..83ae9349ec 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -310,6 +310,23 @@ usage(boolean_t requested)
}
const char *
+state_to_health(int vs_state)
+{
+ switch (vs_state) {
+ case VDEV_STATE_CLOSED:
+ case VDEV_STATE_CANT_OPEN:
+ case VDEV_STATE_OFFLINE:
+ return (dgettext(TEXT_DOMAIN, "FAULTED"));
+ case VDEV_STATE_DEGRADED:
+ return (dgettext(TEXT_DOMAIN, "DEGRADED"));
+ case VDEV_STATE_HEALTHY:
+ return (dgettext(TEXT_DOMAIN, "ONLINE"));
+ }
+
+ return (dgettext(TEXT_DOMAIN, "UNKNOWN"));
+}
+
+const char *
state_to_name(vdev_stat_t *vs)
{
switch (vs->vs_state) {
@@ -954,7 +971,7 @@ show_import(nvlist_t *config)
char *msgid;
nvlist_t *nvroot;
int reason;
- char *health;
+ const char *health;
uint_t vsc;
int namewidth;
@@ -964,21 +981,20 @@ show_import(nvlist_t *config)
&guid) == 0);
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE,
&pool_state) == 0);
- verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_HEALTH,
- &health) == 0);
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) == 0);
verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_STATS,
(uint64_t **)&vs, &vsc) == 0);
+ health = state_to_health(vs->vs_state);
reason = zpool_import_status(config, &msgid);
- (void) printf(" pool: %s\n", name);
- (void) printf(" id: %llu\n", (u_longlong_t)guid);
- (void) printf(" state: %s", health);
+ (void) printf(gettext(" pool: %s\n"), name);
+ (void) printf(gettext(" id: %llu\n"), (u_longlong_t)guid);
+ (void) printf(gettext(" state: %s"), health);
if (pool_state == POOL_STATE_DESTROYED)
- (void) printf(" (DESTROYED)");
+ (void) printf(gettext(" (DESTROYED)"));
(void) printf("\n");
switch (reason) {
@@ -1029,7 +1045,7 @@ show_import(nvlist_t *config)
/*
* Print out an action according to the overall state of the pool.
*/
- if (strcmp(health, gettext("ONLINE")) == 0) {
+ if (vs->vs_state == VDEV_STATE_HEALTHY) {
if (reason == ZPOOL_STATUS_VERSION_OLDER)
(void) printf(gettext("action: The pool can be "
"imported using its name or numeric identifier, "
@@ -1039,7 +1055,7 @@ show_import(nvlist_t *config)
(void) printf(gettext("action: The pool can be "
"imported using its name or numeric "
"identifier.\n"));
- } else if (strcmp(health, gettext("DEGRADED")) == 0) {
+ } else if (vs->vs_state == VDEV_STATE_DEGRADED) {
(void) printf(gettext("action: The pool can be imported "
"despite missing or damaged devices. The\n\tfault "
"tolerance of the pool may be compromised if imported.\n"));
@@ -1064,7 +1080,13 @@ show_import(nvlist_t *config)
}
}
- if (strcmp(health, gettext("FAULTED")) != 0) {
+ /*
+ * If the state is "closed" or "can't open", and the aux state
+ * is "corrupt data":
+ */
+ if (((vs->vs_state == VDEV_STATE_CLOSED) ||
+ (vs->vs_state == VDEV_STATE_CANT_OPEN)) &&
+ (vs->vs_aux == VDEV_AUX_CORRUPT_DATA)) {
if (pool_state == POOL_STATE_DESTROYED)
(void) printf(gettext("\tThe pool was destroyed, "
"but can be imported using the '-Df' flags.\n"));
@@ -1086,9 +1108,9 @@ show_import(nvlist_t *config)
print_import_config(name, nvroot, namewidth, 0);
if (reason == ZPOOL_STATUS_BAD_GUID_SUM) {
- (void) printf("\n\tAdditional devices are known to "
+ (void) printf(gettext("\n\tAdditional devices are known to "
"be part of this pool, though their\n\texact "
- "configuration cannot be determined.\n");
+ "configuration cannot be determined.\n"));
}
}
@@ -2733,7 +2755,9 @@ status_callback(zpool_handle_t *zhp, void *data)
nvlist_t *config, *nvroot;
char *msgid;
int reason;
- char *health;
+ const char *health;
+ uint_t c;
+ vdev_stat_t *vs;
config = zpool_get_config(zhp, NULL);
reason = zpool_get_status(zhp, &msgid);
@@ -2759,8 +2783,11 @@ status_callback(zpool_handle_t *zhp, void *data)
else
(void) printf("\n");
- verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_HEALTH,
- &health) == 0);
+ verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
+ &nvroot) == 0);
+ verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_STATS,
+ (uint64_t **)&vs, &c) == 0);
+ health = state_to_name(vs);
(void) printf(gettext(" pool: %s\n"), zpool_get_name(zhp));
(void) printf(gettext(" state: %s\n"), health);
@@ -2880,8 +2907,6 @@ status_callback(zpool_handle_t *zhp, void *data)
nvlist_t **spares;
uint_t nspares;
- verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
- &nvroot) == 0);
(void) printf(gettext(" scrub: "));
print_scrub_status(nvroot);
diff --git a/usr/src/cmd/zpool/zpool_vdev.c b/usr/src/cmd/zpool/zpool_vdev.c
index cf44cf2e0f..9a41649128 100644
--- a/usr/src/cmd/zpool/zpool_vdev.c
+++ b/usr/src/cmd/zpool/zpool_vdev.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -139,18 +139,12 @@ check_slice(const char *path, int force, boolean_t wholedisk, boolean_t isspare)
int error = 0;
int ret = 0;
- if (dm_inuse((char *)path, &msg,
- force ? DM_WHO_ZPOOL_FORCE : DM_WHO_ZPOOL, &error) || error) {
+ if (dm_inuse((char *)path, &msg, isspare ? DM_WHO_ZPOOL_SPARE :
+ (force ? DM_WHO_ZPOOL_FORCE : DM_WHO_ZPOOL), &error) || error) {
if (error != 0) {
libdiskmgt_error(error);
return (0);
- } else if (!isspare ||
- strstr(msg, gettext("hot spare")) == NULL) {
- /*
- * The above check is a rather severe hack. It would
- * probably make more sense to have DM_WHO_ZPOOL_SPARE
- * instead.
- */
+ } else {
vdev_error("%s", msg);
free(msg);
ret = -1;
diff --git a/usr/src/lib/libdiskmgt/common/entry.c b/usr/src/lib/libdiskmgt/common/entry.c
index 61bc9d60d4..a123a586f5 100644
--- a/usr/src/lib/libdiskmgt/common/entry.c
+++ b/usr/src/lib/libdiskmgt/common/entry.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -743,7 +743,6 @@ dm_inuse(char *dev_name, char **msg, dm_who_type_t who, int *errp)
int found = 0;
char *dname = NULL;
-
*errp = 0;
*msg = NULL;
@@ -892,6 +891,16 @@ dm_inuse(char *dev_name, char **msg, dm_who_type_t who, int *errp)
}
break;
+ case DM_WHO_ZPOOL_SPARE:
+ if (strcmp(by, DM_USE_SPARE_ZPOOL) != 0) {
+ if (build_usage_string(dname, by,
+ data, msg, &found, errp) != 0) {
+ if (*errp)
+ goto out;
+ }
+ }
+ break;
+
default:
/*
* nothing found in use for this client
diff --git a/usr/src/lib/libdiskmgt/common/libdiskmgt.h b/usr/src/lib/libdiskmgt/common/libdiskmgt.h
index 7d6fef46d4..67e1b55bef 100644
--- a/usr/src/lib/libdiskmgt/common/libdiskmgt.h
+++ b/usr/src/lib/libdiskmgt/common/libdiskmgt.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -48,7 +48,8 @@ typedef enum {
DM_WHO_ZPOOL_FORCE,
DM_WHO_FORMAT,
DM_WHO_SWAP,
- DM_WHO_DUMP
+ DM_WHO_DUMP,
+ DM_WHO_ZPOOL_SPARE
} dm_who_type_t;
typedef enum {
diff --git a/usr/src/lib/libzfs/common/libzfs_config.c b/usr/src/lib/libzfs/common/libzfs_config.c
index d8fbd2ecb5..45e2920f3b 100644
--- a/usr/src/lib/libzfs/common/libzfs_config.c
+++ b/usr/src/lib/libzfs/common/libzfs_config.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -289,11 +289,6 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
zhp->zpool_config_size = zc.zc_nvlist_dst_size;
- if (set_pool_health(config) != 0) {
- nvlist_free(config);
- return (no_memory(zhp->zpool_hdl));
- }
-
if (zhp->zpool_config != NULL) {
uint64_t oldtxg, newtxg;
diff --git a/usr/src/lib/libzfs/common/libzfs_impl.h b/usr/src/lib/libzfs/common/libzfs_impl.h
index dfc5706e6a..3cb4585407 100644
--- a/usr/src/lib/libzfs/common/libzfs_impl.h
+++ b/usr/src/lib/libzfs/common/libzfs_impl.h
@@ -120,7 +120,6 @@ int changelist_haszonedchild(prop_changelist_t *);
void remove_mountpoint(zfs_handle_t *);
zfs_handle_t *make_dataset_handle(libzfs_handle_t *, const char *);
-int set_pool_health(nvlist_t *);
int zpool_open_silent(libzfs_handle_t *, const char *, zpool_handle_t **);
diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c
index 0bc9245304..cc114ee3ee 100644
--- a/usr/src/lib/libzfs/common/libzfs_import.c
+++ b/usr/src/lib/libzfs/common/libzfs_import.c
@@ -621,9 +621,6 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl)
}
}
- if (set_pool_health(config) != 0)
- goto nomem;
-
/*
* Add this pool to the list of configs.
*/
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index d53b8c1393..0aa7831014 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -132,45 +132,6 @@ zpool_name_valid(libzfs_handle_t *hdl, boolean_t isopen, const char *pool)
}
/*
- * Set the pool-wide health based on the vdev state of the root vdev.
- */
-int
-set_pool_health(nvlist_t *config)
-{
- nvlist_t *nvroot;
- vdev_stat_t *vs;
- uint_t vsc;
- char *health;
-
- verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
- &nvroot) == 0);
- verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_STATS,
- (uint64_t **)&vs, &vsc) == 0);
-
- switch (vs->vs_state) {
-
- case VDEV_STATE_CLOSED:
- case VDEV_STATE_CANT_OPEN:
- case VDEV_STATE_OFFLINE:
- health = dgettext(TEXT_DOMAIN, "FAULTED");
- break;
-
- case VDEV_STATE_DEGRADED:
- health = dgettext(TEXT_DOMAIN, "DEGRADED");
- break;
-
- case VDEV_STATE_HEALTHY:
- health = dgettext(TEXT_DOMAIN, "ONLINE");
- break;
-
- default:
- abort();
- }
-
- return (nvlist_add_string(config, ZPOOL_CONFIG_POOL_HEALTH, health));
-}
-
-/*
* Open a handle to the given pool, even if the pool is currently in the FAULTED
* state.
*/
diff --git a/usr/src/uts/common/fs/zfs/zfs_ioctl.c b/usr/src/uts/common/fs/zfs/zfs_ioctl.c
index 81648b5416..1178dba1eb 100644
--- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c
+++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c
@@ -869,7 +869,7 @@ zfs_set_prop_nvlist(const char *name, dev_t dev, cred_t *cr, nvlist_t *nvl)
if (error == 0)
continue;
else
- break;
+ return (error);
}
/*
diff --git a/usr/src/uts/common/sys/fs/zfs.h b/usr/src/uts/common/sys/fs/zfs.h
index 0ad3e5a982..4290edb01b 100644
--- a/usr/src/uts/common/sys/fs/zfs.h
+++ b/usr/src/uts/common/sys/fs/zfs.h
@@ -157,7 +157,6 @@ extern zfs_prop_t zfs_prop_iter(zfs_prop_f, void *, boolean_t);
#define ZPOOL_CONFIG_POOL_GUID "pool_guid"
#define ZPOOL_CONFIG_CREATE_TXG "create_txg"
#define ZPOOL_CONFIG_TOP_GUID "top_guid"
-#define ZPOOL_CONFIG_POOL_HEALTH "pool_health"
#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
#define ZPOOL_CONFIG_TYPE "type"
#define ZPOOL_CONFIG_CHILDREN "children"