xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/vdev_impl.h (revision 0713e232b7712cd27d99e1e935ebb8d5de61c57d)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5441d80aaSlling  * Common Development and Distribution License (the "License").
6441d80aaSlling  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
2298d1cbfeSGeorge Wilson  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23b4952e17SGeorge Wilson  * Copyright (c) 2013 by Delphix. All rights reserved.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef _SYS_VDEV_IMPL_H
27fa9e4066Sahrens #define	_SYS_VDEV_IMPL_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #include <sys/avl.h>
30fa9e4066Sahrens #include <sys/dmu.h>
31fa9e4066Sahrens #include <sys/metaslab.h>
32fa9e4066Sahrens #include <sys/nvpair.h>
33fa9e4066Sahrens #include <sys/space_map.h>
34fa9e4066Sahrens #include <sys/vdev.h>
35fa9e4066Sahrens #include <sys/dkio.h>
36fa9e4066Sahrens #include <sys/uberblock_impl.h>
37fa9e4066Sahrens 
38fa9e4066Sahrens #ifdef	__cplusplus
39fa9e4066Sahrens extern "C" {
40fa9e4066Sahrens #endif
41fa9e4066Sahrens 
42fa9e4066Sahrens /*
43fa9e4066Sahrens  * Virtual device descriptors.
44fa9e4066Sahrens  *
45fa9e4066Sahrens  * All storage pool operations go through the virtual device framework,
46fa9e4066Sahrens  * which provides data replication and I/O scheduling.
47fa9e4066Sahrens  */
48fa9e4066Sahrens 
49fa9e4066Sahrens /*
50fa9e4066Sahrens  * Forward declarations that lots of things need.
51fa9e4066Sahrens  */
52fa9e4066Sahrens typedef struct vdev_queue vdev_queue_t;
53fa9e4066Sahrens typedef struct vdev_cache vdev_cache_t;
54fa9e4066Sahrens typedef struct vdev_cache_entry vdev_cache_entry_t;
55fa9e4066Sahrens 
56fa9e4066Sahrens /*
57fa9e4066Sahrens  * Virtual device operations
58fa9e4066Sahrens  */
594263d13fSGeorge Wilson typedef int	vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size,
604263d13fSGeorge Wilson     uint64_t *ashift);
61fa9e4066Sahrens typedef void	vdev_close_func_t(vdev_t *vd);
62fa9e4066Sahrens typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize);
63e05725b1Sbonwick typedef int	vdev_io_start_func_t(zio_t *zio);
64e14bb325SJeff Bonwick typedef void	vdev_io_done_func_t(zio_t *zio);
65fa9e4066Sahrens typedef void	vdev_state_change_func_t(vdev_t *vd, int, int);
66dcba9f3fSGeorge Wilson typedef void	vdev_hold_func_t(vdev_t *vd);
67dcba9f3fSGeorge Wilson typedef void	vdev_rele_func_t(vdev_t *vd);
68fa9e4066Sahrens 
69fa9e4066Sahrens typedef struct vdev_ops {
70fa9e4066Sahrens 	vdev_open_func_t		*vdev_op_open;
71fa9e4066Sahrens 	vdev_close_func_t		*vdev_op_close;
72fa9e4066Sahrens 	vdev_asize_func_t		*vdev_op_asize;
73fa9e4066Sahrens 	vdev_io_start_func_t		*vdev_op_io_start;
74fa9e4066Sahrens 	vdev_io_done_func_t		*vdev_op_io_done;
75fa9e4066Sahrens 	vdev_state_change_func_t	*vdev_op_state_change;
76dcba9f3fSGeorge Wilson 	vdev_hold_func_t		*vdev_op_hold;
77dcba9f3fSGeorge Wilson 	vdev_rele_func_t		*vdev_op_rele;
78fa9e4066Sahrens 	char				vdev_op_type[16];
79fa9e4066Sahrens 	boolean_t			vdev_op_leaf;
80fa9e4066Sahrens } vdev_ops_t;
81fa9e4066Sahrens 
82fa9e4066Sahrens /*
83fa9e4066Sahrens  * Virtual device properties
84fa9e4066Sahrens  */
85fa9e4066Sahrens struct vdev_cache_entry {
86fa9e4066Sahrens 	char		*ve_data;
87fa9e4066Sahrens 	uint64_t	ve_offset;
88fa9e4066Sahrens 	uint64_t	ve_lastused;
89fa9e4066Sahrens 	avl_node_t	ve_offset_node;
90fa9e4066Sahrens 	avl_node_t	ve_lastused_node;
91fa9e4066Sahrens 	uint32_t	ve_hits;
92fa9e4066Sahrens 	uint16_t	ve_missed_update;
93fa9e4066Sahrens 	zio_t		*ve_fill_io;
94fa9e4066Sahrens };
95fa9e4066Sahrens 
96fa9e4066Sahrens struct vdev_cache {
97fa9e4066Sahrens 	avl_tree_t	vc_offset_tree;
98fa9e4066Sahrens 	avl_tree_t	vc_lastused_tree;
99fa9e4066Sahrens 	kmutex_t	vc_lock;
100fa9e4066Sahrens };
101fa9e4066Sahrens 
10269962b56SMatthew Ahrens typedef struct vdev_queue_class {
10369962b56SMatthew Ahrens 	uint32_t	vqc_active;
10469962b56SMatthew Ahrens 
10569962b56SMatthew Ahrens 	/*
10669962b56SMatthew Ahrens 	 * Sorted by offset or timestamp, depending on if the queue is
10769962b56SMatthew Ahrens 	 * LBA-ordered vs FIFO.
10869962b56SMatthew Ahrens 	 */
10969962b56SMatthew Ahrens 	avl_tree_t	vqc_queued_tree;
11069962b56SMatthew Ahrens } vdev_queue_class_t;
11169962b56SMatthew Ahrens 
112fa9e4066Sahrens struct vdev_queue {
11369962b56SMatthew Ahrens 	vdev_t		*vq_vdev;
11469962b56SMatthew Ahrens 	vdev_queue_class_t vq_class[ZIO_PRIORITY_NUM_QUEUEABLE];
11569962b56SMatthew Ahrens 	avl_tree_t	vq_active_tree;
11669962b56SMatthew Ahrens 	uint64_t	vq_last_offset;
11769962b56SMatthew Ahrens 	hrtime_t	vq_io_complete_ts; /* time last i/o completed */
118fa9e4066Sahrens 	kmutex_t	vq_lock;
119fa9e4066Sahrens };
120fa9e4066Sahrens 
121fa9e4066Sahrens /*
122fa9e4066Sahrens  * Virtual device descriptor
123fa9e4066Sahrens  */
124fa9e4066Sahrens struct vdev {
125fa9e4066Sahrens 	/*
126fa9e4066Sahrens 	 * Common to all vdev types.
127fa9e4066Sahrens 	 */
128fa9e4066Sahrens 	uint64_t	vdev_id;	/* child number in vdev parent	*/
129fa9e4066Sahrens 	uint64_t	vdev_guid;	/* unique ID for this vdev	*/
130fa9e4066Sahrens 	uint64_t	vdev_guid_sum;	/* self guid + all child guids	*/
1311195e687SMark J Musante 	uint64_t	vdev_orig_guid;	/* orig. guid prior to remove	*/
132fa9e4066Sahrens 	uint64_t	vdev_asize;	/* allocatable device capacity	*/
133573ca77eSGeorge Wilson 	uint64_t	vdev_min_asize;	/* min acceptable asize		*/
1344263d13fSGeorge Wilson 	uint64_t	vdev_max_asize;	/* max acceptable asize		*/
135fa9e4066Sahrens 	uint64_t	vdev_ashift;	/* block alignment shift	*/
136fa9e4066Sahrens 	uint64_t	vdev_state;	/* see VDEV_STATE_* #defines	*/
137560e6e96Seschrock 	uint64_t	vdev_prevstate;	/* used when reopening a vdev	*/
138fa9e4066Sahrens 	vdev_ops_t	*vdev_ops;	/* vdev operations		*/
139fa9e4066Sahrens 	spa_t		*vdev_spa;	/* spa for this vdev		*/
140fa9e4066Sahrens 	void		*vdev_tsd;	/* type-specific data		*/
141dcba9f3fSGeorge Wilson 	vnode_t		*vdev_name_vp;	/* vnode for pathname		*/
142dcba9f3fSGeorge Wilson 	vnode_t		*vdev_devid_vp;	/* vnode for devid		*/
143fa9e4066Sahrens 	vdev_t		*vdev_top;	/* top-level vdev		*/
144fa9e4066Sahrens 	vdev_t		*vdev_parent;	/* parent vdev			*/
145fa9e4066Sahrens 	vdev_t		**vdev_child;	/* array of children		*/
146fa9e4066Sahrens 	uint64_t	vdev_children;	/* number of children		*/
147fa9e4066Sahrens 	vdev_stat_t	vdev_stat;	/* virtual device statistics	*/
148573ca77eSGeorge Wilson 	boolean_t	vdev_expanding;	/* expand the vdev?		*/
149095bcd66SGeorge Wilson 	boolean_t	vdev_reopening;	/* reopen in progress?		*/
150f64c0e34SEric Taylor 	int		vdev_open_error; /* error on last open		*/
151f64c0e34SEric Taylor 	kthread_t	*vdev_open_thread; /* thread opening children	*/
15288ecc943SGeorge Wilson 	uint64_t	vdev_crtxg;	/* txg when top-level was added */
153fa9e4066Sahrens 
154fa9e4066Sahrens 	/*
155fa9e4066Sahrens 	 * Top-level vdev state.
156fa9e4066Sahrens 	 */
157fa9e4066Sahrens 	uint64_t	vdev_ms_array;	/* metaslab array object	*/
158fa9e4066Sahrens 	uint64_t	vdev_ms_shift;	/* metaslab size shift		*/
159fa9e4066Sahrens 	uint64_t	vdev_ms_count;	/* number of metaslabs		*/
160fa9e4066Sahrens 	metaslab_group_t *vdev_mg;	/* metaslab group		*/
161fa9e4066Sahrens 	metaslab_t	**vdev_ms;	/* metaslab array		*/
162fa9e4066Sahrens 	txg_list_t	vdev_ms_list;	/* per-txg dirty metaslab lists	*/
163fa9e4066Sahrens 	txg_list_t	vdev_dtl_list;	/* per-txg dirty DTL lists	*/
164fa9e4066Sahrens 	txg_node_t	vdev_txg_node;	/* per-txg dirty vdev linkage	*/
1653d7072f8Seschrock 	boolean_t	vdev_remove_wanted; /* async remove wanted?	*/
166e14bb325SJeff Bonwick 	boolean_t	vdev_probe_wanted; /* async probe wanted?	*/
167e14bb325SJeff Bonwick 	list_node_t	vdev_config_dirty_node; /* config dirty list	*/
168e14bb325SJeff Bonwick 	list_node_t	vdev_state_dirty_node; /* state dirty list	*/
16999653d4eSeschrock 	uint64_t	vdev_deflate_ratio; /* deflation ratio (x512)	*/
1708654d025Sperrin 	uint64_t	vdev_islog;	/* is an intent log device	*/
171*0713e232SGeorge Wilson 	uint64_t	vdev_removing;	/* device is being removed?	*/
172*0713e232SGeorge Wilson 	boolean_t	vdev_ishole;	/* is a hole in the namespace 	*/
173fa9e4066Sahrens 
174fa9e4066Sahrens 	/*
175fa9e4066Sahrens 	 * Leaf vdev state.
176fa9e4066Sahrens 	 */
177*0713e232SGeorge Wilson 	range_tree_t	*vdev_dtl[DTL_TYPES]; /* dirty time logs	*/
178*0713e232SGeorge Wilson 	space_map_t	*vdev_dtl_sm;	/* dirty time log space map	*/
179fa9e4066Sahrens 	txg_node_t	vdev_dtl_node;	/* per-txg dirty DTL linkage	*/
180*0713e232SGeorge Wilson 	uint64_t	vdev_dtl_object; /* DTL object			*/
181*0713e232SGeorge Wilson 	uint64_t	vdev_psize;	/* physical device capacity	*/
182afefbcddSeschrock 	uint64_t	vdev_wholedisk;	/* true if this is a whole disk */
1833d7072f8Seschrock 	uint64_t	vdev_offline;	/* persistent offline state	*/
1843d7072f8Seschrock 	uint64_t	vdev_faulted;	/* persistent faulted state	*/
1853d7072f8Seschrock 	uint64_t	vdev_degraded;	/* persistent degraded state	*/
1863d7072f8Seschrock 	uint64_t	vdev_removed;	/* persistent removed state	*/
187b4952e17SGeorge Wilson 	uint64_t	vdev_resilver_txg; /* persistent resilvering state */
18899653d4eSeschrock 	uint64_t	vdev_nparity;	/* number of parity devices for raidz */
189fa9e4066Sahrens 	char		*vdev_path;	/* vdev path (if any)		*/
190fa9e4066Sahrens 	char		*vdev_devid;	/* vdev devid (if any)		*/
1913d7072f8Seschrock 	char		*vdev_physpath;	/* vdev device path (if any)	*/
1926809eb4eSEric Schrock 	char		*vdev_fru;	/* physical FRU location	*/
193e14bb325SJeff Bonwick 	uint64_t	vdev_not_present; /* not present during import	*/
194e14bb325SJeff Bonwick 	uint64_t	vdev_unspare;	/* unspare when resilvering done */
195e14bb325SJeff Bonwick 	boolean_t	vdev_nowritecache; /* true if flushwritecache failed */
196e14bb325SJeff Bonwick 	boolean_t	vdev_checkremove; /* temporary online test	*/
197e14bb325SJeff Bonwick 	boolean_t	vdev_forcefault; /* force online fault		*/
1981195e687SMark J Musante 	boolean_t	vdev_splitting;	/* split or repair in progress  */
19998d1cbfeSGeorge Wilson 	boolean_t	vdev_delayed_close; /* delayed device close?	*/
200*0713e232SGeorge Wilson 	boolean_t	vdev_tmpoffline; /* device taken offline temporarily? */
201*0713e232SGeorge Wilson 	boolean_t	vdev_detached;	/* device detached?		*/
202*0713e232SGeorge Wilson 	boolean_t	vdev_cant_read;	/* vdev is failing all reads	*/
203*0713e232SGeorge Wilson 	boolean_t	vdev_cant_write; /* vdev is failing all writes	*/
204*0713e232SGeorge Wilson 	boolean_t	vdev_isspare;	/* was a hot spare		*/
205*0713e232SGeorge Wilson 	boolean_t	vdev_isl2cache;	/* was a l2cache device		*/
206fa9e4066Sahrens 	vdev_queue_t	vdev_queue;	/* I/O deadline schedule queue	*/
207fa9e4066Sahrens 	vdev_cache_t	vdev_cache;	/* physical block cache		*/
208c5904d13Seschrock 	spa_aux_vdev_t	*vdev_aux;	/* for l2cache vdevs		*/
209e14bb325SJeff Bonwick 	zio_t		*vdev_probe_zio; /* root of current probe	*/
210069f55e2SEric Schrock 	vdev_aux_t	vdev_label_aux;	/* on-disk aux state		*/
211fa9e4066Sahrens 
212fa9e4066Sahrens 	/*
213fa9e4066Sahrens 	 * For DTrace to work in userland (libzpool) context, these fields must
214fa9e4066Sahrens 	 * remain at the end of the structure.  DTrace will use the kernel's
215fa9e4066Sahrens 	 * CTF definition for 'struct vdev', and since the size of a kmutex_t is
216ad135b5dSChristopher Siden 	 * larger in userland, the offsets for the rest of the fields would be
217fa9e4066Sahrens 	 * incorrect.
218fa9e4066Sahrens 	 */
219fa9e4066Sahrens 	kmutex_t	vdev_dtl_lock;	/* vdev_dtl_{map,resilver}	*/
220fa9e4066Sahrens 	kmutex_t	vdev_stat_lock;	/* vdev_stat			*/
221e14bb325SJeff Bonwick 	kmutex_t	vdev_probe_lock; /* protects vdev_probe_zio	*/
222fa9e4066Sahrens };
223fa9e4066Sahrens 
224b24ab676SJeff Bonwick #define	VDEV_RAIDZ_MAXPARITY	3
225b24ab676SJeff Bonwick 
226f83ffe1aSLin Ling #define	VDEV_PAD_SIZE		(8 << 10)
227f83ffe1aSLin Ling /* 2 padding areas (vl_pad1 and vl_pad2) to skip */
228f83ffe1aSLin Ling #define	VDEV_SKIP_SIZE		VDEV_PAD_SIZE * 2
229fa9e4066Sahrens #define	VDEV_PHYS_SIZE		(112 << 10)
230ecc2d604Sbonwick #define	VDEV_UBERBLOCK_RING	(128 << 10)
231ecc2d604Sbonwick 
232ecc2d604Sbonwick #define	VDEV_UBERBLOCK_SHIFT(vd)	\
233ecc2d604Sbonwick 	MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT)
234ecc2d604Sbonwick #define	VDEV_UBERBLOCK_COUNT(vd)	\
235ecc2d604Sbonwick 	(VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd))
236ecc2d604Sbonwick #define	VDEV_UBERBLOCK_OFFSET(vd, n)	\
237ecc2d604Sbonwick 	offsetof(vdev_label_t, vl_uberblock[(n) << VDEV_UBERBLOCK_SHIFT(vd)])
238ecc2d604Sbonwick #define	VDEV_UBERBLOCK_SIZE(vd)		(1ULL << VDEV_UBERBLOCK_SHIFT(vd))
239fa9e4066Sahrens 
240fa9e4066Sahrens typedef struct vdev_phys {
2416e1f5caaSNeil Perrin 	char		vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_eck_t)];
2426e1f5caaSNeil Perrin 	zio_eck_t	vp_zbt;
243fa9e4066Sahrens } vdev_phys_t;
244fa9e4066Sahrens 
245fa9e4066Sahrens typedef struct vdev_label {
246f83ffe1aSLin Ling 	char		vl_pad1[VDEV_PAD_SIZE];			/*  8K */
247f83ffe1aSLin Ling 	char		vl_pad2[VDEV_PAD_SIZE];			/*  8K */
248ecc2d604Sbonwick 	vdev_phys_t	vl_vdev_phys;				/* 112K	*/
249ecc2d604Sbonwick 	char		vl_uberblock[VDEV_UBERBLOCK_RING];	/* 128K	*/
250fa9e4066Sahrens } vdev_label_t;							/* 256K total */
251fa9e4066Sahrens 
252ecc2d604Sbonwick /*
253ecc2d604Sbonwick  * vdev_dirty() flags
254ecc2d604Sbonwick  */
255ecc2d604Sbonwick #define	VDD_METASLAB	0x01
256ecc2d604Sbonwick #define	VDD_DTL		0x02
257ecc2d604Sbonwick 
258f7170741SWill Andrews /* Offset of embedded boot loader region on each label */
259f7170741SWill Andrews #define	VDEV_BOOT_OFFSET	(2 * sizeof (vdev_label_t))
260fa9e4066Sahrens /*
261f7170741SWill Andrews  * Size of embedded boot loader region on each label.
262fa9e4066Sahrens  * The total size of the first two labels plus the boot area is 4MB.
263fa9e4066Sahrens  */
264f7170741SWill Andrews #define	VDEV_BOOT_SIZE		(7ULL << 19)			/* 3.5M */
265fa9e4066Sahrens 
266fa9e4066Sahrens /*
267fa9e4066Sahrens  * Size of label regions at the start and end of each leaf device.
268fa9e4066Sahrens  */
269fa9e4066Sahrens #define	VDEV_LABEL_START_SIZE	(2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)
270fa9e4066Sahrens #define	VDEV_LABEL_END_SIZE	(2 * sizeof (vdev_label_t))
271fa9e4066Sahrens #define	VDEV_LABELS		4
272ad135b5dSChristopher Siden #define	VDEV_BEST_LABEL		VDEV_LABELS
273fa9e4066Sahrens 
274fa9e4066Sahrens #define	VDEV_ALLOC_LOAD		0
275fa9e4066Sahrens #define	VDEV_ALLOC_ADD		1
27699653d4eSeschrock #define	VDEV_ALLOC_SPARE	2
277fa94a07fSbrendan #define	VDEV_ALLOC_L2CACHE	3
27821ecdf64SLin Ling #define	VDEV_ALLOC_ROOTPOOL	4
2791195e687SMark J Musante #define	VDEV_ALLOC_SPLIT	5
280cd0837ccSGeorge Wilson #define	VDEV_ALLOC_ATTACH	6
281fa9e4066Sahrens 
282fa9e4066Sahrens /*
283fa9e4066Sahrens  * Allocate or free a vdev
284fa9e4066Sahrens  */
28588ecc943SGeorge Wilson extern vdev_t *vdev_alloc_common(spa_t *spa, uint_t id, uint64_t guid,
28688ecc943SGeorge Wilson     vdev_ops_t *ops);
28799653d4eSeschrock extern int vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *config,
28899653d4eSeschrock     vdev_t *parent, uint_t id, int alloctype);
289fa9e4066Sahrens extern void vdev_free(vdev_t *vd);
290fa9e4066Sahrens 
291fa9e4066Sahrens /*
292fa9e4066Sahrens  * Add or remove children and parents
293fa9e4066Sahrens  */
294fa9e4066Sahrens extern void vdev_add_child(vdev_t *pvd, vdev_t *cvd);
295fa9e4066Sahrens extern void vdev_remove_child(vdev_t *pvd, vdev_t *cvd);
296fa9e4066Sahrens extern void vdev_compact_children(vdev_t *pvd);
297fa9e4066Sahrens extern vdev_t *vdev_add_parent(vdev_t *cvd, vdev_ops_t *ops);
298fa9e4066Sahrens extern void vdev_remove_parent(vdev_t *cvd);
299fa9e4066Sahrens 
300fa9e4066Sahrens /*
301fa9e4066Sahrens  * vdev sync load and sync
302fa9e4066Sahrens  */
30388ecc943SGeorge Wilson extern void vdev_load_log_state(vdev_t *nvd, vdev_t *ovd);
3044b964adaSGeorge Wilson extern boolean_t vdev_log_state_valid(vdev_t *vd);
305560e6e96Seschrock extern void vdev_load(vdev_t *vd);
306*0713e232SGeorge Wilson extern int vdev_dtl_load(vdev_t *vd);
307fa9e4066Sahrens extern void vdev_sync(vdev_t *vd, uint64_t txg);
308fa9e4066Sahrens extern void vdev_sync_done(vdev_t *vd, uint64_t txg);
309ecc2d604Sbonwick extern void vdev_dirty(vdev_t *vd, int flags, void *arg, uint64_t txg);
310*0713e232SGeorge Wilson extern void vdev_dirty_leaves(vdev_t *vd, int flags, uint64_t txg);
311fa9e4066Sahrens 
312fa9e4066Sahrens /*
313fa9e4066Sahrens  * Available vdev types.
314fa9e4066Sahrens  */
315fa9e4066Sahrens extern vdev_ops_t vdev_root_ops;
316fa9e4066Sahrens extern vdev_ops_t vdev_mirror_ops;
317fa9e4066Sahrens extern vdev_ops_t vdev_replacing_ops;
318fa9e4066Sahrens extern vdev_ops_t vdev_raidz_ops;
319fa9e4066Sahrens extern vdev_ops_t vdev_disk_ops;
320fa9e4066Sahrens extern vdev_ops_t vdev_file_ops;
321fa9e4066Sahrens extern vdev_ops_t vdev_missing_ops;
32288ecc943SGeorge Wilson extern vdev_ops_t vdev_hole_ops;
32399653d4eSeschrock extern vdev_ops_t vdev_spare_ops;
324fa9e4066Sahrens 
325fa9e4066Sahrens /*
3262a79c5feSlling  * Common size functions
327fa9e4066Sahrens  */
328fa9e4066Sahrens extern uint64_t vdev_default_asize(vdev_t *vd, uint64_t psize);
329573ca77eSGeorge Wilson extern uint64_t vdev_get_min_asize(vdev_t *vd);
330573ca77eSGeorge Wilson extern void vdev_set_min_asize(vdev_t *vd);
331fa9e4066Sahrens 
332e81c57b1Sahrens /*
333f7170741SWill Andrews  * Global variables
334e81c57b1Sahrens  */
335f7170741SWill Andrews /* zdb uses this tunable, so it must be declared here to make lint happy. */
336e81c57b1Sahrens extern int zfs_vdev_cache_size;
337e81c57b1Sahrens 
33831d7e8faSGeorge Wilson /*
33931d7e8faSGeorge Wilson  * The vdev_buf_t is used to translate between zio_t and buf_t, and back again.
34031d7e8faSGeorge Wilson  */
34131d7e8faSGeorge Wilson typedef struct vdev_buf {
34231d7e8faSGeorge Wilson 	buf_t	vb_buf;		/* buffer that describes the io */
34331d7e8faSGeorge Wilson 	zio_t	*vb_io;		/* pointer back to the original zio_t */
34431d7e8faSGeorge Wilson } vdev_buf_t;
34531d7e8faSGeorge Wilson 
346fa9e4066Sahrens #ifdef	__cplusplus
347fa9e4066Sahrens }
348fa9e4066Sahrens #endif
349fa9e4066Sahrens 
350fa9e4066Sahrens #endif	/* _SYS_VDEV_IMPL_H */
351