spa_impl.h revision abe1fd01ce5a83718c5a840daeab4abdaec1c104
1bc1f688Robert Mustacchi/*
2bc1f688Robert Mustacchi * CDDL HEADER START
3bc1f688Robert Mustacchi *
4bc1f688Robert Mustacchi * The contents of this file are subject to the terms of the
5bc1f688Robert Mustacchi * Common Development and Distribution License (the "License").
6bc1f688Robert Mustacchi * You may not use this file except in compliance with the License.
7bc1f688Robert Mustacchi *
8bc1f688Robert Mustacchi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9bc1f688Robert Mustacchi * or http://www.opensolaris.org/os/licensing.
10bc1f688Robert Mustacchi * See the License for the specific language governing permissions
11bc1f688Robert Mustacchi * and limitations under the License.
12bc1f688Robert Mustacchi *
13bc1f688Robert Mustacchi * When distributing Covered Code, include this CDDL HEADER in each
14bc1f688Robert Mustacchi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15bc1f688Robert Mustacchi * If applicable, add the following below this CDDL HEADER, with the
16bc1f688Robert Mustacchi * fields enclosed by brackets "[]" replaced with your own identifying
17bc1f688Robert Mustacchi * information: Portions Copyright [yyyy] [name of copyright owner]
18bc1f688Robert Mustacchi *
19bc1f688Robert Mustacchi * CDDL HEADER END
20bc1f688Robert Mustacchi */
21bc1f688Robert Mustacchi/*
22bc1f688Robert Mustacchi * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23bc1f688Robert Mustacchi * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
24bc1f688Robert Mustacchi * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
25bc1f688Robert Mustacchi * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
26bc1f688Robert Mustacchi * Copyright 2013 Saso Kiselkov. All rights reserved.
27bc1f688Robert Mustacchi * Copyright (c) 2017 Datto Inc.
28bc1f688Robert Mustacchi */
29bc1f688Robert Mustacchi
30bc1f688Robert Mustacchi#ifndef _SYS_SPA_IMPL_H
31bc1f688Robert Mustacchi#define	_SYS_SPA_IMPL_H
32bc1f688Robert Mustacchi
33bc1f688Robert Mustacchi#include <sys/spa.h>
34bc1f688Robert Mustacchi#include <sys/spa_checkpoint.h>
35bc1f688Robert Mustacchi#include <sys/vdev.h>
36bc1f688Robert Mustacchi#include <sys/vdev_removal.h>
37bc1f688Robert Mustacchi#include <sys/metaslab.h>
38bc1f688Robert Mustacchi#include <sys/dmu.h>
39bc1f688Robert Mustacchi#include <sys/dsl_pool.h>
40bc1f688Robert Mustacchi#include <sys/uberblock_impl.h>
41bc1f688Robert Mustacchi#include <sys/zfs_context.h>
42bc1f688Robert Mustacchi#include <sys/avl.h>
43bc1f688Robert Mustacchi#include <sys/refcount.h>
44bc1f688Robert Mustacchi#include <sys/bplist.h>
45bc1f688Robert Mustacchi#include <sys/bpobj.h>
46bc1f688Robert Mustacchi#include <sys/zfeature.h>
47bc1f688Robert Mustacchi#include <sys/zthr.h>
48bc1f688Robert Mustacchi#include <zfeature_common.h>
49bc1f688Robert Mustacchi
50bc1f688Robert Mustacchi#ifdef	__cplusplus
51bc1f688Robert Mustacchiextern "C" {
52bc1f688Robert Mustacchi#endif
53bc1f688Robert Mustacchi
54bc1f688Robert Mustacchitypedef struct spa_error_entry {
55bc1f688Robert Mustacchi	zbookmark_phys_t	se_bookmark;
56bc1f688Robert Mustacchi	char			*se_name;
57bc1f688Robert Mustacchi	avl_node_t		se_avl;
58bc1f688Robert Mustacchi} spa_error_entry_t;
59bc1f688Robert Mustacchi
60bc1f688Robert Mustacchitypedef struct spa_history_phys {
61bc1f688Robert Mustacchi	uint64_t sh_pool_create_len;	/* ending offset of zpool create */
62bc1f688Robert Mustacchi	uint64_t sh_phys_max_off;	/* physical EOF */
63bc1f688Robert Mustacchi	uint64_t sh_bof;		/* logical BOF */
64bc1f688Robert Mustacchi	uint64_t sh_eof;		/* logical EOF */
65bc1f688Robert Mustacchi	uint64_t sh_records_lost;	/* num of records overwritten */
66bc1f688Robert Mustacchi} spa_history_phys_t;
67bc1f688Robert Mustacchi
68bc1f688Robert Mustacchi/*
69bc1f688Robert Mustacchi * All members must be uint64_t, for byteswap purposes.
70bc1f688Robert Mustacchi */
71bc1f688Robert Mustacchitypedef struct spa_removing_phys {
72bc1f688Robert Mustacchi	uint64_t sr_state; /* dsl_scan_state_t */
73bc1f688Robert Mustacchi
74bc1f688Robert Mustacchi	/*
75bc1f688Robert Mustacchi	 * The vdev ID that we most recently attempted to remove,
76bc1f688Robert Mustacchi	 * or -1 if no removal has been attempted.
77bc1f688Robert Mustacchi	 */
78bc1f688Robert Mustacchi	uint64_t sr_removing_vdev;
79bc1f688Robert Mustacchi
80bc1f688Robert Mustacchi	/*
81bc1f688Robert Mustacchi	 * The vdev ID that we most recently successfully removed,
82bc1f688Robert Mustacchi	 * or -1 if no devices have been removed.
83bc1f688Robert Mustacchi	 */
84bc1f688Robert Mustacchi	uint64_t sr_prev_indirect_vdev;
85bc1f688Robert Mustacchi
86bc1f688Robert Mustacchi	uint64_t sr_start_time;
87bc1f688Robert Mustacchi	uint64_t sr_end_time;
88bc1f688Robert Mustacchi
89bc1f688Robert Mustacchi	/*
90bc1f688Robert Mustacchi	 * Note that we can not use the space map's or indirect mapping's
91bc1f688Robert Mustacchi	 * accounting as a substitute for these values, because we need to
92bc1f688Robert Mustacchi	 * count frees of not-yet-copied data as though it did the copy.
93bc1f688Robert Mustacchi	 * Otherwise, we could get into a situation where copied > to_copy,
94bc1f688Robert Mustacchi	 * or we complete before copied == to_copy.
95bc1f688Robert Mustacchi	 */
96bc1f688Robert Mustacchi	uint64_t sr_to_copy; /* bytes that need to be copied */
97bc1f688Robert Mustacchi	uint64_t sr_copied; /* bytes that have been copied or freed */
98bc1f688Robert Mustacchi} spa_removing_phys_t;
99bc1f688Robert Mustacchi
100bc1f688Robert Mustacchi/*
101bc1f688Robert Mustacchi * This struct is stored as an entry in the DMU_POOL_DIRECTORY_OBJECT
102bc1f688Robert Mustacchi * (with key DMU_POOL_CONDENSING_INDIRECT).  It is present if a condense
103bc1f688Robert Mustacchi * of an indirect vdev's mapping object is in progress.
104bc1f688Robert Mustacchi */
105bc1f688Robert Mustacchitypedef struct spa_condensing_indirect_phys {
106bc1f688Robert Mustacchi	/*
107bc1f688Robert Mustacchi	 * The vdev ID of the indirect vdev whose indirect mapping is
108bc1f688Robert Mustacchi	 * being condensed.
109bc1f688Robert Mustacchi	 */
110bc1f688Robert Mustacchi	uint64_t	scip_vdev;
111bc1f688Robert Mustacchi
112bc1f688Robert Mustacchi	/*
113bc1f688Robert Mustacchi	 * The vdev's old obsolete spacemap.  This spacemap's contents are
114bc1f688Robert Mustacchi	 * being integrated into the new mapping.
115bc1f688Robert Mustacchi	 */
116bc1f688Robert Mustacchi	uint64_t	scip_prev_obsolete_sm_object;
117bc1f688Robert Mustacchi
118bc1f688Robert Mustacchi	/*
119bc1f688Robert Mustacchi	 * The new mapping object that is being created.
120bc1f688Robert Mustacchi	 */
121bc1f688Robert Mustacchi	uint64_t	scip_next_mapping_object;
122bc1f688Robert Mustacchi} spa_condensing_indirect_phys_t;
123bc1f688Robert Mustacchi
124bc1f688Robert Mustacchistruct spa_aux_vdev {
125bc1f688Robert Mustacchi	uint64_t	sav_object;		/* MOS object for device list */
126bc1f688Robert Mustacchi	nvlist_t	*sav_config;		/* cached device config */
127bc1f688Robert Mustacchi	vdev_t		**sav_vdevs;		/* devices */
128bc1f688Robert Mustacchi	int		sav_count;		/* number devices */
129bc1f688Robert Mustacchi	boolean_t	sav_sync;		/* sync the device list */
130bc1f688Robert Mustacchi	nvlist_t	**sav_pending;		/* pending device additions */
131bc1f688Robert Mustacchi	uint_t		sav_npending;		/* # pending devices */
132bc1f688Robert Mustacchi};
133bc1f688Robert Mustacchi
134bc1f688Robert Mustacchitypedef struct spa_config_lock {
135bc1f688Robert Mustacchi	kmutex_t	scl_lock;
136bc1f688Robert Mustacchi	kthread_t	*scl_writer;
137bc1f688Robert Mustacchi	int		scl_write_wanted;
138bc1f688Robert Mustacchi	kcondvar_t	scl_cv;
139bc1f688Robert Mustacchi	refcount_t	scl_count;
140bc1f688Robert Mustacchi} spa_config_lock_t;
141bc1f688Robert Mustacchi
142bc1f688Robert Mustacchitypedef struct spa_config_dirent {
143bc1f688Robert Mustacchi	list_node_t	scd_link;
144bc1f688Robert Mustacchi	char		*scd_path;
145bc1f688Robert Mustacchi} spa_config_dirent_t;
146bc1f688Robert Mustacchi
147bc1f688Robert Mustacchitypedef enum zio_taskq_type {
148bc1f688Robert Mustacchi	ZIO_TASKQ_ISSUE = 0,
149bc1f688Robert Mustacchi	ZIO_TASKQ_ISSUE_HIGH,
150bc1f688Robert Mustacchi	ZIO_TASKQ_INTERRUPT,
151bc1f688Robert Mustacchi	ZIO_TASKQ_INTERRUPT_HIGH,
152bc1f688Robert Mustacchi	ZIO_TASKQ_TYPES
153bc1f688Robert Mustacchi} zio_taskq_type_t;
154bc1f688Robert Mustacchi
155bc1f688Robert Mustacchi/*
156bc1f688Robert Mustacchi * State machine for the zpool-poolname process.  The states transitions
157bc1f688Robert Mustacchi * are done as follows:
158bc1f688Robert Mustacchi *
159bc1f688Robert Mustacchi *	From		   To			Routine
160bc1f688Robert Mustacchi *	PROC_NONE	-> PROC_CREATED		spa_activate()
161bc1f688Robert Mustacchi *	PROC_CREATED	-> PROC_ACTIVE		spa_thread()
162bc1f688Robert Mustacchi *	PROC_ACTIVE	-> PROC_DEACTIVATE	spa_deactivate()
163bc1f688Robert Mustacchi *	PROC_DEACTIVATE	-> PROC_GONE		spa_thread()
164bc1f688Robert Mustacchi *	PROC_GONE	-> PROC_NONE		spa_deactivate()
165bc1f688Robert Mustacchi */
166bc1f688Robert Mustacchitypedef enum spa_proc_state {
167bc1f688Robert Mustacchi	SPA_PROC_NONE,		/* spa_proc = &p0, no process created */
168bc1f688Robert Mustacchi	SPA_PROC_CREATED,	/* spa_activate() has proc, is waiting */
169bc1f688Robert Mustacchi	SPA_PROC_ACTIVE,	/* taskqs created, spa_proc set */
170bc1f688Robert Mustacchi	SPA_PROC_DEACTIVATE,	/* spa_deactivate() requests process exit */
171bc1f688Robert Mustacchi	SPA_PROC_GONE		/* spa_thread() is exiting, spa_proc = &p0 */
172bc1f688Robert Mustacchi} spa_proc_state_t;
173bc1f688Robert Mustacchi
174bc1f688Robert Mustacchitypedef struct spa_taskqs {
175bc1f688Robert Mustacchi	uint_t stqs_count;
176bc1f688Robert Mustacchi	taskq_t **stqs_taskq;
177bc1f688Robert Mustacchi} spa_taskqs_t;
178bc1f688Robert Mustacchi
179bc1f688Robert Mustacchitypedef enum spa_all_vdev_zap_action {
180bc1f688Robert Mustacchi	AVZ_ACTION_NONE = 0,
181bc1f688Robert Mustacchi	AVZ_ACTION_DESTROY,	/* Destroy all per-vdev ZAPs and the AVZ. */
182bc1f688Robert Mustacchi	AVZ_ACTION_REBUILD,	/* Populate the new AVZ, see spa_avz_rebuild */
183bc1f688Robert Mustacchi	AVZ_ACTION_INITIALIZE
184bc1f688Robert Mustacchi} spa_avz_action_t;
185bc1f688Robert Mustacchi
186bc1f688Robert Mustacchitypedef enum spa_config_source {
187bc1f688Robert Mustacchi	SPA_CONFIG_SRC_NONE = 0,
188bc1f688Robert Mustacchi	SPA_CONFIG_SRC_SCAN,		/* scan of path (default: /dev/dsk) */
189bc1f688Robert Mustacchi	SPA_CONFIG_SRC_CACHEFILE,	/* any cachefile */
190bc1f688Robert Mustacchi	SPA_CONFIG_SRC_TRYIMPORT,	/* returned from call to tryimport */
191bc1f688Robert Mustacchi	SPA_CONFIG_SRC_SPLIT,		/* new pool in a pool split */
192bc1f688Robert Mustacchi	SPA_CONFIG_SRC_MOS		/* MOS, but not always from right txg */
193bc1f688Robert Mustacchi} spa_config_source_t;
194bc1f688Robert Mustacchi
195bc1f688Robert Mustacchistruct spa {
196bc1f688Robert Mustacchi	/*
197bc1f688Robert Mustacchi	 * Fields protected by spa_namespace_lock.
198bc1f688Robert Mustacchi	 */
199bc1f688Robert Mustacchi	char		spa_name[ZFS_MAX_DATASET_NAME_LEN];	/* pool name */
200bc1f688Robert Mustacchi	char		*spa_comment;		/* comment */
201bc1f688Robert Mustacchi	avl_node_t	spa_avl;		/* node in spa_namespace_avl */
202bc1f688Robert Mustacchi	nvlist_t	*spa_config;		/* last synced config */
203bc1f688Robert Mustacchi	nvlist_t	*spa_config_syncing;	/* currently syncing config */
204bc1f688Robert Mustacchi	nvlist_t	*spa_config_splitting;	/* config for splitting */
205bc1f688Robert Mustacchi	nvlist_t	*spa_load_info;		/* info and errors from load */
206bc1f688Robert Mustacchi	uint64_t	spa_config_txg;		/* txg of last config change */
207bc1f688Robert Mustacchi	int		spa_sync_pass;		/* iterate-to-convergence */
208bc1f688Robert Mustacchi	pool_state_t	spa_state;		/* pool state */
209bc1f688Robert Mustacchi	int		spa_inject_ref;		/* injection references */
210bc1f688Robert Mustacchi	uint8_t		spa_sync_on;		/* sync threads are running */
211bc1f688Robert Mustacchi	spa_load_state_t spa_load_state;	/* current load operation */
212bc1f688Robert Mustacchi	boolean_t	spa_indirect_vdevs_loaded; /* mappings loaded? */
213bc1f688Robert Mustacchi	boolean_t	spa_trust_config;	/* do we trust vdev tree? */
214bc1f688Robert Mustacchi	spa_config_source_t spa_config_source;	/* where config comes from? */
215bc1f688Robert Mustacchi	uint64_t	spa_import_flags;	/* import specific flags */
216bc1f688Robert Mustacchi	spa_taskqs_t	spa_zio_taskq[ZIO_TYPES][ZIO_TASKQ_TYPES];
217bc1f688Robert Mustacchi	dsl_pool_t	*spa_dsl_pool;
218bc1f688Robert Mustacchi	boolean_t	spa_is_initializing;	/* true while opening pool */
219bc1f688Robert Mustacchi	metaslab_class_t *spa_normal_class;	/* normal data class */
220bc1f688Robert Mustacchi	metaslab_class_t *spa_log_class;	/* intent log data class */
221bc1f688Robert Mustacchi	uint64_t	spa_first_txg;		/* first txg after spa_open() */
222bc1f688Robert Mustacchi	uint64_t	spa_final_txg;		/* txg of export/destroy */
223bc1f688Robert Mustacchi	uint64_t	spa_freeze_txg;		/* freeze pool at this txg */
224bc1f688Robert Mustacchi	uint64_t	spa_load_max_txg;	/* best initial ub_txg */
225bc1f688Robert Mustacchi	uint64_t	spa_claim_max_txg;	/* highest claimed birth txg */
226bc1f688Robert Mustacchi	timespec_t	spa_loaded_ts;		/* 1st successful open time */
227bc1f688Robert Mustacchi	objset_t	*spa_meta_objset;	/* copy of dp->dp_meta_objset */
228bc1f688Robert Mustacchi	kmutex_t	spa_evicting_os_lock;	/* Evicting objset list lock */
229bc1f688Robert Mustacchi	list_t		spa_evicting_os_list;	/* Objsets being evicted. */
230bc1f688Robert Mustacchi	kcondvar_t	spa_evicting_os_cv;	/* Objset Eviction Completion */
231bc1f688Robert Mustacchi	txg_list_t	spa_vdev_txg_list;	/* per-txg dirty vdev list */
232bc1f688Robert Mustacchi	vdev_t		*spa_root_vdev;		/* top-level vdev container */
233bc1f688Robert Mustacchi	int		spa_min_ashift;		/* of vdevs in normal class */
234bc1f688Robert Mustacchi	int		spa_max_ashift;		/* of vdevs in normal class */
235bc1f688Robert Mustacchi	uint64_t	spa_config_guid;	/* config pool guid */
236bc1f688Robert Mustacchi	uint64_t	spa_load_guid;		/* spa_load initialized guid */
237bc1f688Robert Mustacchi	uint64_t	spa_last_synced_guid;	/* last synced guid */
238bc1f688Robert Mustacchi	list_t		spa_config_dirty_list;	/* vdevs with dirty config */
239bc1f688Robert Mustacchi	list_t		spa_state_dirty_list;	/* vdevs with dirty state */
240bc1f688Robert Mustacchi	/*
241bc1f688Robert Mustacchi	 * spa_alloc_locks and spa_alloc_trees are arrays, whose lengths are
242bc1f688Robert Mustacchi	 * stored in spa_alloc_count. There is one tree and one lock for each
243bc1f688Robert Mustacchi	 * allocator, to help improve allocation performance in write-heavy
244bc1f688Robert Mustacchi	 * workloads.
245bc1f688Robert Mustacchi	 */
246bc1f688Robert Mustacchi	kmutex_t	*spa_alloc_locks;
247bc1f688Robert Mustacchi	avl_tree_t	*spa_alloc_trees;
248bc1f688Robert Mustacchi	int		spa_alloc_count;
249bc1f688Robert Mustacchi
250bc1f688Robert Mustacchi	spa_aux_vdev_t	spa_spares;		/* hot spares */
251bc1f688Robert Mustacchi	spa_aux_vdev_t	spa_l2cache;		/* L2ARC cache devices */
252bc1f688Robert Mustacchi	nvlist_t	*spa_label_features;	/* Features for reading MOS */
253bc1f688Robert Mustacchi	uint64_t	spa_config_object;	/* MOS object for pool config */
254bc1f688Robert Mustacchi	uint64_t	spa_config_generation;	/* config generation number */
255bc1f688Robert Mustacchi	uint64_t	spa_syncing_txg;	/* txg currently syncing */
256bc1f688Robert Mustacchi	bpobj_t		spa_deferred_bpobj;	/* deferred-free bplist */
257bc1f688Robert Mustacchi	bplist_t	spa_free_bplist[TXG_SIZE]; /* bplist of stuff to free */
258bc1f688Robert Mustacchi	zio_cksum_salt_t spa_cksum_salt;	/* secret salt for cksum */
259bc1f688Robert Mustacchi	/* checksum context templates */
260bc1f688Robert Mustacchi	kmutex_t	spa_cksum_tmpls_lock;
261bc1f688Robert Mustacchi	void		*spa_cksum_tmpls[ZIO_CHECKSUM_FUNCTIONS];
262bc1f688Robert Mustacchi	uberblock_t	spa_ubsync;		/* last synced uberblock */
263bc1f688Robert Mustacchi	uberblock_t	spa_uberblock;		/* current uberblock */
264bc1f688Robert Mustacchi	boolean_t	spa_extreme_rewind;	/* rewind past deferred frees */
265bc1f688Robert Mustacchi	uint64_t	spa_last_io;		/* lbolt of last non-scan I/O */
266bc1f688Robert Mustacchi	kmutex_t	spa_scrub_lock;		/* resilver/scrub lock */
267bc1f688Robert Mustacchi	uint64_t	spa_scrub_inflight;	/* in-flight scrub I/Os */
268bc1f688Robert Mustacchi	kcondvar_t	spa_scrub_io_cv;	/* scrub I/O completion */
269bc1f688Robert Mustacchi	uint8_t		spa_scrub_active;	/* active or suspended? */
270bc1f688Robert Mustacchi	uint8_t		spa_scrub_type;		/* type of scrub we're doing */
271bc1f688Robert Mustacchi	uint8_t		spa_scrub_finished;	/* indicator to rotate logs */
272bc1f688Robert Mustacchi	uint8_t		spa_scrub_started;	/* started since last boot */
273bc1f688Robert Mustacchi	uint8_t		spa_scrub_reopen;	/* scrub doing vdev_reopen */
274bc1f688Robert Mustacchi	uint64_t	spa_scan_pass_start;	/* start time per pass/reboot */
275bc1f688Robert Mustacchi	uint64_t	spa_scan_pass_scrub_pause; /* scrub pause time */
276bc1f688Robert Mustacchi	uint64_t	spa_scan_pass_scrub_spent_paused; /* total paused */
277bc1f688Robert Mustacchi	uint64_t	spa_scan_pass_exam;	/* examined bytes per pass */
278bc1f688Robert Mustacchi	kmutex_t	spa_async_lock;		/* protect async state */
279bc1f688Robert Mustacchi	kthread_t	*spa_async_thread;	/* thread doing async task */
280bc1f688Robert Mustacchi	int		spa_async_suspended;	/* async tasks suspended */
281bc1f688Robert Mustacchi	kcondvar_t	spa_async_cv;		/* wait for thread_exit() */
282bc1f688Robert Mustacchi	uint16_t	spa_async_tasks;	/* async task mask */
283bc1f688Robert Mustacchi	uint64_t	spa_missing_tvds;	/* unopenable tvds on load */
284bc1f688Robert Mustacchi	uint64_t	spa_missing_tvds_allowed; /* allow loading spa? */
285bc1f688Robert Mustacchi
286bc1f688Robert Mustacchi	spa_removing_phys_t spa_removing_phys;
287bc1f688Robert Mustacchi	spa_vdev_removal_t *spa_vdev_removal;
288bc1f688Robert Mustacchi
289bc1f688Robert Mustacchi	spa_condensing_indirect_phys_t	spa_condensing_indirect_phys;
290bc1f688Robert Mustacchi	spa_condensing_indirect_t	*spa_condensing_indirect;
291bc1f688Robert Mustacchi	zthr_t		*spa_condense_zthr;	/* zthr doing condense. */
292bc1f688Robert Mustacchi
293bc1f688Robert Mustacchi	uint64_t	spa_checkpoint_txg;	/* the txg of the checkpoint */
294bc1f688Robert Mustacchi	spa_checkpoint_info_t spa_checkpoint_info; /* checkpoint accounting */
295bc1f688Robert Mustacchi	zthr_t		*spa_checkpoint_discard_zthr;
296bc1f688Robert Mustacchi
297bc1f688Robert Mustacchi	char		*spa_root;		/* alternate root directory */
298bc1f688Robert Mustacchi	uint64_t	spa_ena;		/* spa-wide ereport ENA */
299bc1f688Robert Mustacchi	int		spa_last_open_failed;	/* error if last open failed */
300bc1f688Robert Mustacchi	uint64_t	spa_last_ubsync_txg;	/* "best" uberblock txg */
301bc1f688Robert Mustacchi	uint64_t	spa_last_ubsync_txg_ts;	/* timestamp from that ub */
302bc1f688Robert Mustacchi	uint64_t	spa_load_txg;		/* ub txg that loaded */
303bc1f688Robert Mustacchi	uint64_t	spa_load_txg_ts;	/* timestamp from that ub */
304bc1f688Robert Mustacchi	uint64_t	spa_load_meta_errors;	/* verify metadata err count */
305bc1f688Robert Mustacchi	uint64_t	spa_load_data_errors;	/* verify data err count */
306bc1f688Robert Mustacchi	uint64_t	spa_verify_min_txg;	/* start txg of verify scrub */
307bc1f688Robert Mustacchi	kmutex_t	spa_errlog_lock;	/* error log lock */
308bc1f688Robert Mustacchi	uint64_t	spa_errlog_last;	/* last error log object */
309bc1f688Robert Mustacchi	uint64_t	spa_errlog_scrub;	/* scrub error log object */
310bc1f688Robert Mustacchi	kmutex_t	spa_errlist_lock;	/* error list/ereport lock */
311bc1f688Robert Mustacchi	avl_tree_t	spa_errlist_last;	/* last error list */
312bc1f688Robert Mustacchi	avl_tree_t	spa_errlist_scrub;	/* scrub error list */
313bc1f688Robert Mustacchi	uint64_t	spa_deflate;		/* should we deflate? */
314bc1f688Robert Mustacchi	uint64_t	spa_history;		/* history object */
315bc1f688Robert Mustacchi	kmutex_t	spa_history_lock;	/* history lock */
316bc1f688Robert Mustacchi	vdev_t		*spa_pending_vdev;	/* pending vdev additions */
317bc1f688Robert Mustacchi	kmutex_t	spa_props_lock;		/* property lock */
318bc1f688Robert Mustacchi	uint64_t	spa_pool_props_object;	/* object for properties */
319bc1f688Robert Mustacchi	uint64_t	spa_bootfs;		/* default boot filesystem */
320bc1f688Robert Mustacchi	uint64_t	spa_failmode;		/* failure mode for the pool */
321bc1f688Robert Mustacchi	uint64_t	spa_delegation;		/* delegation on/off */
322bc1f688Robert Mustacchi	list_t		spa_config_list;	/* previous cache file(s) */
323bc1f688Robert Mustacchi	/* per-CPU array of root of async I/O: */
324bc1f688Robert Mustacchi	zio_t		**spa_async_zio_root;
325bc1f688Robert Mustacchi	zio_t		*spa_suspend_zio_root;	/* root of all suspended I/O */
326bc1f688Robert Mustacchi	zio_t		*spa_txg_zio[TXG_SIZE]; /* spa_sync() waits for this */
327bc1f688Robert Mustacchi	kmutex_t	spa_suspend_lock;	/* protects suspend_zio_root */
328bc1f688Robert Mustacchi	kcondvar_t	spa_suspend_cv;		/* notification of resume */
329bc1f688Robert Mustacchi	uint8_t		spa_suspended;		/* pool is suspended */
330bc1f688Robert Mustacchi	uint8_t		spa_claiming;		/* pool is doing zil_claim() */
331bc1f688Robert Mustacchi	boolean_t	spa_is_root;		/* pool is root */
332bc1f688Robert Mustacchi	int		spa_minref;		/* num refs when first opened */
333bc1f688Robert Mustacchi	int		spa_mode;		/* FREAD | FWRITE */
334bc1f688Robert Mustacchi	spa_log_state_t spa_log_state;		/* log state */
335bc1f688Robert Mustacchi	uint64_t	spa_autoexpand;		/* lun expansion on/off */
336bc1f688Robert Mustacchi	uint64_t	spa_bootsize;		/* efi system partition size */
337bc1f688Robert Mustacchi	ddt_t		*spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */
338bc1f688Robert Mustacchi	uint64_t	spa_ddt_stat_object;	/* DDT statistics */
339bc1f688Robert Mustacchi	uint64_t	spa_dedup_ditto;	/* dedup ditto threshold */
340bc1f688Robert Mustacchi	uint64_t	spa_dedup_checksum;	/* default dedup checksum */
341bc1f688Robert Mustacchi	uint64_t	spa_dspace;		/* dspace in normal class */
342bc1f688Robert Mustacchi	kmutex_t	spa_vdev_top_lock;	/* dueling offline/remove */
343bc1f688Robert Mustacchi	kmutex_t	spa_proc_lock;		/* protects spa_proc* */
344bc1f688Robert Mustacchi	kcondvar_t	spa_proc_cv;		/* spa_proc_state transitions */
345bc1f688Robert Mustacchi	spa_proc_state_t spa_proc_state;	/* see definition */
346bc1f688Robert Mustacchi	struct proc	*spa_proc;		/* "zpool-poolname" process */
347bc1f688Robert Mustacchi	uint64_t	spa_did;		/* if procp != p0, did of t1 */
348bc1f688Robert Mustacchi	boolean_t	spa_autoreplace;	/* autoreplace set in open */
349bc1f688Robert Mustacchi	int		spa_vdev_locks;		/* locks grabbed */
350bc1f688Robert Mustacchi	uint64_t	spa_creation_version;	/* version at pool creation */
351bc1f688Robert Mustacchi	uint64_t	spa_prev_software_version; /* See ub_software_version */
352bc1f688Robert Mustacchi	uint64_t	spa_feat_for_write_obj;	/* required to write to pool */
353bc1f688Robert Mustacchi	uint64_t	spa_feat_for_read_obj;	/* required to read from pool */
354bc1f688Robert Mustacchi	uint64_t	spa_feat_desc_obj;	/* Feature descriptions */
355bc1f688Robert Mustacchi	uint64_t	spa_feat_enabled_txg_obj; /* Feature enabled txg */
356bc1f688Robert Mustacchi	/* cache feature refcounts */
357bc1f688Robert Mustacchi	uint64_t	spa_feat_refcount_cache[SPA_FEATURES];
358bc1f688Robert Mustacchi	cyclic_id_t	spa_deadman_cycid;	/* cyclic id */
359bc1f688Robert Mustacchi	uint64_t	spa_deadman_calls;	/* number of deadman calls */
360bc1f688Robert Mustacchi	hrtime_t	spa_sync_starttime;	/* starting time fo spa_sync */
361bc1f688Robert Mustacchi	uint64_t	spa_deadman_synctime;	/* deadman expiration timer */
362bc1f688Robert Mustacchi	uint64_t	spa_all_vdev_zaps;	/* ZAP of per-vd ZAP obj #s */
363bc1f688Robert Mustacchi	spa_avz_action_t	spa_avz_action;	/* destroy/rebuild AVZ? */
364bc1f688Robert Mustacchi
365bc1f688Robert Mustacchi	/*
366bc1f688Robert Mustacchi	 * spa_iokstat_lock protects spa_iokstat and
367bc1f688Robert Mustacchi	 * spa_queue_stats[].
368bc1f688Robert Mustacchi	 */
369bc1f688Robert Mustacchi	kmutex_t	spa_iokstat_lock;
370bc1f688Robert Mustacchi	struct kstat	*spa_iokstat;		/* kstat of io to this pool */
371bc1f688Robert Mustacchi	struct {
372bc1f688Robert Mustacchi		int spa_active;
373bc1f688Robert Mustacchi		int spa_queued;
374bc1f688Robert Mustacchi	} spa_queue_stats[ZIO_PRIORITY_NUM_QUEUEABLE];
375bc1f688Robert Mustacchi
376