128
126
if (spa_lookup(nvpair_name(nvpair)) != NULL)
130
spa = spa_add(nvpair_name(nvpair), NULL);
133
* We blindly duplicate the configuration here. If it's
134
* invalid, we will catch it when the pool is first opened.
136
VERIFY(nvlist_dup(child, &spa->spa_config, 0) == 0);
128
(void) spa_add(nvpair_name(nvpair), child, NULL);
138
130
mutex_exit(&spa_namespace_lock);
313
305
mutex_exit(&spa->spa_props_lock);
308
/* Add discovered rewind info, if any to the provided nvlist */
310
spa_rewind_data_to_nvlist(spa_t *spa, nvlist_t *tonvl)
314
if (tonvl == NULL || spa->spa_load_txg == 0)
317
VERIFY(nvlist_add_uint64(tonvl, ZPOOL_CONFIG_LOAD_TIME,
318
spa->spa_load_txg_ts) == 0);
319
if (spa->spa_last_ubsync_txg)
320
loss = spa->spa_last_ubsync_txg_ts - spa->spa_load_txg_ts;
321
VERIFY(nvlist_add_int64(tonvl, ZPOOL_CONFIG_REWIND_TIME, loss) == 0);
322
VERIFY(nvlist_add_uint64(tonvl, ZPOOL_CONFIG_LOAD_DATA_ERRORS,
323
spa->spa_load_data_errors) == 0);
317
327
* Generate the pool's configuration based on the current in-core state.
318
328
* We infer whether to generate a complete config or just one top-level config
378
389
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_IS_LOG,
380
391
vd = vd->vdev_top; /* label contains top config */
394
* Only add the (potentially large) split information
395
* in the mos config, and not in the vdev labels
397
if (spa->spa_config_splitting != NULL)
398
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_SPLIT,
399
spa->spa_config_splitting) == 0);
403
* Add the top-level config. We even add this on pools which
404
* don't support holes in the namespace as older pools will
407
vdev_top_config_generate(spa, config);
410
* If we're splitting, record the original pool's guid.
412
if (spa->spa_config_splitting != NULL &&
413
nvlist_lookup_uint64(spa->spa_config_splitting,
414
ZPOOL_CONFIG_SPLIT_GUID, &split_guid) == 0) {
415
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_SPLIT_GUID,
383
419
nvroot = vdev_config_generate(spa, vd, getstats, B_FALSE, B_FALSE);
384
420
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot) == 0);
385
421
nvlist_free(nvroot);
423
if (getstats && spa_load_state(spa) == SPA_LOAD_NONE) {
424
ddt_histogram_t *ddh;
428
ddh = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP);
429
ddt_get_dedup_histogram(spa, ddh);
430
VERIFY(nvlist_add_uint64_array(config,
431
ZPOOL_CONFIG_DDT_HISTOGRAM,
432
(uint64_t *)ddh, sizeof (*ddh) / sizeof (uint64_t)) == 0);
433
kmem_free(ddh, sizeof (ddt_histogram_t));
435
ddo = kmem_zalloc(sizeof (ddt_object_t), KM_SLEEP);
436
ddt_get_dedup_object_stats(spa, ddo);
437
VERIFY(nvlist_add_uint64_array(config,
438
ZPOOL_CONFIG_DDT_OBJ_STATS,
439
(uint64_t *)ddo, sizeof (*ddo) / sizeof (uint64_t)) == 0);
440
kmem_free(ddo, sizeof (ddt_object_t));
442
dds = kmem_zalloc(sizeof (ddt_stat_t), KM_SLEEP);
443
ddt_get_dedup_stats(spa, dds);
444
VERIFY(nvlist_add_uint64_array(config,
445
ZPOOL_CONFIG_DDT_STATS,
446
(uint64_t *)dds, sizeof (*dds) / sizeof (uint64_t)) == 0);
447
kmem_free(dds, sizeof (ddt_stat_t));
450
spa_rewind_data_to_nvlist(spa, config);
388
453
spa_config_exit(spa, SCL_CONFIG | SCL_STATE, FTAG);
394
* For a pool that's not currently a booting rootpool, update all disk labels,
395
* generate a fresh config based on the current in-core state, and sync the
396
* global config cache.
399
spa_config_update(spa_t *spa, int what)
401
spa_config_update_common(spa, what, FALSE);
405
459
* Update all disk labels, generate a fresh config based on the current
406
460
* in-core state, and sync the global config cache (do not sync the config
407
461
* cache if this is a booting rootpool).
410
spa_config_update_common(spa_t *spa, int what, boolean_t isroot)
464
spa_config_update(spa_t *spa, int what)
412
466
vdev_t *rvd = spa->spa_root_vdev;
446
499
* Update the global config cache to reflect the new mosconfig.
501
if (!spa->spa_is_root)
449
502
spa_config_sync(spa, B_FALSE, what != SPA_CONFIG_UPDATE_POOL);
451
504
if (what == SPA_CONFIG_UPDATE_POOL)
452
spa_config_update_common(spa, SPA_CONFIG_UPDATE_VDEVS, isroot);
505
spa_config_update(spa, SPA_CONFIG_UPDATE_VDEVS);