MCPcopy Create free account
hub / github.com/F-Stack/f-stack / spa_load_impl

Function spa_load_impl

freebsd/contrib/openzfs/module/zfs/spa.c:4634–4885  ·  view source on GitHub ↗

* Load an existing storage pool, using the config provided. This config * describes which vdevs are part of the pool and is later validated against * partial configs present in each vdev's label and an entire copy of the * config stored in the MOS. */

Source from the content-addressed store, hash-verified

4632 * config stored in the MOS.
4633 */
4634static int
4635spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport)
4636{
4637 int error = 0;
4638 boolean_t missing_feat_write = B_FALSE;
4639 boolean_t checkpoint_rewind =
4640 (spa->spa_import_flags & ZFS_IMPORT_CHECKPOINT);
4641 boolean_t update_config_cache = B_FALSE;
4642
4643 ASSERT(MUTEX_HELD(&spa_namespace_lock));
4644 ASSERT(spa->spa_config_source != SPA_CONFIG_SRC_NONE);
4645
4646 spa_load_note(spa, "LOADING");
4647
4648 error = spa_ld_mos_with_trusted_config(spa, type, &update_config_cache);
4649 if (error != 0)
4650 return (error);
4651
4652 /*
4653 * If we are rewinding to the checkpoint then we need to repeat
4654 * everything we've done so far in this function but this time
4655 * selecting the checkpointed uberblock and using that to open
4656 * the MOS.
4657 */
4658 if (checkpoint_rewind) {
4659 /*
4660 * If we are rewinding to the checkpoint update config cache
4661 * anyway.
4662 */
4663 update_config_cache = B_TRUE;
4664
4665 /*
4666 * Extract the checkpointed uberblock from the current MOS
4667 * and use this as the pool's uberblock from now on. If the
4668 * pool is imported as writeable we also write the checkpoint
4669 * uberblock to the labels, making the rewind permanent.
4670 */
4671 error = spa_ld_checkpoint_rewind(spa);
4672 if (error != 0)
4673 return (error);
4674
4675 /*
4676 * Redo the loading process again with the
4677 * checkpointed uberblock.
4678 */
4679 spa_ld_prepare_for_reload(spa);
4680 spa_load_note(spa, "LOADING checkpointed uberblock");
4681 error = spa_ld_mos_with_trusted_config(spa, type, NULL);
4682 if (error != 0)
4683 return (error);
4684 }
4685
4686 /*
4687 * Retrieve the checkpoint txg if the pool has a checkpoint.
4688 */
4689 error = spa_ld_read_checkpoint_txg(spa);
4690 if (error != 0)
4691 return (error);

Callers 1

spa_loadFunction · 0.85

Calls 15

spa_load_noteFunction · 0.85
spa_ld_checkpoint_rewindFunction · 0.85
spa_ld_check_featuresFunction · 0.85
spa_ld_get_propsFunction · 0.85
spa_ld_open_aux_vdevsFunction · 0.85
spa_ld_load_dedup_tablesFunction · 0.85

Tested by

no test coverage detected