Lines Matching +full:mmp +full:- +full:timer
1 // SPDX-License-Identifier: CDDL-1.0
10 * or https://opensource.org/licenses/CDDL-1.0.
80 * - Lookup a spa_t by name
81 * - Add or remove a spa_t from the namespace
82 * - Increase spa_refcount from non-zero
83 * - Check if spa_refcount is zero
84 * - Rename a spa_t
85 * - add/remove/attach/detach devices
86 * - Held for the duration of create/destroy
87 * - Held at the start and end of import and export
94 * spa_refcount (per-spa zfs_refcount_t protected by mutex)
97 * spa_t cannot be destroyed or freed while this is non-zero. Internally,
98 * the refcount is never really 'zero' - opening a pool implicitly keeps
100 * present the image of a zero/non-zero value to consumers.
102 * spa_config_lock[] (per-spa array of rwlocks)
107 * - RW_READER to perform I/O to the spa
108 * - RW_WRITER to change the vdev config
112 * spa_namespace_lock -> spa_refcount
117 * spa_refcount -> spa_config_lock[]
122 * spa_namespace_lock -> spa_config_lock[]
173 * from disk (dmu_read() -> zio_read() -> SCL_ZIO).
178 * They do, however, obey the usual write-wanted semantics to prevent
198 * Held by bp-level zios (those which have no io_vd upon entry)
199 * to prevent changes to the vdev tree. The bp-level zio implicitly
221 * an explicit vdev_t argument -- such as zio_ioctl(), zio_read_phys(),
222 * or zio_write_phys() -- the caller must ensure that the config cannot
236 * Like spa_vdev_enter/exit, these are convenience wrappers -- the actual
266 * otherwise-fatal errors, typically caused by on-disk corruption. When
278 * all remaining space to free from the error-encountering filesystem is
291 * e.g. a top-level vdev going offline), or (b) have localized,
336 * wait - Wait for the "hung" I/O (default)
337 * continue - Attempt to recover from a "hung" I/O
338 * panic - Panic the system
343 * The worst case is single-sector max-parity RAID-Z blocks, in which
357 * to the MOS). It also limits the worst-case time to allocate space. If we
379 * completely out of space, causing it to be permanently read-only.
403 * Valid values are zfs_active_allocator=<dynamic|cursor|new-dynamic>.
417 zfs_dbgmsg("spa_load(%s, config %s): FAILED: %s", spa->spa_name, in spa_load_failed()
418 spa->spa_trust_config ? "trusted" : "untrusted", buf); in spa_load_failed()
431 zfs_dbgmsg("spa_load(%s, config %s): %s", spa->spa_name, in spa_load_note()
432 spa->spa_trust_config ? "trusted" : "untrusted", buf); in spa_load_note()
445 * Once we allocate 100 - zfs_special_class_metadata_reserve_pct we only
459 spa_config_lock_t *scl = &spa->spa_config_lock[i]; in spa_config_lock_init()
460 mutex_init(&scl->scl_lock, NULL, MUTEX_DEFAULT, NULL); in spa_config_lock_init()
461 cv_init(&scl->scl_cv, NULL, CV_DEFAULT, NULL); in spa_config_lock_init()
462 scl->scl_writer = NULL; in spa_config_lock_init()
463 scl->scl_write_wanted = 0; in spa_config_lock_init()
464 scl->scl_count = 0; in spa_config_lock_init()
472 spa_config_lock_t *scl = &spa->spa_config_lock[i]; in spa_config_lock_destroy()
473 mutex_destroy(&scl->scl_lock); in spa_config_lock_destroy()
474 cv_destroy(&scl->scl_cv); in spa_config_lock_destroy()
475 ASSERT0P(scl->scl_writer); in spa_config_lock_destroy()
476 ASSERT0(scl->scl_write_wanted); in spa_config_lock_destroy()
477 ASSERT0(scl->scl_count); in spa_config_lock_destroy()
485 spa_config_lock_t *scl = &spa->spa_config_lock[i]; in spa_config_tryenter()
488 mutex_enter(&scl->scl_lock); in spa_config_tryenter()
490 if (scl->scl_writer || scl->scl_write_wanted) { in spa_config_tryenter()
491 mutex_exit(&scl->scl_lock); in spa_config_tryenter()
492 spa_config_exit(spa, locks & ((1 << i) - 1), in spa_config_tryenter()
497 ASSERT(scl->scl_writer != curthread); in spa_config_tryenter()
498 if (scl->scl_count != 0) { in spa_config_tryenter()
499 mutex_exit(&scl->scl_lock); in spa_config_tryenter()
500 spa_config_exit(spa, locks & ((1 << i) - 1), in spa_config_tryenter()
504 scl->scl_writer = curthread; in spa_config_tryenter()
506 scl->scl_count++; in spa_config_tryenter()
507 mutex_exit(&scl->scl_lock); in spa_config_tryenter()
522 spa_config_lock_t *scl = &spa->spa_config_lock[i]; in spa_config_enter_impl()
523 if (scl->scl_writer == curthread) in spa_config_enter_impl()
527 mutex_enter(&scl->scl_lock); in spa_config_enter_impl()
529 while (scl->scl_writer || in spa_config_enter_impl()
530 (!priority_flag && scl->scl_write_wanted)) { in spa_config_enter_impl()
531 cv_wait(&scl->scl_cv, &scl->scl_lock); in spa_config_enter_impl()
534 ASSERT(scl->scl_writer != curthread); in spa_config_enter_impl()
535 while (scl->scl_count != 0) { in spa_config_enter_impl()
536 scl->scl_write_wanted++; in spa_config_enter_impl()
537 cv_wait(&scl->scl_cv, &scl->scl_lock); in spa_config_enter_impl()
538 scl->scl_write_wanted--; in spa_config_enter_impl()
540 scl->scl_writer = curthread; in spa_config_enter_impl()
542 scl->scl_count++; in spa_config_enter_impl()
543 mutex_exit(&scl->scl_lock); in spa_config_enter_impl()
555 * The spa_config_enter_priority() allows the mmp thread to cut in front of
556 * outstanding write lock requests. This is needed since the mmp updates are
573 for (int i = SCL_LOCKS - 1; i >= 0; i--) { in spa_config_exit()
574 spa_config_lock_t *scl = &spa->spa_config_lock[i]; in spa_config_exit()
577 mutex_enter(&scl->scl_lock); in spa_config_exit()
578 ASSERT(scl->scl_count > 0); in spa_config_exit()
579 if (--scl->scl_count == 0) { in spa_config_exit()
580 ASSERT(scl->scl_writer == NULL || in spa_config_exit()
581 scl->scl_writer == curthread); in spa_config_exit()
582 scl->scl_writer = NULL; /* OK in either case */ in spa_config_exit()
583 cv_broadcast(&scl->scl_cv); in spa_config_exit()
585 mutex_exit(&scl->scl_lock); in spa_config_exit()
595 spa_config_lock_t *scl = &spa->spa_config_lock[i]; in spa_config_held()
598 if ((rw == RW_READER && scl->scl_count != 0) || in spa_config_held()
599 (rw == RW_WRITER && scl->scl_writer == curthread)) in spa_config_held()
697 if ((spa->spa_load_thread != NULL && in spa_lookup()
698 spa->spa_load_thread != curthread) || in spa_lookup()
699 (spa->spa_export_thread != NULL && in spa_lookup()
700 spa->spa_export_thread != curthread)) { in spa_lookup()
723 (getlrtime() - spa->spa_sync_starttime) / NANOSEC, in spa_deadman()
724 (u_longlong_t)++spa->spa_deadman_calls); in spa_deadman()
726 vdev_deadman(spa->spa_root_vdev, FTAG); in spa_deadman()
728 spa->spa_deadman_tqid = taskq_dispatch_delay(system_delay_taskq, in spa_deadman()
739 return (TREE_CMP(a->sls_txg, b->sls_txg)); in spa_log_sm_sort_by_txg()
757 mutex_init(&spa->spa_async_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
758 mutex_init(&spa->spa_errlist_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
759 mutex_init(&spa->spa_errlog_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
760 mutex_init(&spa->spa_evicting_os_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
761 mutex_init(&spa->spa_history_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
762 mutex_init(&spa->spa_proc_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
763 mutex_init(&spa->spa_props_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
764 mutex_init(&spa->spa_cksum_tmpls_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
765 mutex_init(&spa->spa_scrub_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
766 mutex_init(&spa->spa_suspend_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
767 mutex_init(&spa->spa_vdev_top_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
768 mutex_init(&spa->spa_feat_stats_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
769 mutex_init(&spa->spa_flushed_ms_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
770 mutex_init(&spa->spa_activities_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
771 mutex_init(&spa->spa_txg_log_time_lock, NULL, MUTEX_DEFAULT, NULL); in spa_add()
773 cv_init(&spa->spa_async_cv, NULL, CV_DEFAULT, NULL); in spa_add()
774 cv_init(&spa->spa_evicting_os_cv, NULL, CV_DEFAULT, NULL); in spa_add()
775 cv_init(&spa->spa_proc_cv, NULL, CV_DEFAULT, NULL); in spa_add()
776 cv_init(&spa->spa_scrub_io_cv, NULL, CV_DEFAULT, NULL); in spa_add()
777 cv_init(&spa->spa_suspend_cv, NULL, CV_DEFAULT, NULL); in spa_add()
778 cv_init(&spa->spa_activities_cv, NULL, CV_DEFAULT, NULL); in spa_add()
779 cv_init(&spa->spa_waiters_cv, NULL, CV_DEFAULT, NULL); in spa_add()
782 bplist_create(&spa->spa_free_bplist[t]); in spa_add()
784 (void) strlcpy(spa->spa_name, name, sizeof (spa->spa_name)); in spa_add()
785 spa->spa_state = POOL_STATE_UNINITIALIZED; in spa_add()
786 spa->spa_freeze_txg = UINT64_MAX; in spa_add()
787 spa->spa_final_txg = UINT64_MAX; in spa_add()
788 spa->spa_load_max_txg = UINT64_MAX; in spa_add()
789 spa->spa_proc = &p0; in spa_add()
790 spa->spa_proc_state = SPA_PROC_NONE; in spa_add()
791 spa->spa_trust_config = B_TRUE; in spa_add()
792 spa->spa_hostid = zone_get_hostid(NULL); in spa_add()
794 spa->spa_deadman_synctime = MSEC2NSEC(zfs_deadman_synctime_ms); in spa_add()
795 spa->spa_deadman_ziotime = MSEC2NSEC(zfs_deadman_ziotime_ms); in spa_add()
799 zfs_refcount_create(&spa->spa_refcount); in spa_add()
810 spa->spa_root = spa_strdup(altroot); in spa_add()
813 spa->spa_alloc_count = MAX(MIN(spa_num_allocators, in spa_add()
816 if (spa->spa_alloc_count > 1) { in spa_add()
817 spa->spa_allocs_use = kmem_zalloc(offsetof(spa_allocs_use_t, in spa_add()
818 sau_inuse[spa->spa_alloc_count]), KM_SLEEP); in spa_add()
819 mutex_init(&spa->spa_allocs_use->sau_lock, NULL, MUTEX_DEFAULT, in spa_add()
823 avl_create(&spa->spa_metaslabs_by_flushed, metaslab_sort_by_flushed, in spa_add()
825 avl_create(&spa->spa_sm_logs_by_txg, spa_log_sm_sort_by_txg, in spa_add()
827 list_create(&spa->spa_log_summary, sizeof (log_summary_entry_t), in spa_add()
833 list_create(&spa->spa_config_list, sizeof (spa_config_dirent_t), in spa_add()
837 dp->scd_path = altroot ? NULL : spa_strdup(spa_config_path); in spa_add()
838 list_insert_head(&spa->spa_config_list, dp); in spa_add()
840 VERIFY0(nvlist_alloc(&spa->spa_load_info, NV_UNIQUE_NAME, KM_SLEEP)); in spa_add()
848 &spa->spa_label_features, 0)); in spa_add()
851 VERIFY0(nvlist_dup(config, &spa->spa_config, 0)); in spa_add()
854 if (spa->spa_label_features == NULL) { in spa_add()
855 VERIFY0(nvlist_alloc(&spa->spa_label_features, NV_UNIQUE_NAME, in spa_add()
859 spa->spa_min_ashift = INT_MAX; in spa_add()
860 spa->spa_max_ashift = 0; in spa_add()
861 spa->spa_min_alloc = INT_MAX; in spa_add()
862 spa->spa_max_alloc = 0; in spa_add()
863 spa->spa_gcd_alloc = INT_MAX; in spa_add()
866 spa->spa_dedup_dspace = ~0ULL; in spa_add()
874 spa->spa_feat_refcount_cache[i] = SPA_FEATURE_DISABLED; in spa_add()
877 list_create(&spa->spa_leaf_list, sizeof (vdev_t), in spa_add()
895 ASSERT3U(zfs_refcount_count(&spa->spa_refcount), ==, 0); in spa_remove()
896 ASSERT0(spa->spa_waiters); in spa_remove()
898 nvlist_free(spa->spa_config_splitting); in spa_remove()
902 if (spa->spa_root) in spa_remove()
903 spa_strfree(spa->spa_root); in spa_remove()
905 while ((dp = list_remove_head(&spa->spa_config_list)) != NULL) { in spa_remove()
906 if (dp->scd_path != NULL) in spa_remove()
907 spa_strfree(dp->scd_path); in spa_remove()
911 if (spa->spa_alloc_count > 1) { in spa_remove()
912 mutex_destroy(&spa->spa_allocs_use->sau_lock); in spa_remove()
913 kmem_free(spa->spa_allocs_use, offsetof(spa_allocs_use_t, in spa_remove()
914 sau_inuse[spa->spa_alloc_count])); in spa_remove()
917 avl_destroy(&spa->spa_metaslabs_by_flushed); in spa_remove()
918 avl_destroy(&spa->spa_sm_logs_by_txg); in spa_remove()
919 list_destroy(&spa->spa_log_summary); in spa_remove()
920 list_destroy(&spa->spa_config_list); in spa_remove()
921 list_destroy(&spa->spa_leaf_list); in spa_remove()
923 nvlist_free(spa->spa_label_features); in spa_remove()
924 nvlist_free(spa->spa_load_info); in spa_remove()
925 nvlist_free(spa->spa_feat_stats); in spa_remove()
928 zfs_refcount_destroy(&spa->spa_refcount); in spa_remove()
934 bplist_destroy(&spa->spa_free_bplist[t]); in spa_remove()
938 cv_destroy(&spa->spa_async_cv); in spa_remove()
939 cv_destroy(&spa->spa_evicting_os_cv); in spa_remove()
940 cv_destroy(&spa->spa_proc_cv); in spa_remove()
941 cv_destroy(&spa->spa_scrub_io_cv); in spa_remove()
942 cv_destroy(&spa->spa_suspend_cv); in spa_remove()
943 cv_destroy(&spa->spa_activities_cv); in spa_remove()
944 cv_destroy(&spa->spa_waiters_cv); in spa_remove()
946 mutex_destroy(&spa->spa_flushed_ms_lock); in spa_remove()
947 mutex_destroy(&spa->spa_async_lock); in spa_remove()
948 mutex_destroy(&spa->spa_errlist_lock); in spa_remove()
949 mutex_destroy(&spa->spa_errlog_lock); in spa_remove()
950 mutex_destroy(&spa->spa_evicting_os_lock); in spa_remove()
951 mutex_destroy(&spa->spa_history_lock); in spa_remove()
952 mutex_destroy(&spa->spa_proc_lock); in spa_remove()
953 mutex_destroy(&spa->spa_props_lock); in spa_remove()
954 mutex_destroy(&spa->spa_cksum_tmpls_lock); in spa_remove()
955 mutex_destroy(&spa->spa_scrub_lock); in spa_remove()
956 mutex_destroy(&spa->spa_suspend_lock); in spa_remove()
957 mutex_destroy(&spa->spa_vdev_top_lock); in spa_remove()
958 mutex_destroy(&spa->spa_feat_stats_lock); in spa_remove()
959 mutex_destroy(&spa->spa_activities_lock); in spa_remove()
960 mutex_destroy(&spa->spa_txg_log_time_lock); in spa_remove()
993 ASSERT(zfs_refcount_count(&spa->spa_refcount) >= spa->spa_minref || in spa_open_ref()
995 spa->spa_load_thread == curthread); in spa_open_ref()
996 (void) zfs_refcount_add(&spa->spa_refcount, tag); in spa_open_ref()
1006 ASSERT(zfs_refcount_count(&spa->spa_refcount) > spa->spa_minref || in spa_close()
1008 spa->spa_load_thread == curthread || in spa_close()
1009 spa->spa_export_thread == curthread); in spa_close()
1010 (void) zfs_refcount_remove(&spa->spa_refcount, tag); in spa_close()
1024 (void) zfs_refcount_remove(&spa->spa_refcount, tag); in spa_async_close()
1037 spa->spa_export_thread == curthread); in spa_refcount_zero()
1039 return (zfs_refcount_count(&spa->spa_refcount) == spa->spa_minref); in spa_refcount_zero()
1066 return (TREE_CMP(sa->aux_guid, sb->aux_guid)); in spa_aux_compare()
1076 search.aux_guid = vd->vdev_guid; in spa_aux_add()
1078 aux->aux_count++; in spa_aux_add()
1081 aux->aux_guid = vd->vdev_guid; in spa_aux_add()
1082 aux->aux_count = 1; in spa_aux_add()
1094 search.aux_guid = vd->vdev_guid; in spa_aux_remove()
1099 if (--aux->aux_count == 0) { in spa_aux_remove()
1102 } else if (aux->aux_pool == spa_guid(vd->vdev_spa)) { in spa_aux_remove()
1103 aux->aux_pool = 0ULL; in spa_aux_remove()
1117 *pool = found->aux_pool; in spa_aux_exists()
1124 *refcnt = found->aux_count; in spa_aux_exists()
1138 search.aux_guid = vd->vdev_guid; in spa_aux_activate()
1141 ASSERT(found->aux_pool == 0ULL); in spa_aux_activate()
1143 found->aux_pool = spa_guid(vd->vdev_spa); in spa_aux_activate()
1149 * - A spare may be part of multiple pools.
1150 * - A spare may be added to a pool even if it's actively in use within
1152 * - A spare in use in any pool can only be the source of a replacement if
1178 ASSERT(!vd->vdev_isspare); in spa_spare_add()
1180 vd->vdev_isspare = B_TRUE; in spa_spare_add()
1188 ASSERT(vd->vdev_isspare); in spa_spare_remove()
1190 vd->vdev_isspare = B_FALSE; in spa_spare_remove()
1210 ASSERT(vd->vdev_isspare); in spa_spare_activate()
1231 ASSERT(!vd->vdev_isl2cache); in spa_l2cache_add()
1233 vd->vdev_isl2cache = B_TRUE; in spa_l2cache_add()
1241 ASSERT(vd->vdev_isl2cache); in spa_l2cache_remove()
1243 vd->vdev_isl2cache = B_FALSE; in spa_l2cache_remove()
1263 ASSERT(vd->vdev_isl2cache); in spa_l2cache_activate()
1282 mutex_enter(&spa->spa_vdev_top_lock); in spa_vdev_enter()
1285 ASSERT0(spa->spa_export_thread); in spa_vdev_enter()
1301 mutex_enter(&spa->spa_vdev_top_lock); in spa_vdev_detach_enter()
1304 ASSERT0(spa->spa_export_thread); in spa_vdev_detach_enter()
1311 vdev_rebuild_stop_wait(vd->vdev_top); in spa_vdev_detach_enter()
1347 spa->spa_pending_vdev = NULL; in spa_vdev_config_exit()
1352 vdev_dtl_reassess(spa->spa_root_vdev, 0, 0, B_FALSE, B_FALSE); in spa_vdev_config_exit()
1354 if (error == 0 && !list_is_empty(&spa->spa_config_dirty_list)) { in spa_vdev_config_exit()
1356 spa->spa_config_generation++; in spa_vdev_config_exit()
1385 txg_wait_synced(spa->spa_dsl_pool, txg); in spa_vdev_config_exit()
1388 ASSERT(!vd->vdev_detached || vd->vdev_dtl_sm == NULL); in spa_vdev_config_exit()
1389 if (vd->vdev_ops->vdev_op_leaf) { in spa_vdev_config_exit()
1390 mutex_enter(&vd->vdev_initialize_lock); in spa_vdev_config_exit()
1393 mutex_exit(&vd->vdev_initialize_lock); in spa_vdev_config_exit()
1395 mutex_enter(&vd->vdev_trim_lock); in spa_vdev_config_exit()
1397 mutex_exit(&vd->vdev_trim_lock); in spa_vdev_config_exit()
1401 * The vdev may be both a leaf and top-level device. in spa_vdev_config_exit()
1431 mutex_exit(&spa->spa_vdev_top_lock); in spa_vdev_exit()
1454 int low = locks & ~(SCL_ZIO - 1); in spa_vdev_state_enter()
1458 vdev_hold(spa->spa_root_vdev); in spa_vdev_state_enter()
1463 spa->spa_vdev_locks = locks; in spa_vdev_state_enter()
1472 if (vd == NULL || vd == spa->spa_root_vdev) { in spa_vdev_state_exit()
1473 vdev_top = spa->spa_root_vdev; in spa_vdev_state_exit()
1475 vdev_top = vd->vdev_top; in spa_vdev_state_exit()
1482 if (vd != spa->spa_root_vdev) in spa_vdev_state_exit()
1486 spa->spa_config_generation++; in spa_vdev_state_exit()
1490 vdev_rele(spa->spa_root_vdev); in spa_vdev_state_exit()
1492 ASSERT3U(spa->spa_vdev_locks, >=, SCL_STATE_ALL); in spa_vdev_state_exit()
1493 spa_config_exit(spa, spa->spa_vdev_locks, spa); in spa_vdev_state_exit()
1502 txg_wait_synced(spa->spa_dsl_pool, 0); in spa_vdev_state_exit()
1525 if (!nvlist_exists(spa->spa_label_features, feature)) { in spa_activate_mos_feature()
1526 fnvlist_add_boolean(spa->spa_label_features, feature); in spa_activate_mos_feature()
1534 if (tx->tx_txg != TXG_INITIAL) in spa_activate_mos_feature()
1535 vdev_config_dirty(spa->spa_root_vdev); in spa_activate_mos_feature()
1542 if (nvlist_remove_all(spa->spa_label_features, feature) == 0) in spa_deactivate_mos_feature()
1543 vdev_config_dirty(spa->spa_root_vdev); in spa_deactivate_mos_feature()
1548 * device_guid is non-zero, determine whether the pool exists *and* contains
1560 if (spa->spa_state == POOL_STATE_UNINITIALIZED) in spa_by_guid()
1562 if (spa->spa_root_vdev == NULL) in spa_by_guid()
1568 if (vdev_lookup_by_guid(spa->spa_root_vdev, in spa_by_guid()
1575 if (spa->spa_pending_vdev) { in spa_by_guid()
1576 if (vdev_lookup_by_guid(spa->spa_pending_vdev, in spa_by_guid()
1698 if (spa->spa_freeze_txg == UINT64_MAX) { in spa_freeze()
1700 spa->spa_freeze_txg = freeze_txg; in spa_freeze()
1718 * This is a stripped-down version of strtoull, suitable only for converting
1730 digit = c - '0'; in zfs_strtonum()
1732 digit = 10 + c - 'a'; in zfs_strtonum()
1767 return (spa->spa_async_suspended); in spa_shutting_down()
1773 return (spa->spa_dsl_pool); in spa_get_dsl()
1779 return (spa->spa_is_initializing); in spa_is_initializing()
1785 return (spa->spa_indirect_vdevs_loaded); in spa_indirect_vdevs_loaded()
1791 return (&spa->spa_ubsync.ub_rootbp); in spa_get_rootblkptr()
1797 spa->spa_uberblock.ub_rootbp = *bp; in spa_set_rootblkptr()
1803 if (spa->spa_root == NULL) in spa_altroot()
1806 (void) strlcpy(buf, spa->spa_root, buflen); in spa_altroot()
1812 return (spa->spa_sync_pass); in spa_sync_pass()
1818 return (spa->spa_name); in spa_name()
1833 if (spa->spa_root_vdev == NULL) in spa_guid()
1834 return (spa->spa_config_guid); in spa_guid()
1836 guid = spa->spa_last_synced_guid != 0 ? in spa_guid()
1837 spa->spa_last_synced_guid : spa->spa_root_vdev->vdev_guid; in spa_guid()
1844 return (spa->spa_root_vdev->vdev_guid); in spa_guid()
1857 return (spa->spa_load_guid); in spa_load_guid()
1863 return (spa->spa_ubsync.ub_txg); in spa_last_synced_txg()
1869 return (spa->spa_first_txg); in spa_first_txg()
1875 return (spa->spa_syncing_txg); in spa_syncing_txg()
1885 return (spa->spa_final_txg - TXG_DEFER_SIZE); in spa_final_dirty_txg()
1891 return (spa->spa_state); in spa_state()
1897 return (spa->spa_load_state); in spa_load_state()
1903 return (spa->spa_freeze_txg); in spa_freeze_txg()
1918 return (MAX(lsize, 1 << spa->spa_max_ashift) * spa_asize_inflation); in spa_get_worst_case_asize()
1930 *min_alloc = spa->spa_min_alloc; in spa_get_min_alloc_range()
1931 *max_alloc = spa->spa_max_alloc; in spa_get_min_alloc_range()
1941 * default spa_slop_shift=5 and a non-tiny pool).
1954 if (spa->spa_dedup_dspace == ~0ULL) in spa_get_slop_space()
1957 space = spa->spa_rdspace; in spa_get_slop_space()
1970 slop -= MIN(embedded_log, slop >> 1); in spa_get_slop_space()
1983 return (spa->spa_dspace); in spa_get_dspace()
1989 return (spa->spa_checkpoint_info.sci_dspace); in spa_get_checkpoint_space()
1995 spa->spa_rdspace = metaslab_class_get_dspace(spa_normal_class(spa)); in spa_update_dspace()
1996 if (spa->spa_nonallocating_dspace > 0) { in spa_update_dspace()
1998 * Subtract the space provided by all non-allocating vdevs that in spa_update_dspace()
2003 * non-allocating vdev, but the new blocks must be allocated on in spa_update_dspace()
2005 * the non-allocating vdevs (including allocated space), we in spa_update_dspace()
2015 ASSERT3U(spa->spa_rdspace, >=, spa->spa_nonallocating_dspace); in spa_update_dspace()
2016 spa->spa_rdspace -= spa->spa_nonallocating_dspace; in spa_update_dspace()
2018 spa->spa_dspace = spa->spa_rdspace + ddt_get_dedup_dspace(spa) + in spa_update_dspace()
2029 return (spa->spa_failmode); in spa_get_failmode()
2035 return (spa->spa_suspended != ZIO_SUSPEND_NONE); in spa_suspended()
2041 return (spa->spa_ubsync.ub_version); in spa_version()
2047 return (spa->spa_deflate); in spa_deflate()
2053 return (spa->spa_normal_class); in spa_normal_class()
2059 return (spa->spa_log_class); in spa_log_class()
2065 return (spa->spa_embedded_log_class); in spa_embedded_log_class()
2071 return (spa->spa_special_class); in spa_special_class()
2077 return (spa->spa_special_embedded_log_class); in spa_special_embedded_log_class()
2083 return (spa->spa_dedup_class); in spa_dedup_class()
2098 metaslab_class_t *mc = zio->io_metaslab_class; in spa_preferred_class()
2101 const zio_prop_t *zp = &zio->io_prop; in spa_preferred_class()
2110 zp->zp_storage_type == DMU_OT_NONE ? in spa_preferred_class()
2111 zp->zp_type : zp->zp_storage_type; in spa_preferred_class()
2128 if (zp->zp_level > 0 && in spa_preferred_class()
2137 if (DMU_OT_IS_METADATA(objtype) || zp->zp_level > 0) { in spa_preferred_class()
2151 zio->io_size <= zp->zp_zpl_smallblk) { in spa_preferred_class()
2156 (space * (100 - zfs_special_class_metadata_reserve_pct)) in spa_preferred_class()
2169 mutex_enter(&spa->spa_evicting_os_lock); in spa_evicting_os_register()
2170 list_insert_head(&spa->spa_evicting_os_list, os); in spa_evicting_os_register()
2171 mutex_exit(&spa->spa_evicting_os_lock); in spa_evicting_os_register()
2177 mutex_enter(&spa->spa_evicting_os_lock); in spa_evicting_os_deregister()
2178 list_remove(&spa->spa_evicting_os_list, os); in spa_evicting_os_deregister()
2179 cv_broadcast(&spa->spa_evicting_os_cv); in spa_evicting_os_deregister()
2180 mutex_exit(&spa->spa_evicting_os_lock); in spa_evicting_os_deregister()
2186 mutex_enter(&spa->spa_evicting_os_lock); in spa_evicting_os_wait()
2187 while (!list_is_empty(&spa->spa_evicting_os_list)) in spa_evicting_os_wait()
2188 cv_wait(&spa->spa_evicting_os_cv, &spa->spa_evicting_os_lock); in spa_evicting_os_wait()
2189 mutex_exit(&spa->spa_evicting_os_lock); in spa_evicting_os_wait()
2210 return (spa->spa_prev_software_version); in spa_prev_software_version()
2216 return (spa->spa_deadman_synctime); in spa_deadman_synctime()
2222 return (spa->spa_autotrim); in spa_get_autotrim()
2228 return (spa->spa_deadman_ziotime); in spa_deadman_ziotime()
2234 return (spa->spa_deadman_failmode); in spa_get_deadman_failmode()
2241 spa->spa_deadman_failmode = ZIO_FAILURE_MODE_WAIT; in spa_set_deadman_failmode()
2243 spa->spa_deadman_failmode = ZIO_FAILURE_MODE_CONTINUE; in spa_set_deadman_failmode()
2245 spa->spa_deadman_failmode = ZIO_FAILURE_MODE_PANIC; in spa_set_deadman_failmode()
2247 spa->spa_deadman_failmode = ZIO_FAILURE_MODE_WAIT; in spa_set_deadman_failmode()
2258 spa->spa_deadman_ziotime = ns; in spa_set_deadman_ziotime()
2271 spa->spa_deadman_synctime = ns; in spa_set_deadman_synctime()
2284 if (asize != 0 && spa->spa_deflate) { in dva_get_dsize_sync()
2288 vd->vdev_deflate_ratio; in dva_get_dsize_sync()
2300 dsize += dva_get_dsize_sync(spa, &bp->blk_dva[d]); in bp_get_dsize_sync()
2313 dsize += dva_get_dsize_sync(spa, &bp->blk_dva[d]); in bp_get_dsize()
2323 return (spa->spa_dsl_pool->dp_dirty_total); in spa_dirty_data()
2337 uint64_t mmp_sec_remaining; /* MMP activity check */
2347 seq_printf(f, "%-20s %-14s %-14s %-12s %-16s %s\n", "pool_guid", in spa_import_progress_show_header()
2358 seq_printf(f, "%-20llu %-14llu %-14llu %-12llu %-16s %s\n", in spa_import_progress_show()
2359 (u_longlong_t)sip->pool_guid, (u_longlong_t)sip->spa_load_state, in spa_import_progress_show()
2360 (u_longlong_t)sip->mmp_sec_remaining, in spa_import_progress_show()
2361 (u_longlong_t)sip->spa_load_max_txg, in spa_import_progress_show()
2362 (sip->pool_name ? sip->pool_name : "-"), in spa_import_progress_show()
2363 (sip->spa_load_notes ? sip->spa_load_notes : "-")); in spa_import_progress_show()
2373 while (shl->size > size) { in spa_import_progress_truncate()
2374 sip = list_remove_head(&shl->procfs_list.pl_list); in spa_import_progress_truncate()
2375 if (sip->pool_name) in spa_import_progress_truncate()
2376 spa_strfree(sip->pool_name); in spa_import_progress_truncate()
2377 if (sip->spa_load_notes) in spa_import_progress_truncate()
2378 kmem_strfree(sip->spa_load_notes); in spa_import_progress_truncate()
2380 shl->size--; in spa_import_progress_truncate()
2383 IMPLY(size == 0, list_is_empty(&shl->procfs_list.pl_list)); in spa_import_progress_truncate()
2392 spa_import_progress_list->size = 0; in spa_import_progress_init()
2394 spa_import_progress_list->procfs_list.pl_private = in spa_import_progress_init()
2401 &spa_import_progress_list->procfs_list, in spa_import_progress_init()
2412 procfs_list_uninstall(&shl->procfs_list); in spa_import_progress_destroy()
2414 procfs_list_destroy(&shl->procfs_list); in spa_import_progress_destroy()
2426 if (shl->size == 0) in spa_import_progress_set_state()
2429 mutex_enter(&shl->procfs_list.pl_lock); in spa_import_progress_set_state()
2430 for (sip = list_tail(&shl->procfs_list.pl_list); sip != NULL; in spa_import_progress_set_state()
2431 sip = list_prev(&shl->procfs_list.pl_list, sip)) { in spa_import_progress_set_state()
2432 if (sip->pool_guid == pool_guid) { in spa_import_progress_set_state()
2433 sip->spa_load_state = load_state; in spa_import_progress_set_state()
2434 if (sip->spa_load_notes != NULL) { in spa_import_progress_set_state()
2435 kmem_strfree(sip->spa_load_notes); in spa_import_progress_set_state()
2436 sip->spa_load_notes = NULL; in spa_import_progress_set_state()
2442 mutex_exit(&shl->procfs_list.pl_lock); in spa_import_progress_set_state()
2455 if (shl->size == 0) in spa_import_progress_set_notes_impl()
2460 mutex_enter(&shl->procfs_list.pl_lock); in spa_import_progress_set_notes_impl()
2461 for (sip = list_tail(&shl->procfs_list.pl_list); sip != NULL; in spa_import_progress_set_notes_impl()
2462 sip = list_prev(&shl->procfs_list.pl_list, sip)) { in spa_import_progress_set_notes_impl()
2463 if (sip->pool_guid == pool_guid) { in spa_import_progress_set_notes_impl()
2464 if (sip->spa_load_notes != NULL) { in spa_import_progress_set_notes_impl()
2465 kmem_strfree(sip->spa_load_notes); in spa_import_progress_set_notes_impl()
2466 sip->spa_load_notes = NULL; in spa_import_progress_set_notes_impl()
2468 sip->spa_load_notes = notes; in spa_import_progress_set_notes_impl()
2470 zfs_dbgmsg("'%s' %s", sip->pool_name, notes); in spa_import_progress_set_notes_impl()
2475 mutex_exit(&shl->procfs_list.pl_lock); in spa_import_progress_set_notes_impl()
2507 if (shl->size == 0) in spa_import_progress_set_max_txg()
2510 mutex_enter(&shl->procfs_list.pl_lock); in spa_import_progress_set_max_txg()
2511 for (sip = list_tail(&shl->procfs_list.pl_list); sip != NULL; in spa_import_progress_set_max_txg()
2512 sip = list_prev(&shl->procfs_list.pl_list, sip)) { in spa_import_progress_set_max_txg()
2513 if (sip->pool_guid == pool_guid) { in spa_import_progress_set_max_txg()
2514 sip->spa_load_max_txg = load_max_txg; in spa_import_progress_set_max_txg()
2519 mutex_exit(&shl->procfs_list.pl_lock); in spa_import_progress_set_max_txg()
2532 if (shl->size == 0) in spa_import_progress_set_mmp_check()
2535 mutex_enter(&shl->procfs_list.pl_lock); in spa_import_progress_set_mmp_check()
2536 for (sip = list_tail(&shl->procfs_list.pl_list); sip != NULL; in spa_import_progress_set_mmp_check()
2537 sip = list_prev(&shl->procfs_list.pl_list, sip)) { in spa_import_progress_set_mmp_check()
2538 if (sip->pool_guid == pool_guid) { in spa_import_progress_set_mmp_check()
2539 sip->mmp_sec_remaining = mmp_sec_remaining; in spa_import_progress_set_mmp_check()
2544 mutex_exit(&shl->procfs_list.pl_lock); in spa_import_progress_set_mmp_check()
2560 sip->pool_guid = spa_guid(spa); in spa_import_progress_add()
2562 (void) nvlist_lookup_string(spa->spa_config, ZPOOL_CONFIG_POOL_NAME, in spa_import_progress_add()
2566 sip->pool_name = spa_strdup(poolname); in spa_import_progress_add()
2567 sip->spa_load_state = spa_load_state(spa); in spa_import_progress_add()
2568 sip->spa_load_notes = NULL; in spa_import_progress_add()
2570 mutex_enter(&shl->procfs_list.pl_lock); in spa_import_progress_add()
2571 procfs_list_add(&shl->procfs_list, sip); in spa_import_progress_add()
2572 shl->size++; in spa_import_progress_add()
2573 mutex_exit(&shl->procfs_list.pl_lock); in spa_import_progress_add()
2582 mutex_enter(&shl->procfs_list.pl_lock); in spa_import_progress_remove()
2583 for (sip = list_tail(&shl->procfs_list.pl_list); sip != NULL; in spa_import_progress_remove()
2584 sip = list_prev(&shl->procfs_list.pl_list, sip)) { in spa_import_progress_remove()
2585 if (sip->pool_guid == pool_guid) { in spa_import_progress_remove()
2586 if (sip->pool_name) in spa_import_progress_remove()
2587 spa_strfree(sip->pool_name); in spa_import_progress_remove()
2588 if (sip->spa_load_notes) in spa_import_progress_remove()
2589 spa_strfree(sip->spa_load_notes); in spa_import_progress_remove()
2590 list_remove(&shl->procfs_list.pl_list, sip); in spa_import_progress_remove()
2591 shl->size--; in spa_import_progress_remove()
2596 mutex_exit(&shl->procfs_list.pl_lock); in spa_import_progress_remove()
2612 s = strcmp(s1->spa_name, s2->spa_name); in spa_name_compare()
2644 if (sigaction(SIGSEGV, &sa, NULL) == -1) { in spa_init()
2717 return (spa->spa_dedup_class->mc_groups != 0); in spa_has_dedup()
2728 return (spa->spa_log_class->mc_groups != 0); in spa_has_slogs()
2734 return (spa->spa_special_class->mc_groups != 0); in spa_has_special()
2740 return (spa->spa_log_state); in spa_get_log_state()
2746 spa->spa_log_state = state; in spa_set_log_state()
2752 return (spa->spa_is_root); in spa_is_root()
2758 return (!!(spa->spa_mode & SPA_MODE_WRITE) && spa->spa_trust_config); in spa_writeable()
2768 return (!txg_all_lists_empty(&spa->spa_dsl_pool->dp_sync_tasks) || in spa_has_pending_synctask()
2769 !txg_all_lists_empty(&spa->spa_dsl_pool->dp_early_sync_tasks)); in spa_has_pending_synctask()
2775 return (spa->spa_mode); in spa_mode()
2781 return (spa->spa_scrubbed_last_txg); in spa_get_last_scrubbed_txg()
2787 return (spa->spa_bootfs); in spa_bootfs()
2793 return (spa->spa_delegation); in spa_delegation()
2799 return (spa->spa_meta_objset); in spa_meta_objset()
2805 return (spa->spa_dedup_checksum); in spa_dedup_checksum()
2815 spa->spa_scan_pass_start = gethrestime_sec(); in spa_scan_stat_init()
2816 if (dsl_scan_is_paused_scrub(spa->spa_dsl_pool->dp_scan)) in spa_scan_stat_init()
2817 spa->spa_scan_pass_scrub_pause = spa->spa_scan_pass_start; in spa_scan_stat_init()
2819 spa->spa_scan_pass_scrub_pause = 0; in spa_scan_stat_init()
2821 if (dsl_errorscrub_is_paused(spa->spa_dsl_pool->dp_scan)) in spa_scan_stat_init()
2822 spa->spa_scan_pass_errorscrub_pause = spa->spa_scan_pass_start; in spa_scan_stat_init()
2824 spa->spa_scan_pass_errorscrub_pause = 0; in spa_scan_stat_init()
2826 spa->spa_scan_pass_scrub_spent_paused = 0; in spa_scan_stat_init()
2827 spa->spa_scan_pass_exam = 0; in spa_scan_stat_init()
2828 spa->spa_scan_pass_issued = 0; in spa_scan_stat_init()
2831 spa->spa_scan_pass_errorscrub_spent_paused = 0; in spa_scan_stat_init()
2840 dsl_scan_t *scn = spa->spa_dsl_pool ? spa->spa_dsl_pool->dp_scan : NULL; in spa_scan_get_stats()
2842 if (scn == NULL || (scn->scn_phys.scn_func == POOL_SCAN_NONE && in spa_scan_get_stats()
2843 scn->errorscrub_phys.dep_func == POOL_SCAN_NONE)) in spa_scan_get_stats()
2849 ps->pss_func = scn->scn_phys.scn_func; in spa_scan_get_stats()
2850 ps->pss_state = scn->scn_phys.scn_state; in spa_scan_get_stats()
2851 ps->pss_start_time = scn->scn_phys.scn_start_time; in spa_scan_get_stats()
2852 ps->pss_end_time = scn->scn_phys.scn_end_time; in spa_scan_get_stats()
2853 ps->pss_to_examine = scn->scn_phys.scn_to_examine; in spa_scan_get_stats()
2854 ps->pss_examined = scn->scn_phys.scn_examined; in spa_scan_get_stats()
2855 ps->pss_skipped = scn->scn_phys.scn_skipped; in spa_scan_get_stats()
2856 ps->pss_processed = scn->scn_phys.scn_processed; in spa_scan_get_stats()
2857 ps->pss_errors = scn->scn_phys.scn_errors; in spa_scan_get_stats()
2860 ps->pss_pass_exam = spa->spa_scan_pass_exam; in spa_scan_get_stats()
2861 ps->pss_pass_start = spa->spa_scan_pass_start; in spa_scan_get_stats()
2862 ps->pss_pass_scrub_pause = spa->spa_scan_pass_scrub_pause; in spa_scan_get_stats()
2863 ps->pss_pass_scrub_spent_paused = spa->spa_scan_pass_scrub_spent_paused; in spa_scan_get_stats()
2864 ps->pss_pass_issued = spa->spa_scan_pass_issued; in spa_scan_get_stats()
2865 ps->pss_issued = in spa_scan_get_stats()
2866 scn->scn_issued_before_pass + spa->spa_scan_pass_issued; in spa_scan_get_stats()
2869 ps->pss_error_scrub_func = scn->errorscrub_phys.dep_func; in spa_scan_get_stats()
2870 ps->pss_error_scrub_state = scn->errorscrub_phys.dep_state; in spa_scan_get_stats()
2871 ps->pss_error_scrub_start = scn->errorscrub_phys.dep_start_time; in spa_scan_get_stats()
2872 ps->pss_error_scrub_end = scn->errorscrub_phys.dep_end_time; in spa_scan_get_stats()
2873 ps->pss_error_scrub_examined = scn->errorscrub_phys.dep_examined; in spa_scan_get_stats()
2874 ps->pss_error_scrub_to_be_examined = in spa_scan_get_stats()
2875 scn->errorscrub_phys.dep_to_examine; in spa_scan_get_stats()
2878 ps->pss_pass_error_scrub_pause = spa->spa_scan_pass_errorscrub_pause; in spa_scan_get_stats()
2901 uint64_t ret = -1ULL; in spa_get_last_removal_txg()
2909 vdevid = spa->spa_removing_phys.sr_prev_indirect_vdev; in spa_get_last_removal_txg()
2911 while (vdevid != -1ULL) { in spa_get_last_removal_txg()
2913 vdev_indirect_births_t *vib = vd->vdev_indirect_births; in spa_get_last_removal_txg()
2915 ASSERT3P(vd->vdev_ops, ==, &vdev_indirect_ops); in spa_get_last_removal_txg()
2925 vdevid = vd->vdev_indirect_config.vic_prev_indirect_vdev; in spa_get_last_removal_txg()
2929 IMPLY(ret != -1ULL, in spa_get_last_removal_txg()
2947 return (spa->spa_multihost ? B_TRUE : B_FALSE); in spa_multihost()
2953 return (spa->spa_hostid); in spa_get_hostid()
2959 return (spa->spa_trust_config); in spa_trust_config()
2965 return (spa->spa_missing_tvds_allowed); in spa_missing_tvds_allowed()
2971 return (spa->spa_syncing_log_sm); in spa_syncing_log_sm()
2977 spa->spa_missing_tvds = missing; in spa_set_missing_tvds()
2992 vdev_t *rvd = spa->spa_root_vdev; in spa_state_to_name()
2996 vdev_state_t state = rvd->vdev_state; in spa_state_to_name()
2997 vdev_aux_t aux = rvd->vdev_stat.vs_aux; in spa_state_to_name()
3031 vdev_t *rvd = spa->spa_root_vdev; in spa_top_vdevs_spacemap_addressable()
3032 for (uint64_t c = 0; c < rvd->vdev_children; c++) { in spa_top_vdevs_spacemap_addressable()
3033 if (!vdev_is_spacemap_addressable(rvd->vdev_child[c])) in spa_top_vdevs_spacemap_addressable()
3042 return (spa->spa_checkpoint_txg != 0); in spa_has_checkpoint()
3048 return ((spa->spa_import_flags & ZFS_IMPORT_CHECKPOINT) && in spa_importing_readonly_checkpoint()
3049 spa->spa_mode == SPA_MODE_READ); in spa_importing_readonly_checkpoint()
3055 uint64_t checkpoint_txg = spa->spa_uberblock.ub_checkpoint_txg; in spa_min_claim_txg()
3060 return (spa->spa_first_txg); in spa_min_claim_txg()
3076 uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes; in spa_suspend_async_destroy()
3077 uint64_t avail = (unreserved > used) ? (unreserved - used) : 0; in spa_suspend_async_destroy()
3214 "Enable deadman timer");
3227 "Failmode for deadman timer");