diff options
author | Richard Yao <ryao@gentoo.org> | 2014-06-20 23:00:11 +0000 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2014-09-30 17:46:59 +0000 |
commit | 83e9986f6eefdf0afc387f06407087bba3ead4e9 (patch) | |
tree | 4a457cb85a0a59cd219319727893ab9446024ecf /module/zfs/spa.c | |
parent | 00d2a8c92f614f49d23dea5d73f7ea7eb489ccf1 (diff) | |
download | src-83e9986f6eefdf0afc387f06407087bba3ead4e9.tar.gz src-83e9986f6eefdf0afc387f06407087bba3ead4e9.zip |
Diffstat (limited to 'module/zfs/spa.c')
-rw-r--r-- | module/zfs/spa.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 62887122d5e4..d96bda3fa8b3 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)) { |