Print this page
5882 Temporary pool names
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
*** 206,215 ****
--- 206,216 ----
{
spa_config_dirent_t *dp, *tdp;
nvlist_t *nvl;
boolean_t ccw_failure;
int error;
+ char *pool_name;
ASSERT(MUTEX_HELD(&spa_namespace_lock));
if (rootdir == NULL || !(spa_mode_global & FWRITE))
return;
*** 252,262 ****
}
if (nvl == NULL)
nvl = fnvlist_alloc();
! fnvlist_add_nvlist(nvl, spa->spa_name,
spa->spa_config);
mutex_exit(&spa->spa_props_lock);
}
error = spa_config_write(dp, nvl);
--- 253,270 ----
}
if (nvl == NULL)
nvl = fnvlist_alloc();
! if (spa->spa_import_flags & ZFS_IMPORT_TEMP_NAME) {
! pool_name = fnvlist_lookup_string(
! spa->spa_config, ZPOOL_CONFIG_POOL_NAME);
! } else {
! pool_name = spa_name(spa);
! }
!
! fnvlist_add_nvlist(nvl, pool_name,
spa->spa_config);
mutex_exit(&spa->spa_props_lock);
}
error = spa_config_write(dp, nvl);
*** 357,366 ****
--- 365,375 ----
nvlist_t *config, *nvroot;
vdev_t *rvd = spa->spa_root_vdev;
unsigned long hostid = 0;
boolean_t locked = B_FALSE;
uint64_t split_guid;
+ char *pool_name;
if (vd == NULL) {
vd = rvd;
locked = B_TRUE;
spa_config_enter(spa, SCL_CONFIG | SCL_STATE, FTAG, RW_READER);
*** 373,386 ****
* If txg is -1, report the current value of spa->spa_config_txg.
*/
if (txg == -1ULL)
txg = spa->spa_config_txg;
config = fnvlist_alloc();
fnvlist_add_uint64(config, ZPOOL_CONFIG_VERSION, spa_version(spa));
! fnvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, spa_name(spa));
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE, spa_state(spa));
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG, txg);
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID, spa_guid(spa));
if (spa->spa_comment != NULL) {
fnvlist_add_string(config, ZPOOL_CONFIG_COMMENT,
--- 382,412 ----
* If txg is -1, report the current value of spa->spa_config_txg.
*/
if (txg == -1ULL)
txg = spa->spa_config_txg;
+ /*
+ * Originally, users had to handle spa namespace collisions by either
+ * exporting the already imported pool or by specifying a new name for
+ * the pool with a conflicting name. In the case of root pools from
+ * virtual guests, neither approach to collision resolution is
+ * reasonable. This is addressed by extending the new name syntax with
+ * an option to specify that the new name is temporary. When specified,
+ * ZFS_IMPORT_TEMP_NAME will be set in spa->spa_import_flags to tell us
+ * to use the previous name, which we do below.
+ */
+ if (spa->spa_import_flags & ZFS_IMPORT_TEMP_NAME) {
+ pool_name = fnvlist_lookup_string(spa->spa_config,
+ ZPOOL_CONFIG_POOL_NAME);
+ } else {
+ pool_name = spa_name(spa);
+ }
+
config = fnvlist_alloc();
fnvlist_add_uint64(config, ZPOOL_CONFIG_VERSION, spa_version(spa));
! fnvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME, pool_name);
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE, spa_state(spa));
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG, txg);
fnvlist_add_uint64(config, ZPOOL_CONFIG_POOL_GUID, spa_guid(spa));
if (spa->spa_comment != NULL) {
fnvlist_add_string(config, ZPOOL_CONFIG_COMMENT,