aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2013-07-01 10:57:04 -0400
committerBrian Behlendorf <[email protected]>2014-03-20 12:05:30 -0700
commit26b42f3f9d03f85cc7966dc2fe4dfe9216601b0e (patch)
treef0f0eab8b0d8b53c5fd8609451c6f6345a5bcd7d /module/zfs
parent8959b29e31975a281acc411e9f60203f09716e79 (diff)
Implement -t option to zpool import for temporary pool names
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 a -t option to specify that the new name is temporary. When specified, this sets an internal flag that is passed into the kernel to tell it that all label updates should refer to the name used in the original label. Consequently, the original pool name will be retained on export. Signed-off-by: Richard Yao <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2189
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/spa_config.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c
index 5b95a8e81..c8fe79ed5 100644
--- a/module/zfs/spa_config.c
+++ b/module/zfs/spa_config.c
@@ -208,6 +208,7 @@ spa_config_sync(spa_t *target, boolean_t removing, boolean_t postsysevent)
{
spa_config_dirent_t *dp, *tdp;
nvlist_t *nvl;
+ char *pool_name;
ASSERT(MUTEX_HELD(&spa_namespace_lock));
@@ -254,7 +255,13 @@ spa_config_sync(spa_t *target, boolean_t removing, boolean_t postsysevent)
VERIFY(nvlist_alloc(&nvl, NV_UNIQUE_NAME,
KM_PUSHPAGE) == 0);
- VERIFY(nvlist_add_nvlist(nvl, spa->spa_name,
+ if (spa->spa_import_flags & ZFS_IMPORT_TEMP_NAME) {
+ VERIFY0(nvlist_lookup_string(spa->spa_config,
+ ZPOOL_CONFIG_POOL_NAME, &pool_name));
+ } else
+ pool_name = spa_name(spa);
+
+ VERIFY(nvlist_add_nvlist(nvl, pool_name,
spa->spa_config) == 0);
mutex_exit(&spa->spa_props_lock);
}
@@ -337,6 +344,7 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
unsigned long hostid = 0;
boolean_t locked = B_FALSE;
uint64_t split_guid;
+ char *pool_name;
if (vd == NULL) {
vd = rvd;
@@ -353,12 +361,28 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
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) {
+ VERIFY0(nvlist_lookup_string(spa->spa_config,
+ ZPOOL_CONFIG_POOL_NAME, &pool_name));
+ } else
+ pool_name = spa_name(spa);
+
VERIFY(nvlist_alloc(&config, NV_UNIQUE_NAME, KM_PUSHPAGE) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_VERSION,
spa_version(spa)) == 0);
VERIFY(nvlist_add_string(config, ZPOOL_CONFIG_POOL_NAME,
- spa_name(spa)) == 0);
+ pool_name) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_STATE,
spa_state(spa)) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_POOL_TXG,