summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/zcommon/zpool_prop.c2
-rw-r--r--module/zfs/spa.c18
2 files changed, 18 insertions, 2 deletions
diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c
index 6bde4f471..e5f69c815 100644
--- a/module/zcommon/zpool_prop.c
+++ b/module/zcommon/zpool_prop.c
@@ -131,6 +131,8 @@ zpool_prop_init(void)
/* hidden properties */
zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING,
PROP_READONLY, ZFS_TYPE_POOL, "NAME");
+ zprop_register_hidden(ZPOOL_PROP_TNAME, "tname", PROP_TYPE_STRING,
+ PROP_ONETIME, ZFS_TYPE_POOL, "TNAME");
}
/*
diff --git a/module/zfs/spa.c b/module/zfs/spa.c
index 62887122d..d96bda3fa 100644
--- a/module/zfs/spa.c
+++ b/module/zfs/spa.c
@@ -3496,12 +3496,17 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
boolean_t has_features;
nvpair_t *elem;
int c;
+ char *poolname;
+ nvlist_t *nvl;
+
+ if (nvlist_lookup_string(props, "tname", &poolname) != 0)
+ poolname = (char *)pool;
/*
* If this pool already exists, return failure.
*/
mutex_enter(&spa_namespace_lock);
- if (spa_lookup(pool) != NULL) {
+ if (spa_lookup(poolname) != NULL) {
mutex_exit(&spa_namespace_lock);
return (SET_ERROR(EEXIST));
}
@@ -3509,9 +3514,12 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
/*
* Allocate a new spa_t structure.
*/
+ nvl = fnvlist_alloc();
+ fnvlist_add_string(nvl, ZPOOL_CONFIG_POOL_NAME, pool);
(void) nvlist_lookup_string(props,
zpool_prop_to_name(ZPOOL_PROP_ALTROOT), &altroot);
- spa = spa_add(pool, NULL, altroot);
+ spa = spa_add(poolname, nvl, altroot);
+ fnvlist_free(nvl);
spa_activate(spa, spa_mode_global);
if (props && (error = spa_prop_validate(spa, props))) {
@@ -3521,6 +3529,12 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
return (error);
}
+ /*
+ * Temporary pool names should never be written to disk.
+ */
+ if (poolname != pool)
+ spa->spa_import_flags |= ZFS_IMPORT_TEMP_NAME;
+
has_features = B_FALSE;
for (elem = nvlist_next_nvpair(props, NULL);
elem != NULL; elem = nvlist_next_nvpair(props, elem)) {