summaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_import.c
diff options
context:
space:
mode:
authorGeorge Wilson <[email protected]>2012-12-14 12:38:04 -0800
committerBrian Behlendorf <[email protected]>2013-01-08 10:35:42 -0800
commit3bc7e0fb0f3904eaf41e0b9768ebe2d042ae98aa (patch)
treea72896a0cabe59d930c2253078eca4877b5dbb27 /lib/libzfs/libzfs_import.c
parent5ac0c30a94a0804080f0a89c9b7a31f8d4ab5708 (diff)
Illumos #3090 and #3102
3090 vdev_reopen() during reguid causes vdev to be treated as corrupt 3102 vdev_uberblock_load() and vdev_validate() may read the wrong label Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: Christopher Siden <[email protected]> Reviewed by: Garrett D'Amore <[email protected]> Approved by: Eric Schrock <[email protected]> References: illumos/illumos-gate@dfbb943217bf8ab22a1a9d2e9dca01d4da95ee0b illumos changeset: 13777:b1e53580146d https://www.illumos.org/issues/3090 https://www.illumos.org/issues/3102 Ported-by: Brian Behlendorf <[email protected]> Closes #939
Diffstat (limited to 'lib/libzfs/libzfs_import.c')
-rw-r--r--lib/libzfs/libzfs_import.c85
1 files changed, 39 insertions, 46 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
index ad343e896..22e46b432 100644
--- a/lib/libzfs/libzfs_import.c
+++ b/lib/libzfs/libzfs_import.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -434,8 +434,8 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
uint_t i, nspares, nl2cache;
boolean_t config_seen;
uint64_t best_txg;
- char *name, *hostname, *comment;
- uint64_t version, guid;
+ char *name, *hostname = NULL;
+ uint64_t guid;
uint_t children = 0;
nvlist_t **child = NULL;
uint_t holes;
@@ -521,61 +521,54 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
* configuration:
*
* version
- * pool guid
- * name
+ * pool guid
+ * name
+ * pool txg (if available)
* comment (if available)
- * pool state
+ * pool state
* hostid (if available)
* hostname (if available)
*/
- uint64_t state;
+ uint64_t state, version, pool_txg;
+ char *comment = NULL;
+
+ version = fnvlist_lookup_uint64(tmp,
+ ZPOOL_CONFIG_VERSION);
+ fnvlist_add_uint64(config,
+ ZPOOL_CONFIG_VERSION, version);
+ guid = fnvlist_lookup_uint64(tmp,
+ ZPOOL_CONFIG_POOL_GUID);
+ fnvlist_add_uint64(config,
+ ZPOOL_CONFIG_POOL_GUID, guid);
+ name = fnvlist_lookup_string(tmp,
+ ZPOOL_CONFIG_POOL_NAME);
+ fnvlist_add_string(config,
+ ZPOOL_CONFIG_POOL_NAME, name);
- verify(nvlist_lookup_uint64(tmp,
- ZPOOL_CONFIG_VERSION, &version) == 0);
- if (nvlist_add_uint64(config,
- ZPOOL_CONFIG_VERSION, version) != 0)
- goto nomem;
- verify(nvlist_lookup_uint64(tmp,
- ZPOOL_CONFIG_POOL_GUID, &guid) == 0);
- if (nvlist_add_uint64(config,
- ZPOOL_CONFIG_POOL_GUID, guid) != 0)
- goto nomem;
- verify(nvlist_lookup_string(tmp,
- ZPOOL_CONFIG_POOL_NAME, &name) == 0);
- if (nvlist_add_string(config,
- ZPOOL_CONFIG_POOL_NAME, name) != 0)
- goto nomem;
+ if (nvlist_lookup_uint64(tmp,
+ ZPOOL_CONFIG_POOL_TXG, &pool_txg) == 0)
+ fnvlist_add_uint64(config,
+ ZPOOL_CONFIG_POOL_TXG, pool_txg);
- /*
- * COMMENT is optional, don't bail if it's not
- * there, instead, set it to NULL.
- */
if (nvlist_lookup_string(tmp,
- ZPOOL_CONFIG_COMMENT, &comment) != 0)
- comment = NULL;
- else if (nvlist_add_string(config,
- ZPOOL_CONFIG_COMMENT, comment) != 0)
- goto nomem;
+ ZPOOL_CONFIG_COMMENT, &comment) == 0)
+ fnvlist_add_string(config,
+ ZPOOL_CONFIG_COMMENT, comment);
- verify(nvlist_lookup_uint64(tmp,
- ZPOOL_CONFIG_POOL_STATE, &state) == 0);
- if (nvlist_add_uint64(config,
- ZPOOL_CONFIG_POOL_STATE, state) != 0)
- goto nomem;
+ state = fnvlist_lookup_uint64(tmp,
+ ZPOOL_CONFIG_POOL_STATE);
+ fnvlist_add_uint64(config,
+ ZPOOL_CONFIG_POOL_STATE, state);
hostid = 0;
if (nvlist_lookup_uint64(tmp,
ZPOOL_CONFIG_HOSTID, &hostid) == 0) {
- if (nvlist_add_uint64(config,
- ZPOOL_CONFIG_HOSTID, hostid) != 0)
- goto nomem;
- verify(nvlist_lookup_string(tmp,
- ZPOOL_CONFIG_HOSTNAME,
- &hostname) == 0);
- if (nvlist_add_string(config,
- ZPOOL_CONFIG_HOSTNAME,
- hostname) != 0)
- goto nomem;
+ fnvlist_add_uint64(config,
+ ZPOOL_CONFIG_HOSTID, hostid);
+ hostname = fnvlist_lookup_string(tmp,
+ ZPOOL_CONFIG_HOSTNAME);
+ fnvlist_add_string(config,
+ ZPOOL_CONFIG_HOSTNAME, hostname);
}
config_seen = B_TRUE;