1462 VDEV_ALLOC_L2CACHE) == 0);
1463 ASSERT(vd != NULL);
1464 newvdevs[i] = vd;
1465
1466 /*
1467 * Commit this vdev as an l2cache device,
1468 * even if it fails to open.
1469 */
1470 spa_l2cache_add(vd);
1471
1472 vd->vdev_top = vd;
1473 vd->vdev_aux = sav;
1474
1475 spa_l2cache_activate(vd);
1476
1477 if (vdev_open(vd) != 0)
1478 continue;
1479
1480 (void) vdev_validate_aux(vd);
1481
1482 if (!vdev_is_dead(vd))
1483 l2arc_add_vdev(spa, vd);
1484 }
1485 }
1486
1487 /*
1488 * Purge vdevs that were dropped
1489 */
1490 for (i = 0; i < oldnvdevs; i++) {
1491 uint64_t pool;
1492
1493 vd = oldvdevs[i];
1494 if (vd != NULL) {
1495 ASSERT(vd->vdev_isl2cache);
1496
1497 if (spa_l2cache_exists(vd->vdev_guid, &pool) &&
1498 pool != 0ULL && l2arc_vdev_present(vd))
1499 l2arc_remove_vdev(vd);
1500 vdev_clear_stats(vd);
1501 vdev_free(vd);
1502 }
1503 }
1504
1505 if (oldvdevs)
3863 error = spa_load_best(spa, state, B_TRUE, policy.zrp_txg,
3864 policy.zrp_request);
3865
3866 /*
3867 * Propagate anything learned while loading the pool and pass it
3868 * back to caller (i.e. rewind info, missing devices, etc).
3869 */
3870 VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
3871 spa->spa_load_info) == 0);
3872
3873 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
3874 /*
3875 * Toss any existing sparelist, as it doesn't have any validity
3876 * anymore, and conflicts with spa_has_spare().
3877 */
3878 if (spa->spa_spares.sav_config) {
3879 nvlist_free(spa->spa_spares.sav_config);
3880 spa->spa_spares.sav_config = NULL;
3881 spa_load_spares(spa);
3882 }
3883 if (spa->spa_l2cache.sav_config) {
3884 nvlist_free(spa->spa_l2cache.sav_config);
3885 spa->spa_l2cache.sav_config = NULL;
3886 spa_load_l2cache(spa);
3887 }
3888
3889 VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
3890 &nvroot) == 0);
3891 if (error == 0)
3892 error = spa_validate_aux(spa, nvroot, -1ULL,
3893 VDEV_ALLOC_SPARE);
3894 if (error == 0)
3895 error = spa_validate_aux(spa, nvroot, -1ULL,
3896 VDEV_ALLOC_L2CACHE);
3897 spa_config_exit(spa, SCL_ALL, FTAG);
3898
3899 if (props != NULL)
3900 spa_configfile_set(spa, props, B_FALSE);
3901
3902 if (error != 0 || (props && spa_writeable(spa) &&
3903 (error = spa_prop_set(spa, props)))) {
3904 spa_unload(spa);
3905 spa_deactivate(spa);
3906 spa_remove(spa);
3907 mutex_exit(&spa_namespace_lock);
|
1462 VDEV_ALLOC_L2CACHE) == 0);
1463 ASSERT(vd != NULL);
1464 newvdevs[i] = vd;
1465
1466 /*
1467 * Commit this vdev as an l2cache device,
1468 * even if it fails to open.
1469 */
1470 spa_l2cache_add(vd);
1471
1472 vd->vdev_top = vd;
1473 vd->vdev_aux = sav;
1474
1475 spa_l2cache_activate(vd);
1476
1477 if (vdev_open(vd) != 0)
1478 continue;
1479
1480 (void) vdev_validate_aux(vd);
1481
1482 if (!vdev_is_dead(vd)) {
1483 boolean_t persist = B_FALSE;
1484
1485 if (spa->spa_load_state != SPA_LOAD_TRYIMPORT) {
1486 /*
1487 * Only allow to do the L2ARC rebuild
1488 * when not doing a spa try-load.
1489 */
1490 (void) nvlist_lookup_boolean_value(
1491 l2cache[i],
1492 ZPOOL_CONFIG_L2CACHE_PERSISTENT,
1493 &persist);
1494 }
1495 l2arc_add_vdev(spa, vd, persist);
1496 }
1497 }
1498 }
1499
1500 /*
1501 * Purge vdevs that were dropped
1502 */
1503 for (i = 0; i < oldnvdevs; i++) {
1504 uint64_t pool;
1505
1506 vd = oldvdevs[i];
1507 if (vd != NULL) {
1508 ASSERT(vd->vdev_isl2cache);
1509
1510 if (spa_l2cache_exists(vd->vdev_guid, &pool) &&
1511 pool != 0ULL && l2arc_vdev_present(vd))
1512 l2arc_remove_vdev(vd);
1513 vdev_clear_stats(vd);
1514 vdev_free(vd);
1515 }
1516 }
1517
1518 if (oldvdevs)
3876 error = spa_load_best(spa, state, B_TRUE, policy.zrp_txg,
3877 policy.zrp_request);
3878
3879 /*
3880 * Propagate anything learned while loading the pool and pass it
3881 * back to caller (i.e. rewind info, missing devices, etc).
3882 */
3883 VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
3884 spa->spa_load_info) == 0);
3885
3886 spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
3887 /*
3888 * Toss any existing sparelist, as it doesn't have any validity
3889 * anymore, and conflicts with spa_has_spare().
3890 */
3891 if (spa->spa_spares.sav_config) {
3892 nvlist_free(spa->spa_spares.sav_config);
3893 spa->spa_spares.sav_config = NULL;
3894 spa_load_spares(spa);
3895 }
3896
3897 VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
3898 &nvroot) == 0);
3899 if (error == 0)
3900 error = spa_validate_aux(spa, nvroot, -1ULL,
3901 VDEV_ALLOC_SPARE);
3902 if (error == 0)
3903 error = spa_validate_aux(spa, nvroot, -1ULL,
3904 VDEV_ALLOC_L2CACHE);
3905 spa_config_exit(spa, SCL_ALL, FTAG);
3906
3907 if (props != NULL)
3908 spa_configfile_set(spa, props, B_FALSE);
3909
3910 if (error != 0 || (props && spa_writeable(spa) &&
3911 (error = spa_prop_set(spa, props)))) {
3912 spa_unload(spa);
3913 spa_deactivate(spa);
3914 spa_remove(spa);
3915 mutex_exit(&spa_namespace_lock);
|