Lines Matching refs:spa

138 spa_sync_removing_state(spa_t *spa, dmu_tx_t *tx)  in spa_sync_removing_state()  argument
140 VERIFY0(zap_update(spa->spa_dsl_pool->dp_meta_objset, in spa_sync_removing_state()
143 sizeof (spa->spa_removing_phys) / sizeof (uint64_t), in spa_sync_removing_state()
144 &spa->spa_removing_phys, tx)); in spa_sync_removing_state()
237 spa_t *spa = dmu_tx_pool(tx)->dp_spa; in vdev_remove_initiate_sync() local
238 vdev_t *vd = vdev_lookup_top(spa, vdev_id); in vdev_remove_initiate_sync()
240 objset_t *mos = spa->spa_dsl_pool->dp_meta_objset; in vdev_remove_initiate_sync()
250 spa_feature_incr(spa, SPA_FEATURE_DEVICE_REMOVAL, tx); in vdev_remove_initiate_sync()
251 if (spa_feature_is_enabled(spa, SPA_FEATURE_OBSOLETE_COUNTS)) { in vdev_remove_initiate_sync()
257 spa_feature_incr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx); in vdev_remove_initiate_sync()
259 VERIFY0(zap_add(spa->spa_meta_objset, vd->vdev_top_zap, in vdev_remove_initiate_sync()
271 spa->spa_removing_phys.sr_removing_vdev = vd->vdev_id; in vdev_remove_initiate_sync()
272 spa->spa_removing_phys.sr_start_time = gethrestime_sec(); in vdev_remove_initiate_sync()
273 spa->spa_removing_phys.sr_end_time = 0; in vdev_remove_initiate_sync()
274 spa->spa_removing_phys.sr_state = DSS_SCANNING; in vdev_remove_initiate_sync()
275 spa->spa_removing_phys.sr_to_copy = 0; in vdev_remove_initiate_sync()
276 spa->spa_removing_phys.sr_copied = 0; in vdev_remove_initiate_sync()
288 spa->spa_removing_phys.sr_to_copy += in vdev_remove_initiate_sync()
295 spa->spa_removing_phys.sr_to_copy -= in vdev_remove_initiate_sync()
309 spa_sync_removing_state(spa, tx); in vdev_remove_initiate_sync()
340 spa_history_log_internal(spa, "vdev remove started", tx, in vdev_remove_initiate_sync()
341 "%s vdev %llu %s", spa_name(spa), vd->vdev_id, in vdev_remove_initiate_sync()
351 ASSERT3P(spa->spa_vdev_removal, ==, NULL); in vdev_remove_initiate_sync()
352 spa->spa_vdev_removal = svr; in vdev_remove_initiate_sync()
354 spa_vdev_remove_thread, spa, 0, &p0, TS_RUN, minclsyspri); in vdev_remove_initiate_sync()
366 spa_remove_init(spa_t *spa) in spa_remove_init() argument
370 error = zap_lookup(spa->spa_dsl_pool->dp_meta_objset, in spa_remove_init()
373 sizeof (spa->spa_removing_phys) / sizeof (uint64_t), in spa_remove_init()
374 &spa->spa_removing_phys); in spa_remove_init()
377 spa->spa_removing_phys.sr_state = DSS_NONE; in spa_remove_init()
378 spa->spa_removing_phys.sr_removing_vdev = -1; in spa_remove_init()
379 spa->spa_removing_phys.sr_prev_indirect_vdev = -1; in spa_remove_init()
380 spa->spa_indirect_vdevs_loaded = B_TRUE; in spa_remove_init()
386 if (spa->spa_removing_phys.sr_state == DSS_SCANNING) { in spa_remove_init()
393 spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); in spa_remove_init()
394 vdev_t *vd = vdev_lookup_top(spa, in spa_remove_init()
395 spa->spa_removing_phys.sr_removing_vdev); in spa_remove_init()
398 spa_config_exit(spa, SCL_STATE, FTAG); in spa_remove_init()
410 spa->spa_meta_objset, vic->vic_mapping_object); in spa_remove_init()
412 spa->spa_meta_objset, vic->vic_births_object); in spa_remove_init()
413 spa_config_exit(spa, SCL_STATE, FTAG); in spa_remove_init()
415 spa->spa_vdev_removal = svr; in spa_remove_init()
418 spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); in spa_remove_init()
420 spa->spa_removing_phys.sr_prev_indirect_vdev; in spa_remove_init()
422 vdev_t *vd = vdev_lookup_top(spa, indirect_vdev_id); in spa_remove_init()
427 spa->spa_meta_objset, vic->vic_mapping_object); in spa_remove_init()
429 spa->spa_meta_objset, vic->vic_births_object); in spa_remove_init()
433 spa_config_exit(spa, SCL_STATE, FTAG); in spa_remove_init()
439 spa->spa_indirect_vdevs_loaded = B_TRUE; in spa_remove_init()
444 spa_restart_removal(spa_t *spa) in spa_restart_removal() argument
446 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in spa_restart_removal()
463 if (!spa_writeable(spa)) in spa_restart_removal()
467 svr->svr_thread = thread_create(NULL, 0, spa_vdev_remove_thread, spa, in spa_restart_removal()
479 spa_t *spa = vd->vdev_spa; in free_from_removing_vdev() local
480 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in free_from_removing_vdev()
482 uint64_t txg = spa_syncing_txg(spa); in free_from_removing_vdev()
508 ASSERT(!spa_has_checkpoint(spa)); in free_from_removing_vdev()
534 spa_t *, spa, in free_from_removing_vdev()
559 spa_t *, spa, in free_from_removing_vdev()
620 spa_t *, spa, in free_from_removing_vdev()
659 spa_finish_removal(spa_t *spa, dsl_scan_state_t state, dmu_tx_t *tx) in spa_finish_removal() argument
661 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in spa_finish_removal()
662 ASSERT3U(dmu_tx_get_txg(tx), ==, spa_syncing_txg(spa)); in spa_finish_removal()
665 spa_vdev_remove_suspend(spa); in spa_finish_removal()
670 spa_removing_phys_t *srp = &spa->spa_removing_phys; in spa_finish_removal()
671 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id); in spa_finish_removal()
675 vdev_t *pvd = vdev_lookup_top(spa, in spa_finish_removal()
683 spa->spa_removing_phys.sr_state = state; in spa_finish_removal()
684 spa->spa_removing_phys.sr_end_time = gethrestime_sec(); in spa_finish_removal()
686 spa->spa_vdev_removal = NULL; in spa_finish_removal()
689 spa_sync_removing_state(spa, tx); in spa_finish_removal()
691 vdev_config_dirty(spa->spa_root_vdev); in spa_finish_removal()
713 spa_t *spa = dmu_tx_pool(tx)->dp_spa; in vdev_mapping_sync() local
714 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id); in vdev_mapping_sync()
720 ASSERT3U(txg, ==, spa_syncing_txg(spa)); in vdev_mapping_sync()
739 spa_sync_removing_state(spa, tx); in vdev_mapping_sync()
753 spa_t *spa = vcsa->vcsa_spa; in unalloc_seg() local
771 zio_free(spa, vcsa->vcsa_txg, &bp); in unalloc_seg()
909 spa_t *spa = vd->vdev_spa; in spa_vdev_copy_segment() local
910 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in spa_vdev_copy_segment()
948 if (mc != spa_normal_class(spa) && mc->mc_groups <= 1) in spa_vdev_copy_segment()
949 mc = spa_normal_class(spa); in spa_vdev_copy_segment()
950 int error = metaslab_alloc_dva(spa, mc, size, &dst, 0, NULL, txg, 0, in spa_vdev_copy_segment()
952 if (error == ENOSPC && mc != spa_normal_class(spa)) { in spa_vdev_copy_segment()
953 error = metaslab_alloc_dva(spa, spa_normal_class(spa), size, in spa_vdev_copy_segment()
997 if (spa_feature_is_enabled(spa, SPA_FEATURE_OBSOLETE_COUNTS)) { in spa_vdev_copy_segment()
1004 vcsa->vcsa_spa = spa; in spa_vdev_copy_segment()
1010 spa_config_enter(spa, SCL_STATE, spa, RW_READER); in spa_vdev_copy_segment()
1011 zio_t *nzio = zio_null(spa->spa_txg_zio[txg & TXG_MASK], spa, NULL, in spa_vdev_copy_segment()
1013 vdev_t *dest_vd = vdev_lookup_top(spa, DVA_GET_VDEV(&dst)); in spa_vdev_copy_segment()
1042 spa_t *spa = dmu_tx_pool(tx)->dp_spa; in vdev_remove_complete_sync() local
1043 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id); in vdev_remove_complete_sync()
1051 ASSERT3U(spa->spa_removing_phys.sr_copied, ==, in vdev_remove_complete_sync()
1052 spa->spa_removing_phys.sr_to_copy); in vdev_remove_complete_sync()
1067 spa_history_log_internal(spa, "vdev remove completed", tx, in vdev_remove_complete_sync()
1068 "%s vdev %llu", spa_name(spa), vd->vdev_id); in vdev_remove_complete_sync()
1094 spa_t *spa = vd->vdev_spa; in vdev_remove_replace_with_indirect() local
1095 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in vdev_remove_replace_with_indirect()
1115 tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg); in vdev_remove_replace_with_indirect()
1116 dsl_sync_task_nowait(spa->spa_dsl_pool, vdev_remove_complete_sync, svr, in vdev_remove_replace_with_indirect()
1135 vdev_remove_complete(spa_t *spa) in vdev_remove_complete() argument
1143 txg_wait_synced(spa->spa_dsl_pool, 0); in vdev_remove_complete()
1144 txg = spa_vdev_enter(spa); in vdev_remove_complete()
1145 vdev_t *vd = vdev_lookup_top(spa, spa->spa_vdev_removal->svr_vdev_id); in vdev_remove_complete()
1150 sysevent_t *ev = spa_event_create(spa, vd, NULL, in vdev_remove_complete()
1163 spa_log_sm_set_blocklimit(spa); in vdev_remove_complete()
1178 (void) spa_vdev_exit(spa, NULL, txg, 0); in vdev_remove_complete()
1191 txg = spa_vdev_enter(spa); in vdev_remove_complete()
1196 vdev_config_dirty(spa->spa_root_vdev); in vdev_remove_complete()
1197 (void) spa_vdev_exit(spa, vd, txg, 0); in vdev_remove_complete()
1214 spa_t *spa = dmu_tx_pool(tx)->dp_spa; in spa_vdev_copy_impl() local
1304 ASSERT3U(spa->spa_max_ashift, >=, SPA_MINBLOCKSHIFT); in spa_vdev_copy_impl()
1305 ASSERT3U(spa->spa_max_ashift, ==, spa->spa_min_ashift); in spa_vdev_copy_impl()
1309 1 << spa->spa_max_ashift); in spa_vdev_copy_impl()
1313 ASSERT3U(attempted, >, 1 << spa->spa_max_ashift); in spa_vdev_copy_impl()
1314 *max_alloc = attempted - (1 << spa->spa_max_ashift); in spa_vdev_copy_impl()
1349 spa_t *spa = arg; in spa_vdev_remove_thread() local
1350 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in spa_vdev_remove_thread()
1355 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER); in spa_vdev_remove_thread()
1356 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id); in spa_vdev_remove_thread()
1443 spa_config_exit(spa, SCL_CONFIG, FTAG); in spa_vdev_remove_thread()
1451 spa->spa_removing_phys.sr_copied; in spa_vdev_remove_thread()
1466 dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir); in spa_vdev_remove_thread()
1476 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER); in spa_vdev_remove_thread()
1477 vd = vdev_lookup_top(spa, svr->svr_vdev_id); in spa_vdev_remove_thread()
1492 spa_config_exit(spa, SCL_CONFIG, FTAG); in spa_vdev_remove_thread()
1497 txg_wait_synced(spa->spa_dsl_pool, 0); in spa_vdev_remove_thread()
1511 vdev_remove_complete(spa); in spa_vdev_remove_thread()
1516 spa_vdev_remove_suspend(spa_t *spa) in spa_vdev_remove_suspend() argument
1518 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in spa_vdev_remove_suspend()
1535 spa_t *spa = dmu_tx_pool(tx)->dp_spa; in spa_vdev_remove_cancel_check() local
1537 if (spa->spa_vdev_removal == NULL) in spa_vdev_remove_cancel_check()
1550 spa_t *spa = dmu_tx_pool(tx)->dp_spa; in spa_vdev_remove_cancel_sync() local
1551 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in spa_vdev_remove_cancel_sync()
1552 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id); in spa_vdev_remove_cancel_sync()
1555 objset_t *mos = spa->spa_meta_objset; in spa_vdev_remove_cancel_sync()
1559 spa_feature_decr(spa, SPA_FEATURE_DEVICE_REMOVAL, tx); in spa_vdev_remove_cancel_sync()
1561 spa_feature_decr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx); in spa_vdev_remove_cancel_sync()
1562 VERIFY0(zap_remove(spa->spa_meta_objset, vd->vdev_top_zap, in spa_vdev_remove_cancel_sync()
1572 VERIFY0(zap_remove(spa->spa_meta_objset, vd->vdev_top_zap, in spa_vdev_remove_cancel_sync()
1576 spa_feature_decr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx); in spa_vdev_remove_cancel_sync()
1665 spa_finish_removal(spa, DSS_CANCELED, tx); in spa_vdev_remove_cancel_sync()
1672 spa_history_log_internal(spa, "vdev remove canceled", tx, in spa_vdev_remove_cancel_sync()
1673 "%s vdev %llu %s", spa_name(spa), in spa_vdev_remove_cancel_sync()
1678 spa_vdev_remove_cancel(spa_t *spa) in spa_vdev_remove_cancel() argument
1680 spa_vdev_remove_suspend(spa); in spa_vdev_remove_cancel()
1682 if (spa->spa_vdev_removal == NULL) in spa_vdev_remove_cancel()
1685 uint64_t vdid = spa->spa_vdev_removal->svr_vdev_id; in spa_vdev_remove_cancel()
1687 int error = dsl_sync_task(spa->spa_name, spa_vdev_remove_cancel_check, in spa_vdev_remove_cancel()
1692 spa_config_enter(spa, SCL_ALLOC | SCL_VDEV, FTAG, RW_WRITER); in spa_vdev_remove_cancel()
1693 vdev_t *vd = vdev_lookup_top(spa, vdid); in spa_vdev_remove_cancel()
1695 spa_config_exit(spa, SCL_ALLOC | SCL_VDEV, FTAG); in spa_vdev_remove_cancel()
1702 svr_sync(spa_t *spa, dmu_tx_t *tx) in svr_sync() argument
1704 spa_vdev_removal_t *svr = spa->spa_vdev_removal; in svr_sync()
1722 spa->spa_removing_phys.sr_copied += svr->svr_bytes_done[txgoff]; in svr_sync()
1725 spa_sync_removing_state(spa, tx); in svr_sync()
1732 spa_t *spa = vd->vdev_spa; in vdev_remove_make_hole_and_free() local
1733 vdev_t *rvd = spa->spa_root_vdev; in vdev_remove_make_hole_and_free()
1736 ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL); in vdev_remove_make_hole_and_free()
1740 vd = vdev_alloc_common(spa, id, 0, &vdev_hole_ops); in vdev_remove_make_hole_and_free()
1757 spa_t *spa = vd->vdev_spa; in spa_vdev_remove_log() local
1773 spa_vdev_config_exit(spa, NULL, in spa_vdev_remove_log()
1784 error = spa_reset_logs(spa); in spa_vdev_remove_log()
1786 *txg = spa_vdev_config_enter(spa); in spa_vdev_remove_log()
1824 spa_log_sm_set_blocklimit(spa); in spa_vdev_remove_log()
1826 spa_history_log_internal(spa, "vdev remove", NULL, in spa_vdev_remove_log()
1827 "%s vdev %llu (log) %s", spa_name(spa), vd->vdev_id, in spa_vdev_remove_log()
1831 spa_vdev_config_exit(spa, NULL, *txg, 0, FTAG); in spa_vdev_remove_log()
1838 *txg = spa_vdev_config_enter(spa); in spa_vdev_remove_log()
1840 sysevent_t *ev = spa_event_create(spa, vd, NULL, in spa_vdev_remove_log()
1843 ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL); in spa_vdev_remove_log()
1873 spa_t *spa = vd->vdev_spa; in spa_vdev_remove_top_check() local
1878 if (!spa_feature_is_enabled(spa, SPA_FEATURE_DEVICE_REMOVAL)) in spa_vdev_remove_top_check()
1883 spa->spa_dsl_pool->dp_root_dir, NULL, 0, B_TRUE); in spa_vdev_remove_top_check()
1891 if (mc != spa_normal_class(spa) && mc->mc_groups > 1) { in spa_vdev_remove_top_check()
1905 if (available < vd->vdev_stat.vs_dspace + spa_get_slop_space(spa)) { in spa_vdev_remove_top_check()
1912 if (spa->spa_removing_phys.sr_state == DSS_SCANNING) in spa_vdev_remove_top_check()
1931 if (spa->spa_max_ashift != spa->spa_min_ashift) { in spa_vdev_remove_top_check()
1939 vdev_t *rvd = spa->spa_root_vdev; in spa_vdev_remove_top_check()
1944 ASSERT3U(cvd->vdev_ashift, ==, spa->spa_max_ashift); in spa_vdev_remove_top_check()
1978 spa_t *spa = vd->vdev_spa; in spa_vdev_remove_top() local
2005 spa_vdev_config_exit(spa, NULL, in spa_vdev_remove_top()
2014 error = spa_reset_logs(spa); in spa_vdev_remove_top()
2025 *txg = spa_vdev_config_enter(spa); in spa_vdev_remove_top()
2036 spa_async_request(spa, SPA_ASYNC_INITIALIZE_RESTART); in spa_vdev_remove_top()
2037 spa_async_request(spa, SPA_ASYNC_TRIM_RESTART); in spa_vdev_remove_top()
2038 spa_async_request(spa, SPA_ASYNC_AUTOTRIM_RESTART); in spa_vdev_remove_top()
2046 dmu_tx_t *tx = dmu_tx_create_assigned(spa->spa_dsl_pool, *txg); in spa_vdev_remove_top()
2047 dsl_sync_task_nowait(spa->spa_dsl_pool, in spa_vdev_remove_top()
2065 spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare) in spa_vdev_remove() argument
2075 ASSERT(spa_writeable(spa)); in spa_vdev_remove()
2078 txg = spa_vdev_enter(spa); in spa_vdev_remove()
2081 if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) { in spa_vdev_remove()
2082 error = (spa_has_checkpoint(spa)) ? in spa_vdev_remove()
2086 return (spa_vdev_exit(spa, NULL, txg, error)); in spa_vdev_remove()
2091 vd = spa_lookup_by_guid(spa, guid, B_FALSE); in spa_vdev_remove()
2093 if (spa->spa_spares.sav_vdevs != NULL && in spa_vdev_remove()
2094 nvlist_lookup_nvlist_array(spa->spa_spares.sav_config, in spa_vdev_remove()
2104 spa_history_log_internal(spa, "vdev remove", NULL, in spa_vdev_remove()
2105 "%s vdev (%s) %s", spa_name(spa), in spa_vdev_remove()
2108 vd = spa_lookup_by_guid(spa, guid, B_TRUE); in spa_vdev_remove()
2109 ev = spa_event_create(spa, vd, NULL, in spa_vdev_remove()
2111 spa_vdev_remove_aux(spa->spa_spares.sav_config, in spa_vdev_remove()
2113 spa_load_spares(spa); in spa_vdev_remove()
2114 spa->spa_spares.sav_sync = B_TRUE; in spa_vdev_remove()
2118 } else if (spa->spa_l2cache.sav_vdevs != NULL && in spa_vdev_remove()
2119 nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, in spa_vdev_remove()
2123 spa_history_log_internal(spa, "vdev remove", NULL, in spa_vdev_remove()
2124 "%s vdev (%s) %s", spa_name(spa), VDEV_TYPE_L2CACHE, nvstr); in spa_vdev_remove()
2128 vd = spa_lookup_by_guid(spa, guid, B_TRUE); in spa_vdev_remove()
2129 ev = spa_event_create(spa, vd, NULL, ESC_ZFS_VDEV_REMOVE_AUX); in spa_vdev_remove()
2130 spa_vdev_remove_aux(spa->spa_l2cache.sav_config, in spa_vdev_remove()
2132 spa_load_l2cache(spa); in spa_vdev_remove()
2133 spa->spa_l2cache.sav_sync = B_TRUE; in spa_vdev_remove()
2148 error = spa_vdev_exit(spa, NULL, txg, error); in spa_vdev_remove()
2162 spa_removal_get_stats(spa_t *spa, pool_removal_stat_t *prs) in spa_removal_get_stats() argument
2164 prs->prs_state = spa->spa_removing_phys.sr_state; in spa_removal_get_stats()
2169 prs->prs_removing_vdev = spa->spa_removing_phys.sr_removing_vdev; in spa_removal_get_stats()
2170 prs->prs_start_time = spa->spa_removing_phys.sr_start_time; in spa_removal_get_stats()
2171 prs->prs_end_time = spa->spa_removing_phys.sr_end_time; in spa_removal_get_stats()
2172 prs->prs_to_copy = spa->spa_removing_phys.sr_to_copy; in spa_removal_get_stats()
2173 prs->prs_copied = spa->spa_removing_phys.sr_copied; in spa_removal_get_stats()
2175 if (spa->spa_vdev_removal != NULL) { in spa_removal_get_stats()
2178 spa->spa_vdev_removal->svr_bytes_done[i]; in spa_removal_get_stats()
2184 spa->spa_removing_phys.sr_prev_indirect_vdev; in spa_removal_get_stats()
2186 vdev_t *vd = spa->spa_root_vdev->vdev_child[indirect_vdev_id]; in spa_removal_get_stats()