FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
/*
 * Update all disk labels, generate a fresh config based on the current
 * in-core state, and sync the global config cache (do not sync the config
 * cache if this is a booting rootpool).
 */
Update all disk labels, generate a fresh config based on the current
in-core state, and sync the global config cache (do not sync the config
cache if this is a booting rootpool).
Update all disk labels generate a fresh config based on the current in - core state and sync the global config cache ( do not sync the config cache if this is a booting rootpool ) .
void
spa_config_update(spa_t *spa, int what)
{
	vdev_t *rvd = spa->spa_root_vdev;
	uint64_t txg;
	int c;
	ASSERT(MUTEX_HELD(&spa_namespace_lock));
	spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
	txg = spa_last_synced_txg(spa) + 1;
	if (what == SPA_CONFIG_UPDATE_POOL) {
		vdev_config_dirty(rvd);
	} else {
		for (c = 0; c < rvd->vdev_children; c++) {
			vdev_t *tvd = rvd->vdev_child[c];
			if (tvd->vdev_ms_array == 0) {
				vdev_ashift_optimize(tvd);
				vdev_metaslab_set_size(tvd);
			}
			vdev_expand(tvd, txg);
		}
	}
	spa_config_exit(spa, SCL_ALL, FTAG);
	txg_wait_synced(spa->spa_dsl_pool, txg);
	spa_config_sync(spa, B_FALSE, what != SPA_CONFIG_UPDATE_POOL);
	if (what == SPA_CONFIG_UPDATE_POOL)
		spa_config_update(spa, SPA_CONFIG_UPDATE_VDEVS);
}
void spa_config_update ( spa_t * spa , int what ) { vdev_t * rvd = spa -> spa_root_vdev ; uint64_t txg ; int c ; ASSERT ( MUTEX_HELD ( & spa_namespace_lock ) ) ; spa_config_enter ( spa , SCL_ALL , FTAG , RW_WRITER ) ; txg = spa_last_synced_txg ( spa ) + 1 ; if ( what == SPA_CONFIG_UPDATE_POOL ) { vdev_config_dirty ( rvd ) ; } else { for ( c = 0 ; c < rvd -> vdev_children ; c ++ ) { vdev_t * tvd = rvd -> vdev_child [ c ] ; if ( tvd -> vdev_ms_array == 0 ) { vdev_ashift_optimize ( tvd ) ; vdev_metaslab_set_size ( tvd ) ; } vdev_expand ( tvd , txg ) ; } } spa_config_exit ( spa , SCL_ALL , FTAG ) ; txg_wait_synced ( spa -> spa_dsl_pool , txg ) ; spa_config_sync ( spa , B_FALSE , what != SPA_CONFIG_UPDATE_POOL ) ; if ( what == SPA_CONFIG_UPDATE_POOL ) spa_config_update ( spa , SPA_CONFIG_UPDATE_VDEVS ) ; }
Update all disk labels, generate a fresh config based on the current
 in-core state, and sync the global config cache (do not sync the config
 cache if this is a booting rootpool).
Update all disk labels generate a fresh config based on the current in - core state and sync the global config cache ( do not sync the config cache if this is a booting rootpool ) .
/*
		 * If we have top-level vdevs that were added but have
		 * not yet been prepared for allocation, do that now.
		 * (It's safe now because the config cache is up to date,
		 * so it will be able to translate the new DVAs.)
		 * See comments in spa_vdev_add() for full details.
		 */ /*
	 * Wait for the mosconfig to be regenerated and synced.
	 */ /*
	 * Update the global config cache to reflect the new mosconfig.
	 */