* 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. */
| 4632 | * config stored in the MOS. |
| 4633 | */ |
| 4634 | static int |
| 4635 | spa_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); |
no test coverage detected