Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/zfs/vdev_removal.c
Show First 20 Lines • Show All 1,201 Lines • ▼ Show 20 Lines | vdev_remove_complete(spa_t *spa) | ||||
* Discard allocation state. | * Discard allocation state. | ||||
*/ | */ | ||||
if (vd->vdev_mg != NULL) { | if (vd->vdev_mg != NULL) { | ||||
vdev_metaslab_fini(vd); | vdev_metaslab_fini(vd); | ||||
metaslab_group_destroy(vd->vdev_mg); | metaslab_group_destroy(vd->vdev_mg); | ||||
vd->vdev_mg = NULL; | vd->vdev_mg = NULL; | ||||
spa_log_sm_set_blocklimit(spa); | spa_log_sm_set_blocklimit(spa); | ||||
} | } | ||||
if (vd->vdev_log_mg != NULL) { | |||||
ASSERT0(vd->vdev_ms_count); | |||||
metaslab_group_destroy(vd->vdev_log_mg); | |||||
vd->vdev_log_mg = NULL; | |||||
} | |||||
ASSERT0(vd->vdev_stat.vs_space); | ASSERT0(vd->vdev_stat.vs_space); | ||||
ASSERT0(vd->vdev_stat.vs_dspace); | ASSERT0(vd->vdev_stat.vs_dspace); | ||||
vdev_remove_replace_with_indirect(vd, txg); | vdev_remove_replace_with_indirect(vd, txg); | ||||
/* | /* | ||||
* We now release the locks, allowing spa_sync to run and finish the | * We now release the locks, allowing spa_sync to run and finish the | ||||
* removal via vdev_remove_complete_sync in syncing context. | * removal via vdev_remove_complete_sync in syncing context. | ||||
▲ Show 20 Lines • Show All 557 Lines • ▼ Show 20 Lines | spa_vdev_remove_cancel_impl(spa_t *spa) | ||||
int error = dsl_sync_task(spa->spa_name, spa_vdev_remove_cancel_check, | int error = dsl_sync_task(spa->spa_name, spa_vdev_remove_cancel_check, | ||||
spa_vdev_remove_cancel_sync, NULL, 0, | spa_vdev_remove_cancel_sync, NULL, 0, | ||||
ZFS_SPACE_CHECK_EXTRA_RESERVED); | ZFS_SPACE_CHECK_EXTRA_RESERVED); | ||||
if (error == 0) { | if (error == 0) { | ||||
spa_config_enter(spa, SCL_ALLOC | SCL_VDEV, FTAG, RW_WRITER); | spa_config_enter(spa, SCL_ALLOC | SCL_VDEV, FTAG, RW_WRITER); | ||||
vdev_t *vd = vdev_lookup_top(spa, vdid); | vdev_t *vd = vdev_lookup_top(spa, vdid); | ||||
metaslab_group_activate(vd->vdev_mg); | metaslab_group_activate(vd->vdev_mg); | ||||
ASSERT(!vd->vdev_islog); | |||||
metaslab_group_activate(vd->vdev_log_mg); | |||||
spa_config_exit(spa, SCL_ALLOC | SCL_VDEV, FTAG); | spa_config_exit(spa, SCL_ALLOC | SCL_VDEV, FTAG); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
spa_vdev_remove_cancel(spa_t *spa) | spa_vdev_remove_cancel(spa_t *spa) | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) | spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) | ||||
{ | { | ||||
metaslab_group_t *mg = vd->vdev_mg; | metaslab_group_t *mg = vd->vdev_mg; | ||||
spa_t *spa = vd->vdev_spa; | spa_t *spa = vd->vdev_spa; | ||||
int error = 0; | int error = 0; | ||||
ASSERT(vd->vdev_islog); | ASSERT(vd->vdev_islog); | ||||
ASSERT(vd == vd->vdev_top); | ASSERT(vd == vd->vdev_top); | ||||
ASSERT3P(vd->vdev_log_mg, ==, NULL); | |||||
ASSERT(MUTEX_HELD(&spa_namespace_lock)); | ASSERT(MUTEX_HELD(&spa_namespace_lock)); | ||||
/* | /* | ||||
* Stop allocating from this vdev. | * Stop allocating from this vdev. | ||||
*/ | */ | ||||
metaslab_group_passivate(mg); | metaslab_group_passivate(mg); | ||||
/* | /* | ||||
Show All 19 Lines | spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) | ||||
ASSERT(MUTEX_HELD(&spa_namespace_lock)); | ASSERT(MUTEX_HELD(&spa_namespace_lock)); | ||||
if (vd->vdev_stat.vs_alloc != 0) | if (vd->vdev_stat.vs_alloc != 0) | ||||
error = spa_reset_logs(spa); | error = spa_reset_logs(spa); | ||||
*txg = spa_vdev_config_enter(spa); | *txg = spa_vdev_config_enter(spa); | ||||
if (error != 0) { | if (error != 0) { | ||||
metaslab_group_activate(mg); | metaslab_group_activate(mg); | ||||
ASSERT3P(vd->vdev_log_mg, ==, NULL); | |||||
return (error); | return (error); | ||||
} | } | ||||
ASSERT0(vd->vdev_stat.vs_alloc); | ASSERT0(vd->vdev_stat.vs_alloc); | ||||
/* | /* | ||||
* The evacuation succeeded. Remove any remaining MOS metadata | * The evacuation succeeded. Remove any remaining MOS metadata | ||||
* associated with this vdev, and wait for these changes to sync. | * associated with this vdev, and wait for these changes to sync. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | spa_vdev_remove_top(vdev_t *vd, uint64_t *txg) | ||||
* that this is not the only device in the pool before | * that this is not the only device in the pool before | ||||
* passivating, otherwise we will not be able to make | * passivating, otherwise we will not be able to make | ||||
* progress because we can't allocate from any vdevs. | * progress because we can't allocate from any vdevs. | ||||
* The above check for sufficient free space serves this | * The above check for sufficient free space serves this | ||||
* purpose. | * purpose. | ||||
*/ | */ | ||||
metaslab_group_t *mg = vd->vdev_mg; | metaslab_group_t *mg = vd->vdev_mg; | ||||
metaslab_group_passivate(mg); | metaslab_group_passivate(mg); | ||||
ASSERT(!vd->vdev_islog); | |||||
metaslab_group_passivate(vd->vdev_log_mg); | |||||
/* | /* | ||||
* Wait for the youngest allocations and frees to sync, | * Wait for the youngest allocations and frees to sync, | ||||
* and then wait for the deferral of those frees to finish. | * and then wait for the deferral of those frees to finish. | ||||
*/ | */ | ||||
spa_vdev_config_exit(spa, NULL, | spa_vdev_config_exit(spa, NULL, | ||||
*txg + TXG_CONCURRENT_STATES + TXG_DEFER_SIZE, 0, FTAG); | *txg + TXG_CONCURRENT_STATES + TXG_DEFER_SIZE, 0, FTAG); | ||||
Show All 20 Lines | spa_vdev_remove_top(vdev_t *vd, uint64_t *txg) | ||||
* Things might have changed while the config lock was dropped | * Things might have changed while the config lock was dropped | ||||
* (e.g. space usage). Check for errors again. | * (e.g. space usage). Check for errors again. | ||||
*/ | */ | ||||
if (error == 0) | if (error == 0) | ||||
error = spa_vdev_remove_top_check(vd); | error = spa_vdev_remove_top_check(vd); | ||||
if (error != 0) { | if (error != 0) { | ||||
metaslab_group_activate(mg); | metaslab_group_activate(mg); | ||||
ASSERT(!vd->vdev_islog); | |||||
metaslab_group_activate(vd->vdev_log_mg); | |||||
spa_async_request(spa, SPA_ASYNC_INITIALIZE_RESTART); | spa_async_request(spa, SPA_ASYNC_INITIALIZE_RESTART); | ||||
spa_async_request(spa, SPA_ASYNC_TRIM_RESTART); | spa_async_request(spa, SPA_ASYNC_TRIM_RESTART); | ||||
spa_async_request(spa, SPA_ASYNC_AUTOTRIM_RESTART); | spa_async_request(spa, SPA_ASYNC_AUTOTRIM_RESTART); | ||||
return (error); | return (error); | ||||
} | } | ||||
vd->vdev_removing = B_TRUE; | vd->vdev_removing = B_TRUE; | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |