Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
Show First 20 Lines • Show All 4,660 Lines • ▼ Show 20 Lines | spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, | ||||
dsl_pool_t *dp; | dsl_pool_t *dp; | ||||
dmu_tx_t *tx; | dmu_tx_t *tx; | ||||
int error = 0; | int error = 0; | ||||
uint64_t txg = TXG_INITIAL; | uint64_t txg = TXG_INITIAL; | ||||
nvlist_t **spares, **l2cache; | nvlist_t **spares, **l2cache; | ||||
uint_t nspares, nl2cache; | uint_t nspares, nl2cache; | ||||
uint64_t version, obj; | uint64_t version, obj; | ||||
boolean_t has_features; | boolean_t has_features; | ||||
char *poolname; | |||||
nvlist_t *nvl; | |||||
if (nvlist_lookup_string(props, | |||||
zpool_prop_to_name(ZPOOL_PROP_TNAME), &poolname) != 0) | |||||
poolname = (char *)pool; | |||||
/* | /* | ||||
* If this pool already exists, return failure. | * If this pool already exists, return failure. | ||||
*/ | */ | ||||
mutex_enter(&spa_namespace_lock); | mutex_enter(&spa_namespace_lock); | ||||
if (spa_lookup(pool) != NULL) { | if (spa_lookup(poolname) != NULL) { | ||||
mutex_exit(&spa_namespace_lock); | mutex_exit(&spa_namespace_lock); | ||||
return (SET_ERROR(EEXIST)); | return (SET_ERROR(EEXIST)); | ||||
} | } | ||||
/* | /* | ||||
* Allocate a new spa_t structure. | * Allocate a new spa_t structure. | ||||
*/ | */ | ||||
nvl = fnvlist_alloc(); | |||||
fnvlist_add_string(nvl, ZPOOL_CONFIG_POOL_NAME, pool); | |||||
(void) nvlist_lookup_string(props, | (void) nvlist_lookup_string(props, | ||||
zpool_prop_to_name(ZPOOL_PROP_ALTROOT), &altroot); | 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); | spa_activate(spa, spa_mode_global); | ||||
if (props && (error = spa_prop_validate(spa, props))) { | if (props && (error = spa_prop_validate(spa, props))) { | ||||
spa_deactivate(spa); | spa_deactivate(spa); | ||||
spa_remove(spa); | spa_remove(spa); | ||||
mutex_exit(&spa_namespace_lock); | mutex_exit(&spa_namespace_lock); | ||||
return (error); | 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; | has_features = B_FALSE; | ||||
for (nvpair_t *elem = nvlist_next_nvpair(props, NULL); | for (nvpair_t *elem = nvlist_next_nvpair(props, NULL); | ||||
elem != NULL; elem = nvlist_next_nvpair(props, elem)) { | elem != NULL; elem = nvlist_next_nvpair(props, elem)) { | ||||
if (zpool_prop_feature(nvpair_name(elem))) | if (zpool_prop_feature(nvpair_name(elem))) | ||||
has_features = B_TRUE; | has_features = B_TRUE; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,620 Lines • Show Last 20 Lines |