Lines Matching defs:spa

60  * into a hole vdev while holding spa config locks.
144 static int spa_vdev_remove_cancel_impl(spa_t *spa);
147 spa_sync_removing_state(spa_t *spa, dmu_tx_t *tx)
149 VERIFY0(zap_update(spa->spa_dsl_pool->dp_meta_objset,
152 sizeof (spa->spa_removing_phys) / sizeof (uint64_t),
153 &spa->spa_removing_phys, tx));
174 spa_t *spa = vd->vdev_spa;
175 uint64_t vdev_space = spa_deflate(spa) ?
184 ASSERT3U(spa->spa_nonallocating_dspace, >=, vdev_space);
186 spa->spa_nonallocating_dspace -= vdev_space;
194 spa_t *spa = vd->vdev_spa;
199 vdev_t *rvd = spa->spa_root_vdev;
201 metaslab_class_t *normal = spa_normal_class(spa);
237 spa_vdev_config_exit(spa, NULL,
246 error = spa_reset_logs(spa);
248 *txg = spa_vdev_config_enter(spa);
258 spa->spa_nonallocating_dspace += spa_deflate(spa) ?
275 spa_vdev_noalloc(spa_t *spa, uint64_t guid)
282 ASSERT(spa_writeable(spa));
284 txg = spa_vdev_enter(spa);
288 vd = spa_lookup_by_guid(spa, guid, B_FALSE);
302 error = spa_vdev_exit(spa, NULL, txg, error);
308 spa_vdev_alloc(spa_t *spa, uint64_t guid)
315 ASSERT(spa_writeable(spa));
317 txg = spa_vdev_enter(spa);
321 vd = spa_lookup_by_guid(spa, guid, B_FALSE);
335 (void) spa_vdev_exit(spa, NULL, txg, error);
417 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
418 vdev_t *vd = vdev_lookup_top(spa, vdev_id);
420 objset_t *mos = spa->spa_dsl_pool->dp_meta_objset;
430 spa_feature_incr(spa, SPA_FEATURE_DEVICE_REMOVAL, tx);
431 if (spa_feature_is_enabled(spa, SPA_FEATURE_OBSOLETE_COUNTS)) {
437 spa_feature_incr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx);
439 VERIFY0(zap_add(spa->spa_meta_objset, vd->vdev_top_zap,
453 spa->spa_removing_phys.sr_removing_vdev = vd->vdev_id;
454 spa->spa_removing_phys.sr_start_time = gethrestime_sec();
455 spa->spa_removing_phys.sr_end_time = 0;
456 spa->spa_removing_phys.sr_state = DSS_SCANNING;
457 spa->spa_removing_phys.sr_to_copy = 0;
458 spa->spa_removing_phys.sr_copied = 0;
470 spa->spa_removing_phys.sr_to_copy +=
477 spa->spa_removing_phys.sr_to_copy -=
491 spa_sync_removing_state(spa, tx);
523 spa_history_log_internal(spa, "vdev remove started", tx,
524 "%s vdev %llu %s", spa_name(spa), (u_longlong_t)vd->vdev_id,
534 ASSERT3P(spa->spa_vdev_removal, ==, NULL);
535 spa->spa_vdev_removal = svr;
537 spa_vdev_remove_thread, spa, 0, &p0, TS_RUN, minclsyspri);
549 spa_remove_init(spa_t *spa)
553 error = zap_lookup(spa->spa_dsl_pool->dp_meta_objset,
556 sizeof (spa->spa_removing_phys) / sizeof (uint64_t),
557 &spa->spa_removing_phys);
560 spa->spa_removing_phys.sr_state = DSS_NONE;
561 spa->spa_removing_phys.sr_removing_vdev = -1;
562 spa->spa_removing_phys.sr_prev_indirect_vdev = -1;
563 spa->spa_indirect_vdevs_loaded = B_TRUE;
569 if (spa->spa_removing_phys.sr_state == DSS_SCANNING) {
576 spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
577 vdev_t *vd = vdev_lookup_top(spa,
578 spa->spa_removing_phys.sr_removing_vdev);
581 spa_config_exit(spa, SCL_STATE, FTAG);
593 spa->spa_meta_objset, vic->vic_mapping_object);
595 spa->spa_meta_objset, vic->vic_births_object);
596 spa_config_exit(spa, SCL_STATE, FTAG);
598 spa->spa_vdev_removal = svr;
601 spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
603 spa->spa_removing_phys.sr_prev_indirect_vdev;
605 vdev_t *vd = vdev_lookup_top(spa, indirect_vdev_id);
610 spa->spa_meta_objset, vic->vic_mapping_object);
612 spa->spa_meta_objset, vic->vic_births_object);
616 spa_config_exit(spa, SCL_STATE, FTAG);
622 spa->spa_indirect_vdevs_loaded = B_TRUE;
627 spa_restart_removal(spa_t *spa)
629 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
646 if (!spa_writeable(spa))
651 svr->svr_thread = thread_create(NULL, 0, spa_vdev_remove_thread, spa,
663 spa_t *spa = vd->vdev_spa;
664 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
666 uint64_t txg = spa_syncing_txg(spa);
692 ASSERT(!spa_has_checkpoint(spa));
718 spa_t *, spa,
743 spa_t *, spa,
804 spa_t *, spa,
843 spa_finish_removal(spa_t *spa, dsl_scan_state_t state, dmu_tx_t *tx)
845 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
846 ASSERT3U(dmu_tx_get_txg(tx), ==, spa_syncing_txg(spa));
849 spa_vdev_remove_suspend(spa);
854 spa_removing_phys_t *srp = &spa->spa_removing_phys;
855 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id);
860 pvd = vdev_lookup_top(spa,
868 spa->spa_removing_phys.sr_state = state;
869 spa->spa_removing_phys.sr_end_time = gethrestime_sec();
871 spa->spa_vdev_removal = NULL;
874 spa_sync_removing_state(spa, tx);
875 spa_notify_waiters(spa);
877 vdev_config_dirty(spa->spa_root_vdev);
899 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
900 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id);
906 ASSERT3U(txg, ==, spa_syncing_txg(spa));
925 spa_sync_removing_state(spa, tx);
939 spa_t *spa = vcsa->vcsa_spa;
957 zio_free(spa, vcsa->vcsa_txg, &bp);
1127 spa_t *spa = vd->vdev_spa;
1128 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
1132 ASSERT0(P2PHASE(start, 1 << spa->spa_min_ashift));
1135 ASSERT0(P2PHASE(maxalloc, 1 << spa->spa_min_ashift));
1163 ASSERT0(P2PHASE(size, 1 << spa->spa_min_ashift));
1170 mc = spa_normal_class(spa);
1171 int error = metaslab_alloc_dva(spa, mc, size, &dst, 0, NULL, txg,
1173 if (error == ENOSPC && mc != spa_normal_class(spa)) {
1174 error = metaslab_alloc_dva(spa, spa_normal_class(spa), size,
1218 if (spa_feature_is_enabled(spa, SPA_FEATURE_OBSOLETE_COUNTS)) {
1225 vcsa->vcsa_spa = spa;
1231 spa_config_enter(spa, SCL_STATE, spa, RW_READER);
1232 zio_t *nzio = zio_null(spa->spa_txg_zio[txg & TXG_MASK], spa, NULL,
1234 vdev_t *dest_vd = vdev_lookup_top(spa, DVA_GET_VDEV(&dst));
1263 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
1264 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id);
1272 ASSERT3U(spa->spa_removing_phys.sr_copied, ==,
1273 spa->spa_removing_phys.sr_to_copy);
1288 spa_history_log_internal(spa, "vdev remove completed", tx,
1289 "%s vdev %llu", spa_name(spa), (u_longlong_t)vd->vdev_id);
1315 spa_t *spa = vd->vdev_spa;
1316 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
1342 tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
1343 dsl_sync_task_nowait(spa->spa_dsl_pool,
1353 vdev_remove_complete(spa_t *spa)
1361 txg_wait_synced(spa->spa_dsl_pool, 0);
1362 txg = spa_vdev_enter(spa);
1363 vdev_t *vd = vdev_lookup_top(spa, spa->spa_vdev_removal->svr_vdev_id);
1369 uint64_t vdev_space = spa_deflate(spa) ?
1372 sysevent_t *ev = spa_event_create(spa, vd, NULL,
1379 ASSERT3U(spa->spa_nonallocating_dspace, >=, vdev_space);
1382 spa->spa_nonallocating_dspace -= vdev_space;
1410 (void) spa_vdev_exit(spa, NULL, txg, 0);
1423 txg = spa_vdev_enter(spa);
1428 vdev_config_dirty(spa->spa_root_vdev);
1429 (void) spa_vdev_exit(spa, vd, txg, 0);
1447 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
1537 ASSERT3U(spa->spa_max_ashift, >=, SPA_MINBLOCKSHIFT);
1538 ASSERT3U(spa->spa_max_ashift, ==, spa->spa_min_ashift);
1542 1 << spa->spa_max_ashift);
1546 ASSERT3U(attempted, >, 1 << spa->spa_max_ashift);
1547 *max_alloc = attempted - (1 << spa->spa_max_ashift);
1572 spa_remove_max_segment(spa_t *spa)
1574 return (P2ROUNDUP(zfs_remove_max_segment, 1 << spa->spa_max_ashift));
1596 spa_t *spa = arg;
1597 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
1599 uint64_t max_alloc = spa_remove_max_segment(spa);
1602 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
1603 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id);
1693 spa_config_exit(spa, SCL_CONFIG, FTAG);
1712 dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir);
1722 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
1723 vd = vdev_lookup_top(spa, svr->svr_vdev_id);
1726 max_alloc = spa_remove_max_segment(spa);
1746 spa_config_exit(spa, SCL_CONFIG, FTAG);
1751 txg_wait_synced(spa->spa_dsl_pool, 0);
1776 spa_vdev_remove_cancel_impl(spa);
1780 vdev_remove_complete(spa);
1787 spa_vdev_remove_suspend(spa_t *spa)
1789 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
1813 spa_t *spa = vd->vdev_spa;
1814 objset_t *mos = spa->spa_meta_objset;
1816 mutex_enter(&spa->spa_props_lock);
1819 mutex_exit(&spa->spa_props_lock);
1828 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
1830 if (spa->spa_vdev_removal == NULL)
1843 spa_t *spa = dmu_tx_pool(tx)->dp_spa;
1844 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
1845 vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id);
1848 objset_t *mos = spa->spa_meta_objset;
1852 spa_feature_decr(spa, SPA_FEATURE_DEVICE_REMOVAL, tx);
1857 spa_feature_decr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx);
1858 VERIFY0(zap_remove(spa->spa_meta_objset, vd->vdev_top_zap,
1870 VERIFY0(zap_remove(spa->spa_meta_objset, vd->vdev_top_zap,
1874 spa_feature_decr(spa, SPA_FEATURE_OBSOLETE_COUNTS, tx);
1963 spa_finish_removal(spa, DSS_CANCELED, tx);
1968 spa_config_enter(spa, SCL_ALLOC | SCL_VDEV, FTAG, RW_WRITER);
1970 spa_config_exit(spa, SCL_ALLOC | SCL_VDEV, FTAG);
1977 spa_history_log_internal(spa, "vdev remove canceled", tx,
1978 "%s vdev %llu %s", spa_name(spa),
1984 spa_vdev_remove_cancel_impl(spa_t *spa)
1986 int error = dsl_sync_task(spa->spa_name, spa_vdev_remove_cancel_check,
1993 spa_vdev_remove_cancel(spa_t *spa)
1995 spa_vdev_remove_suspend(spa);
1997 if (spa->spa_vdev_removal == NULL)
2000 return (spa_vdev_remove_cancel_impl(spa));
2004 svr_sync(spa_t *spa, dmu_tx_t *tx)
2006 spa_vdev_removal_t *svr = spa->spa_vdev_removal;
2024 spa->spa_removing_phys.sr_copied += svr->svr_bytes_done[txgoff];
2027 spa_sync_removing_state(spa, tx);
2034 spa_t *spa = vd->vdev_spa;
2035 vdev_t *rvd = spa->spa_root_vdev;
2038 ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
2042 vd = vdev_alloc_common(spa, id, 0, &vdev_hole_ops);
2059 spa_t *spa = vd->vdev_spa;
2076 spa_vdev_config_exit(spa, NULL,
2094 error = spa_reset_logs(spa);
2096 *txg = spa_vdev_config_enter(spa);
2136 spa_vdev_config_exit(spa, NULL, *txg, 0, FTAG);
2137 *txg = spa_vdev_config_enter(spa);
2139 sysevent_t *ev = spa_event_create(spa, vd, NULL,
2142 ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
2172 spa_t *spa = vd->vdev_spa;
2180 if (!spa_feature_is_enabled(spa, SPA_FEATURE_DEVICE_REMOVAL))
2190 metaslab_class_t *normal = spa_normal_class(spa);
2209 spa->spa_dsl_pool->dp_root_dir, NULL, 0, B_TRUE);
2217 if (spa->spa_removing_phys.sr_state == DSS_SCANNING)
2236 if (spa->spa_max_ashift != spa->spa_min_ashift) {
2245 vd->vdev_ashift != spa->spa_max_ashift) {
2253 vdev_t *rvd = spa->spa_root_vdev;
2268 ASSERT3U(cvd->vdev_ashift, ==, spa->spa_max_ashift);
2300 spa_t *spa = vd->vdev_spa;
2333 spa_vdev_config_exit(spa, NULL, *txg, 0, FTAG);
2339 *txg = spa_vdev_config_enter(spa);
2350 spa_async_request(spa, SPA_ASYNC_INITIALIZE_RESTART);
2351 spa_async_request(spa, SPA_ASYNC_TRIM_RESTART);
2352 spa_async_request(spa, SPA_ASYNC_AUTOTRIM_RESTART);
2360 dmu_tx_t *tx = dmu_tx_create_assigned(spa->spa_dsl_pool, *txg);
2361 dsl_sync_task_nowait(spa->spa_dsl_pool,
2378 spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
2390 ASSERT(spa_writeable(spa));
2393 txg = spa_vdev_enter(spa);
2396 if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
2397 error = (spa_has_checkpoint(spa)) ?
2401 return (spa_vdev_exit(spa, NULL, txg, error));
2406 vd = spa_lookup_by_guid(spa, guid, B_FALSE);
2408 if (spa->spa_spares.sav_vdevs != NULL &&
2409 nvlist_lookup_nvlist_array(spa->spa_spares.sav_config,
2428 vd = spa_lookup_by_guid(spa,
2430 ev = spa_event_create(spa, vd, NULL,
2436 spa_vdev_remove_aux(spa->spa_spares.sav_config,
2438 spa_load_spares(spa);
2439 spa->spa_spares.sav_sync = B_TRUE;
2444 } else if (spa->spa_l2cache.sav_vdevs != NULL &&
2445 nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config,
2454 vd = spa_lookup_by_guid(spa, guid, B_TRUE);
2462 spa_vdev_config_exit(spa, NULL,
2467 txg = spa_vdev_config_enter(spa);
2469 ev = spa_event_create(spa, vd, NULL, ESC_ZFS_VDEV_REMOVE_AUX);
2470 spa_vdev_remove_aux(spa->spa_l2cache.sav_config,
2472 spa_load_l2cache(spa);
2473 spa->spa_l2cache.sav_sync = B_TRUE;
2493 error = spa_vdev_exit(spa, NULL, txg, error);
2496 * Logging must be done outside the spa config lock. Otherwise,
2497 * this code path could end up holding the spa config lock while
2503 spa_history_log_internal(spa, "vdev remove", NULL,
2504 "%s vdev (%s) %s", spa_name(spa), vd_type, vd_path);
2516 spa_removal_get_stats(spa_t *spa, pool_removal_stat_t *prs)
2518 prs->prs_state = spa->spa_removing_phys.sr_state;
2523 prs->prs_removing_vdev = spa->spa_removing_phys.sr_removing_vdev;
2524 prs->prs_start_time = spa->spa_removing_phys.sr_start_time;
2525 prs->prs_end_time = spa->spa_removing_phys.sr_end_time;
2526 prs->prs_to_copy = spa->spa_removing_phys.sr_to_copy;
2527 prs->prs_copied = spa->spa_removing_phys.sr_copied;
2531 spa->spa_removing_phys.sr_prev_indirect_vdev;
2533 vdev_t *vd = spa->spa_root_vdev->vdev_child[indirect_vdev_id];