1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * https://opensource.org/license/CDDL-1.0. 11 */ 12 /* 13 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 14 * Copyright (c) 2011, 2024 by Delphix. All rights reserved. 15 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 16 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. 17 * Copyright 2013 Saso Kiselkov. All rights reserved. 18 * Copyright (c) 2016 Actifio, Inc. All rights reserved. 19 * Copyright (c) 2017, Intel Corporation. 20 * Copyright (c) 2019 Datto Inc. 21 * Copyright (c) 2024-2026, Klara, Inc. 22 * Copyright (c) 2026, TrueNAS. 23 */ 24 25 #ifndef _SYS_SPA_IMPL_H 26 #define _SYS_SPA_IMPL_H 27 28 #include <sys/spa.h> 29 #include <sys/spa_checkpoint.h> 30 #include <sys/spa_log_spacemap.h> 31 #include <sys/vdev.h> 32 #include <sys/vdev_rebuild.h> 33 #include <sys/vdev_removal.h> 34 #include <sys/vdev_raidz.h> 35 #include <sys/metaslab.h> 36 #include <sys/dmu.h> 37 #include <sys/dsl_pool.h> 38 #include <sys/uberblock_impl.h> 39 #include <sys/zfs_context.h> 40 #include <sys/avl.h> 41 #include <sys/zfs_refcount.h> 42 #include <sys/bplist.h> 43 #include <sys/bpobj.h> 44 #include <sys/dsl_crypt.h> 45 #include <sys/zfeature.h> 46 #include <sys/zthr.h> 47 #include <sys/arc_impl.h> 48 #include <sys/dsl_deadlist.h> 49 #include <zfeature_common.h> 50 51 #include "zfs_crrd.h" 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 typedef struct spa_allocs_use { 58 kmutex_t sau_lock; 59 uint_t sau_rotor; 60 boolean_t sau_inuse[]; 61 } spa_allocs_use_t; 62 63 typedef struct spa_error_entry { 64 zbookmark_phys_t se_bookmark; 65 char *se_name; 66 avl_node_t se_avl; 67 zbookmark_err_phys_t se_zep; /* not accounted in avl_find */ 68 } spa_error_entry_t; 69 70 typedef struct spa_history_phys { 71 uint64_t sh_pool_create_len; /* ending offset of zpool create */ 72 uint64_t sh_phys_max_off; /* physical EOF */ 73 uint64_t sh_bof; /* logical BOF */ 74 uint64_t sh_eof; /* logical EOF */ 75 uint64_t sh_records_lost; /* num of records overwritten */ 76 } spa_history_phys_t; 77 78 /* 79 * All members must be uint64_t, for byteswap purposes. 80 */ 81 typedef struct spa_removing_phys { 82 uint64_t sr_state; /* dsl_scan_state_t */ 83 84 /* 85 * The vdev ID that we most recently attempted to remove, 86 * or -1 if no removal has been attempted. 87 */ 88 uint64_t sr_removing_vdev; 89 90 /* 91 * The vdev ID that we most recently successfully removed, 92 * or -1 if no devices have been removed. 93 */ 94 uint64_t sr_prev_indirect_vdev; 95 96 uint64_t sr_start_time; 97 uint64_t sr_end_time; 98 99 /* 100 * Note that we can not use the space map's or indirect mapping's 101 * accounting as a substitute for these values, because we need to 102 * count frees of not-yet-copied data as though it did the copy. 103 * Otherwise, we could get into a situation where copied > to_copy, 104 * or we complete before copied == to_copy. 105 */ 106 uint64_t sr_to_copy; /* bytes that need to be copied */ 107 uint64_t sr_copied; /* bytes that have been copied or freed */ 108 } spa_removing_phys_t; 109 110 /* 111 * This struct is stored as an entry in the DMU_POOL_DIRECTORY_OBJECT 112 * (with key DMU_POOL_CONDENSING_INDIRECT). It is present if a condense 113 * of an indirect vdev's mapping object is in progress. 114 */ 115 typedef struct spa_condensing_indirect_phys { 116 /* 117 * The vdev ID of the indirect vdev whose indirect mapping is 118 * being condensed. 119 */ 120 uint64_t scip_vdev; 121 122 /* 123 * The vdev's old obsolete spacemap. This spacemap's contents are 124 * being integrated into the new mapping. 125 */ 126 uint64_t scip_prev_obsolete_sm_object; 127 128 /* 129 * The new mapping object that is being created. 130 */ 131 uint64_t scip_next_mapping_object; 132 } spa_condensing_indirect_phys_t; 133 134 struct spa_aux_vdev { 135 uint64_t sav_object; /* MOS object for device list */ 136 nvlist_t *sav_config; /* cached device config */ 137 vdev_t **sav_vdevs; /* devices */ 138 int sav_count; /* number devices */ 139 boolean_t sav_sync; /* sync the device list */ 140 boolean_t sav_label_sync; /* sync aux labels */ 141 nvlist_t **sav_pending; /* pending device additions */ 142 uint_t sav_npending; /* # pending devices */ 143 }; 144 145 typedef struct spa_config_lock { 146 kmutex_t scl_lock; 147 kthread_t *scl_writer; 148 int scl_write_wanted; 149 int scl_count; 150 kcondvar_t scl_cv; 151 } ____cacheline_aligned spa_config_lock_t; 152 153 typedef struct spa_config_dirent { 154 list_node_t scd_link; 155 char *scd_path; 156 } spa_config_dirent_t; 157 158 typedef enum zio_taskq_type { 159 ZIO_TASKQ_ISSUE = 0, 160 ZIO_TASKQ_ISSUE_HIGH, 161 ZIO_TASKQ_INTERRUPT, 162 ZIO_TASKQ_INTERRUPT_HIGH, 163 ZIO_TASKQ_TYPES 164 } zio_taskq_type_t; 165 166 /* 167 * State machine for the zpool-poolname process. The states transitions 168 * are done as follows: 169 * 170 * From To Routine 171 * PROC_NONE -> PROC_CREATED spa_activate() 172 * PROC_CREATED -> PROC_ACTIVE spa_thread() 173 * PROC_ACTIVE -> PROC_DEACTIVATE spa_deactivate() 174 * PROC_DEACTIVATE -> PROC_GONE spa_thread() 175 * PROC_GONE -> PROC_NONE spa_deactivate() 176 */ 177 typedef enum spa_proc_state { 178 SPA_PROC_NONE, /* spa_proc = &p0, no process created */ 179 SPA_PROC_CREATED, /* spa_activate() has proc, is waiting */ 180 SPA_PROC_ACTIVE, /* taskqs created, spa_proc set */ 181 SPA_PROC_DEACTIVATE, /* spa_deactivate() requests process exit */ 182 SPA_PROC_GONE /* spa_thread() is exiting, spa_proc = &p0 */ 183 } spa_proc_state_t; 184 185 typedef struct spa_taskqs { 186 uint_t stqs_count; 187 taskq_t **stqs_taskq; 188 } spa_taskqs_t; 189 190 /* one for each thread in the spa sync taskq */ 191 typedef struct spa_syncthread_info { 192 kthread_t *sti_thread; 193 uint_t sti_allocator; 194 } spa_syncthread_info_t; 195 196 typedef enum spa_all_vdev_zap_action { 197 AVZ_ACTION_NONE = 0, 198 AVZ_ACTION_DESTROY, /* Destroy all per-vdev ZAPs and the AVZ. */ 199 AVZ_ACTION_REBUILD, /* Populate the new AVZ, see spa_avz_rebuild */ 200 AVZ_ACTION_INITIALIZE 201 } spa_avz_action_t; 202 203 typedef enum spa_config_source { 204 SPA_CONFIG_SRC_NONE = 0, 205 SPA_CONFIG_SRC_SCAN, /* scan of path (default: /dev/dsk) */ 206 SPA_CONFIG_SRC_CACHEFILE, /* any cachefile */ 207 SPA_CONFIG_SRC_TRYIMPORT, /* returned from call to tryimport */ 208 SPA_CONFIG_SRC_SPLIT, /* new pool in a pool split */ 209 SPA_CONFIG_SRC_MOS /* MOS, but not always from right txg */ 210 } spa_config_source_t; 211 212 typedef enum spa_condense_type { 213 SPA_CONDENSE_LOG_SPACEMAP = 0, 214 #ifdef ZFS_DEBUG 215 SPA_CONDENSE_DEBUG, 216 #endif 217 SPA_CONDENSE_TYPES 218 } spa_condense_type_t; 219 220 typedef struct spa_condense_stat { 221 uint64_t scns_start_time; /* time_t */ 222 uint64_t scns_end_time; /* time_t */ 223 uint64_t scns_processed; /* items processed */ 224 uint64_t scns_total; /* total items to process */ 225 } spa_condense_stat_t; 226 227 228 struct spa { 229 /* 230 * Fields protected by spa_namespace_lock. 231 */ 232 char spa_name[ZFS_MAX_DATASET_NAME_LEN]; /* pool name */ 233 char *spa_load_name; /* unmodified pool name */ 234 char *spa_comment; /* comment */ 235 avl_node_t spa_avl; /* node in spa_namespace_avl */ 236 nvlist_t *spa_config; /* last synced config */ 237 nvlist_t *spa_config_syncing; /* currently syncing config */ 238 nvlist_t *spa_config_splitting; /* config for splitting */ 239 nvlist_t *spa_load_info; /* info and errors from load */ 240 nvlist_t *spa_create_info; /* info from create */ 241 uint64_t spa_config_txg; /* txg of last config change */ 242 uint32_t spa_sync_pass; /* iterate-to-convergence */ 243 pool_state_t spa_state; /* pool state */ 244 int spa_inject_ref; /* injection references */ 245 uint8_t spa_sync_on; /* sync threads are running */ 246 spa_load_state_t spa_load_state; /* current load operation */ 247 boolean_t spa_indirect_vdevs_loaded; /* mappings loaded? */ 248 boolean_t spa_trust_config; /* do we trust vdev tree? */ 249 boolean_t spa_is_splitting; /* in the middle of a split? */ 250 spa_config_source_t spa_config_source; /* where config comes from? */ 251 uint64_t spa_import_flags; /* import specific flags */ 252 spa_taskqs_t spa_zio_taskq[ZIO_TYPES][ZIO_TASKQ_TYPES]; 253 dsl_pool_t *spa_dsl_pool; 254 boolean_t spa_is_initializing; /* true while opening pool */ 255 boolean_t spa_is_exporting; /* true while exporting pool */ 256 kthread_t *spa_export_thread; /* valid during pool export */ 257 kthread_t *spa_load_thread; /* loading, no namespace lock */ 258 metaslab_class_t *spa_normal_class; /* normal data class */ 259 metaslab_class_t *spa_log_class; /* intent log data class */ 260 metaslab_class_t *spa_embedded_log_class; /* log on normal vdevs */ 261 metaslab_class_t *spa_special_class; /* special allocation class */ 262 metaslab_class_t *spa_special_embedded_log_class; /* log on special */ 263 metaslab_class_t *spa_dedup_class; /* dedup allocation class */ 264 uint64_t spa_first_txg; /* first txg after spa_open() */ 265 uint64_t spa_final_txg; /* txg of export/destroy */ 266 uint64_t spa_freeze_txg; /* freeze pool at this txg */ 267 uint64_t spa_load_max_txg; /* best initial ub_txg */ 268 uint64_t spa_claim_max_txg; /* highest claimed birth txg */ 269 inode_timespec_t spa_loaded_ts; /* 1st successful open time */ 270 objset_t *spa_meta_objset; /* copy of dp->dp_meta_objset */ 271 kmutex_t spa_evicting_os_lock; /* Evicting objset list lock */ 272 list_t spa_evicting_os_list; /* Objsets being evicted. */ 273 kcondvar_t spa_evicting_os_cv; /* Objset Eviction Completion */ 274 txg_list_t spa_vdev_txg_list; /* per-txg dirty vdev list */ 275 vdev_t *spa_root_vdev; /* top-level vdev container */ 276 uint64_t spa_min_ashift; /* of vdevs in normal class */ 277 uint64_t spa_max_ashift; /* of vdevs in normal class */ 278 uint64_t spa_min_alloc; /* of vdevs in normal class */ 279 uint64_t spa_max_alloc; /* of vdevs in normal class */ 280 uint64_t spa_gcd_alloc; /* of vdevs in normal class */ 281 uint64_t spa_config_guid; /* config pool guid */ 282 uint64_t spa_load_guid; /* spa_load initialized guid */ 283 uint64_t spa_last_synced_guid; /* last synced guid */ 284 list_t spa_config_dirty_list; /* vdevs with dirty config */ 285 list_t spa_state_dirty_list; /* vdevs with dirty state */ 286 spa_allocs_use_t *spa_allocs_use; 287 int spa_alloc_count; 288 int spa_active_allocator; /* selectable allocator */ 289 290 /* per-allocator sync thread taskqs */ 291 taskq_t *spa_sync_tq; 292 spa_syncthread_info_t *spa_syncthreads; 293 294 spa_aux_vdev_t spa_spares; /* hot spares */ 295 spa_aux_vdev_t spa_l2cache; /* L2ARC cache devices */ 296 boolean_t spa_aux_sync_uber; /* need to sync aux uber */ 297 l2arc_info_t spa_l2arc_info; /* L2ARC state and stats */ 298 nvlist_t *spa_label_features; /* Features for reading MOS */ 299 uint64_t spa_config_object; /* MOS object for pool config */ 300 uint64_t spa_config_generation; /* config generation number */ 301 uint64_t spa_syncing_txg; /* txg currently syncing */ 302 bpobj_t spa_deferred_bpobj; /* deferred-free bplist */ 303 bplist_t spa_free_bplist[TXG_SIZE]; /* bplist of stuff to free */ 304 zio_cksum_salt_t spa_cksum_salt; /* secret salt for cksum */ 305 /* checksum context templates */ 306 kmutex_t spa_cksum_tmpls_lock; 307 void *spa_cksum_tmpls[ZIO_CHECKSUM_FUNCTIONS]; 308 uberblock_t spa_ubsync; /* last synced uberblock */ 309 uberblock_t spa_uberblock; /* current uberblock */ 310 boolean_t spa_activity_check; /* activity check required */ 311 boolean_t spa_extreme_rewind; /* rewind past deferred frees */ 312 kmutex_t spa_scrub_lock; /* resilver/scrub lock */ 313 uint64_t spa_scrub_inflight; /* in-flight scrub bytes */ 314 315 /* in-flight verification bytes */ 316 uint64_t spa_load_verify_bytes; 317 kcondvar_t spa_scrub_io_cv; /* scrub I/O completion */ 318 uint8_t spa_scrub_active; /* active or suspended? */ 319 uint8_t spa_scrub_type; /* type of scrub we're doing */ 320 uint8_t spa_scrub_finished; /* indicator to rotate logs */ 321 uint8_t spa_scrub_started; /* started since last boot */ 322 uint8_t spa_scrub_reopen; /* scrub doing vdev_reopen */ 323 uint64_t spa_scan_pass_start; /* start time per pass/reboot */ 324 uint64_t spa_scan_pass_scrub_pause; /* scrub pause time */ 325 uint64_t spa_scan_pass_scrub_spent_paused; /* total paused */ 326 uint64_t spa_scan_pass_exam; /* examined bytes per pass */ 327 uint64_t spa_scan_pass_issued; /* issued bytes per pass */ 328 uint64_t spa_scrubbed_last_txg; /* last txg scrubbed */ 329 330 /* error scrub pause time in milliseconds */ 331 uint64_t spa_scan_pass_errorscrub_pause; 332 /* total error scrub paused time in milliseconds */ 333 uint64_t spa_scan_pass_errorscrub_spent_paused; 334 /* 335 * We are in the middle of a resilver, and another resilver 336 * is needed once this one completes. This is set iff any 337 * vdev_resilver_deferred is set. 338 */ 339 boolean_t spa_resilver_deferred; 340 kmutex_t spa_async_lock; /* protect async state */ 341 kthread_t *spa_async_thread; /* thread doing async task */ 342 int spa_async_suspended; /* async tasks suspended */ 343 kcondvar_t spa_async_cv; /* wait for thread_exit() */ 344 uint16_t spa_async_tasks; /* async task mask */ 345 uint64_t spa_missing_tvds; /* unopenable tvds on load */ 346 uint64_t spa_missing_tvds_allowed; /* allow loading spa? */ 347 348 uint64_t spa_nonallocating_dspace; 349 spa_removing_phys_t spa_removing_phys; 350 spa_vdev_removal_t *spa_vdev_removal; 351 352 spa_condensing_indirect_phys_t spa_condensing_indirect_phys; 353 spa_condensing_indirect_t *spa_condensing_indirect; 354 zthr_t *spa_condense_zthr; /* zthr doing condense. */ 355 356 vdev_raidz_expand_t *spa_raidz_expand; 357 zthr_t *spa_raidz_expand_zthr; 358 359 uint64_t spa_checkpoint_txg; /* the txg of the checkpoint */ 360 spa_checkpoint_info_t spa_checkpoint_info; /* checkpoint accounting */ 361 zthr_t *spa_checkpoint_discard_zthr; 362 363 kmutex_t spa_txg_log_time_lock; /* for spa_txg_log_time */ 364 dbrrd_t spa_txg_log_time; 365 uint64_t spa_last_noted_txg; 366 uint64_t spa_last_noted_txg_time; 367 uint64_t spa_last_flush_txg_time; 368 369 space_map_t *spa_syncing_log_sm; /* current log space map */ 370 avl_tree_t spa_sm_logs_by_txg; 371 kmutex_t spa_flushed_ms_lock; /* for metaslabs_by_flushed */ 372 avl_tree_t spa_metaslabs_by_flushed; 373 spa_unflushed_stats_t spa_unflushed_stats; 374 list_t spa_log_summary; 375 spa_log_flushall_mode_t spa_log_flushall_mode; 376 uint64_t spa_log_flushall_txg; 377 378 zthr_t *spa_livelist_delete_zthr; /* deleting livelists */ 379 zthr_t *spa_livelist_condense_zthr; /* condensing livelists */ 380 uint64_t spa_livelists_to_delete; /* set of livelists to free */ 381 livelist_condense_entry_t spa_to_condense; /* next to condense */ 382 383 char *spa_root; /* alternate root directory */ 384 uint64_t spa_ena; /* spa-wide ereport ENA */ 385 int spa_last_open_failed; /* error if last open failed */ 386 uint64_t spa_last_ubsync_txg; /* "best" uberblock txg */ 387 uint64_t spa_last_ubsync_txg_ts; /* timestamp from that ub */ 388 uint64_t spa_load_txg; /* ub txg that loaded */ 389 uint64_t spa_load_txg_ts; /* timestamp from that ub */ 390 uint64_t spa_load_meta_errors; /* verify metadata err count */ 391 uint64_t spa_load_data_errors; /* verify data err count */ 392 uint64_t spa_verify_min_txg; /* start txg of verify scrub */ 393 kmutex_t spa_errlog_lock; /* error log lock */ 394 uint64_t spa_errlog_last; /* last error log object */ 395 uint64_t spa_errlog_scrub; /* scrub error log object */ 396 kmutex_t spa_errlist_lock; /* error list/ereport lock */ 397 avl_tree_t spa_errlist_last; /* last error list */ 398 avl_tree_t spa_errlist_scrub; /* scrub error list */ 399 avl_tree_t spa_errlist_healed; /* list of healed blocks */ 400 uint64_t spa_deflate; /* should we deflate? */ 401 uint64_t spa_history; /* history object */ 402 kmutex_t spa_history_lock; /* history lock */ 403 vdev_t *spa_pending_vdev; /* pending vdev additions */ 404 kmutex_t spa_props_lock; /* property lock */ 405 uint64_t spa_pool_props_object; /* object for properties */ 406 uint64_t spa_bootfs; /* default boot filesystem */ 407 uint64_t spa_failmode; /* failure mode for the pool */ 408 uint64_t spa_deadman_failmode; /* failure mode for deadman */ 409 uint64_t spa_delegation; /* delegation on/off */ 410 list_t spa_config_list; /* previous cache file(s) */ 411 /* per-CPU array of root of async I/O: */ 412 zio_t **spa_async_zio_root; 413 zio_t *spa_suspend_zio_root; /* root of all suspended I/O */ 414 zio_t *spa_txg_zio[TXG_SIZE]; /* spa_sync() waits for this */ 415 kmutex_t spa_suspend_lock; /* protects suspend_zio_root */ 416 kcondvar_t spa_suspend_cv; /* notification of resume */ 417 zio_suspend_reason_t spa_suspended; /* pool is suspended */ 418 uint8_t spa_claiming; /* pool is doing zil_claim() */ 419 boolean_t spa_is_root; /* pool is root */ 420 int spa_minref; /* num refs when first opened */ 421 spa_mode_t spa_mode; /* SPA_MODE_{READ|WRITE} */ 422 boolean_t spa_read_spacemaps; /* spacemaps available if ro */ 423 spa_log_state_t spa_log_state; /* log state */ 424 uint64_t spa_autoexpand; /* lun expansion on/off */ 425 ddt_t *spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */ 426 uint64_t spa_ddt_stat_object; /* DDT statistics */ 427 uint64_t spa_dedup_dspace; /* Cache get_dedup_dspace() */ 428 uint64_t spa_dedup_checksum; /* default dedup checksum */ 429 uint64_t spa_dspace; /* dspace in normal class */ 430 uint64_t spa_rdspace; /* raw (non-dedup) --//-- */ 431 boolean_t spa_active_ddt_prune; /* ddt prune process active */ 432 brt_vdev_t **spa_brt_vdevs; /* array of per-vdev BRTs */ 433 uint64_t spa_brt_nvdevs; /* number of vdevs in BRT */ 434 brt_dedup_shard_t *spa_brt_dedup; /* pending dedup'd clones */ 435 uint64_t spa_brt_rangesize; /* pool's BRT range size */ 436 krwlock_t spa_brt_lock; /* Protects brt_vdevs/nvdevs */ 437 kmutex_t spa_vdev_top_lock; /* dueling offline/remove */ 438 kmutex_t spa_proc_lock; /* protects spa_proc* */ 439 kcondvar_t spa_proc_cv; /* spa_proc_state transitions */ 440 spa_proc_state_t spa_proc_state; /* see definition */ 441 proc_t *spa_proc; /* "zpool-poolname" process */ 442 uintptr_t spa_did; /* if procp != p0, did of t1 */ 443 boolean_t spa_autoreplace; /* autoreplace set in open */ 444 int spa_vdev_locks; /* locks grabbed */ 445 uint64_t spa_creation_version; /* version at pool creation */ 446 uint64_t spa_prev_software_version; /* See ub_software_version */ 447 uint64_t spa_feat_for_write_obj; /* required to write to pool */ 448 uint64_t spa_feat_for_read_obj; /* required to read from pool */ 449 uint64_t spa_feat_desc_obj; /* Feature descriptions */ 450 uint64_t spa_feat_enabled_txg_obj; /* Feature enabled txg */ 451 kmutex_t spa_feat_stats_lock; /* protects spa_feat_stats */ 452 nvlist_t *spa_feat_stats; /* Cache of enabled features */ 453 /* cache feature refcounts */ 454 uint64_t spa_feat_refcount_cache[SPA_FEATURES]; 455 taskqid_t spa_deadman_tqid; /* Task id */ 456 uint64_t spa_deadman_calls; /* number of deadman calls */ 457 hrtime_t spa_sync_starttime; /* starting time of spa_sync */ 458 uint64_t spa_deadman_synctime; /* deadman sync expiration */ 459 uint64_t spa_deadman_ziotime; /* deadman zio expiration */ 460 uint64_t spa_all_vdev_zaps; /* ZAP of per-vd ZAP obj #s */ 461 spa_avz_action_t spa_avz_action; /* destroy/rebuild AVZ? */ 462 uint64_t spa_autotrim; /* automatic background trim? */ 463 uint64_t spa_errata; /* errata issues detected */ 464 spa_stats_t spa_stats; /* assorted spa statistics */ 465 spa_keystore_t spa_keystore; /* loaded crypto keys */ 466 467 /* arc_memory_throttle() parameters during low memory condition */ 468 uint64_t spa_lowmem_page_load; /* memory load during txg */ 469 uint64_t spa_lowmem_last_txg; /* txg window start */ 470 471 hrtime_t spa_ccw_fail_time; /* Conf cache write fail time */ 472 taskq_t *spa_zvol_taskq; /* Taskq for minor management */ 473 taskq_t *spa_metaslab_taskq; /* Taskq for metaslab preload */ 474 taskq_t *spa_prefetch_taskq; /* Taskq for prefetch threads */ 475 taskq_t *spa_upgrade_taskq; /* Taskq for upgrade jobs */ 476 uint64_t spa_multihost; /* multihost aware (mmp) */ 477 mmp_thread_t spa_mmp; /* multihost mmp thread */ 478 list_t spa_leaf_list; /* list of leaf vdevs */ 479 uint64_t spa_leaf_list_gen; /* track leaf_list changes */ 480 uint32_t spa_hostid; /* cached system hostid */ 481 482 /* synchronization for threads in spa_wait */ 483 kmutex_t spa_activities_lock; 484 kcondvar_t spa_activities_cv; 485 kcondvar_t spa_waiters_cv; 486 int spa_waiters; /* number of waiting threads */ 487 boolean_t spa_waiters_cancel; /* waiters should return */ 488 489 char *spa_compatibility; /* compatibility file(s) */ 490 uint64_t spa_dedup_table_quota; /* property DDT maximum size */ 491 uint64_t spa_dedup_dsize; /* cached on-disk size of DDT */ 492 uint64_t spa_dedup_class_full_txg; /* txg dedup class was full */ 493 494 /* stats for user-initiated condense operations */ 495 spa_condense_stat_t spa_condense_stats[SPA_CONDENSE_TYPES]; 496 kmutex_t spa_condense_stats_lock; 497 498 #ifdef ZFS_DEBUG 499 /* see spa_condense_debug_task() */ 500 taskqid_t spa_condense_debug_tqid; 501 #endif 502 503 /* 504 * spa_refcount & spa_config_lock must be the last elements 505 * because zfs_refcount_t changes size based on compilation options. 506 * In order for the MDB module to function correctly, the other 507 * fields must remain in the same location. 508 */ 509 spa_config_lock_t spa_config_lock[SCL_LOCKS]; /* config changes */ 510 zfs_refcount_t spa_refcount; /* number of opens */ 511 }; 512 513 extern char *spa_config_path; 514 extern const char *zfs_deadman_failmode; 515 extern uint_t spa_slop_shift; 516 extern void spa_taskq_dispatch(spa_t *spa, zio_type_t t, zio_taskq_type_t q, 517 task_func_t *func, zio_t *zio, boolean_t cutinline); 518 extern void spa_load_spares(spa_t *spa); 519 extern void spa_load_l2cache(spa_t *spa); 520 extern sysevent_t *spa_event_create(spa_t *spa, vdev_t *vd, nvlist_t *hist_nvl, 521 const char *name); 522 extern void spa_event_post(sysevent_t *ev); 523 extern int param_set_deadman_failmode_common(const char *val); 524 extern void spa_set_deadman_synctime(hrtime_t ns); 525 extern void spa_set_deadman_ziotime(hrtime_t ns); 526 extern const char *spa_history_zone(void); 527 extern const char *zfs_active_allocator; 528 extern int param_set_active_allocator_common(const char *val); 529 530 #ifdef __cplusplus 531 } 532 #endif 533 534 #endif /* _SYS_SPA_IMPL_H */ 535