xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zio.h (revision c9431fa1e59a88c2f0abf611f25b97af964449e5)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * 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  */
21*c9431fa1Sahl 
22fa9e4066Sahrens /*
23b3995adbSahrens  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24fa9e4066Sahrens  * Use is subject to license terms.
25fa9e4066Sahrens  */
26fa9e4066Sahrens 
27fa9e4066Sahrens #ifndef _ZIO_H
28fa9e4066Sahrens #define	_ZIO_H
29fa9e4066Sahrens 
30fa9e4066Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
31fa9e4066Sahrens 
32fa9e4066Sahrens #include <sys/zfs_context.h>
33fa9e4066Sahrens #include <sys/spa.h>
34fa9e4066Sahrens #include <sys/txg.h>
35fa9e4066Sahrens #include <sys/avl.h>
36fa9e4066Sahrens #include <sys/dkio.h>
37fa9e4066Sahrens #include <sys/fs/zfs.h>
3844cd46caSbillm #include <sys/zio_impl.h>
39fa9e4066Sahrens 
40fa9e4066Sahrens #ifdef	__cplusplus
41fa9e4066Sahrens extern "C" {
42fa9e4066Sahrens #endif
43fa9e4066Sahrens 
44fa9e4066Sahrens #define	ZBT_MAGIC	0x210da7ab10c7a11ULL	/* zio data bloc tail */
45fa9e4066Sahrens 
46fa9e4066Sahrens typedef struct zio_block_tail {
47fa9e4066Sahrens 	uint64_t	zbt_magic;	/* for validation, endianness	*/
48fa9e4066Sahrens 	zio_cksum_t	zbt_cksum;	/* 256-bit checksum		*/
49fa9e4066Sahrens } zio_block_tail_t;
50fa9e4066Sahrens 
51fa9e4066Sahrens /*
52fa9e4066Sahrens  * Gang block headers are self-checksumming and contain an array
53fa9e4066Sahrens  * of block pointers.
54fa9e4066Sahrens  */
55fa9e4066Sahrens #define	SPA_GANGBLOCKSIZE	SPA_MINBLOCKSIZE
56fa9e4066Sahrens #define	SPA_GBH_NBLKPTRS	((SPA_GANGBLOCKSIZE - \
57fa9e4066Sahrens 	sizeof (zio_block_tail_t)) / sizeof (blkptr_t))
58fa9e4066Sahrens #define	SPA_GBH_FILLER		((SPA_GANGBLOCKSIZE - \
59fa9e4066Sahrens 	sizeof (zio_block_tail_t) - \
60fa9e4066Sahrens 	(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
61fa9e4066Sahrens 	sizeof (uint64_t))
62fa9e4066Sahrens 
63fa9e4066Sahrens #define	ZIO_GET_IOSIZE(zio)	\
6444cd46caSbillm 	(BP_IS_GANG((zio)->io_bp) ? \
65fa9e4066Sahrens 	SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
66fa9e4066Sahrens 
67fa9e4066Sahrens typedef struct zio_gbh {
68fa9e4066Sahrens 	blkptr_t		zg_blkptr[SPA_GBH_NBLKPTRS];
69fa9e4066Sahrens 	uint64_t		zg_filler[SPA_GBH_FILLER];
70fa9e4066Sahrens 	zio_block_tail_t	zg_tail;
71fa9e4066Sahrens } zio_gbh_phys_t;
72fa9e4066Sahrens 
73fa9e4066Sahrens enum zio_checksum {
74fa9e4066Sahrens 	ZIO_CHECKSUM_INHERIT = 0,
75fa9e4066Sahrens 	ZIO_CHECKSUM_ON,
76fa9e4066Sahrens 	ZIO_CHECKSUM_OFF,
77fa9e4066Sahrens 	ZIO_CHECKSUM_LABEL,
78fa9e4066Sahrens 	ZIO_CHECKSUM_GANG_HEADER,
79fa9e4066Sahrens 	ZIO_CHECKSUM_ZILOG,
80fa9e4066Sahrens 	ZIO_CHECKSUM_FLETCHER_2,
81fa9e4066Sahrens 	ZIO_CHECKSUM_FLETCHER_4,
82fa9e4066Sahrens 	ZIO_CHECKSUM_SHA256,
83fa9e4066Sahrens 	ZIO_CHECKSUM_FUNCTIONS
84fa9e4066Sahrens };
85fa9e4066Sahrens 
86fa9e4066Sahrens #define	ZIO_CHECKSUM_ON_VALUE	ZIO_CHECKSUM_FLETCHER_2
87fa9e4066Sahrens #define	ZIO_CHECKSUM_DEFAULT	ZIO_CHECKSUM_ON
88fa9e4066Sahrens 
89fa9e4066Sahrens enum zio_compress {
90fa9e4066Sahrens 	ZIO_COMPRESS_INHERIT = 0,
91fa9e4066Sahrens 	ZIO_COMPRESS_ON,
92fa9e4066Sahrens 	ZIO_COMPRESS_OFF,
93fa9e4066Sahrens 	ZIO_COMPRESS_LZJB,
94416e0cd8Sek 	ZIO_COMPRESS_EMPTY,
95*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_1,
96*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_2,
97*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_3,
98*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_4,
99*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_5,
100*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_6,
101*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_7,
102*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_8,
103*c9431fa1Sahl 	ZIO_COMPRESS_GZIP_9,
104fa9e4066Sahrens 	ZIO_COMPRESS_FUNCTIONS
105fa9e4066Sahrens };
106fa9e4066Sahrens 
107fa9e4066Sahrens #define	ZIO_COMPRESS_ON_VALUE	ZIO_COMPRESS_LZJB
108fa9e4066Sahrens #define	ZIO_COMPRESS_DEFAULT	ZIO_COMPRESS_OFF
109fa9e4066Sahrens 
110fa9e4066Sahrens #define	ZIO_PRIORITY_NOW		(zio_priority_table[0])
111fa9e4066Sahrens #define	ZIO_PRIORITY_SYNC_READ		(zio_priority_table[1])
112fa9e4066Sahrens #define	ZIO_PRIORITY_SYNC_WRITE		(zio_priority_table[2])
113fa9e4066Sahrens #define	ZIO_PRIORITY_ASYNC_READ		(zio_priority_table[3])
114fa9e4066Sahrens #define	ZIO_PRIORITY_ASYNC_WRITE	(zio_priority_table[4])
115fa9e4066Sahrens #define	ZIO_PRIORITY_FREE		(zio_priority_table[5])
116fa9e4066Sahrens #define	ZIO_PRIORITY_CACHE_FILL		(zio_priority_table[6])
117fa9e4066Sahrens #define	ZIO_PRIORITY_LOG_WRITE		(zio_priority_table[7])
118fa9e4066Sahrens #define	ZIO_PRIORITY_RESILVER		(zio_priority_table[8])
119fa9e4066Sahrens #define	ZIO_PRIORITY_SCRUB		(zio_priority_table[9])
120fa9e4066Sahrens #define	ZIO_PRIORITY_TABLE_SIZE		10
121fa9e4066Sahrens 
122ea8dc4b6Seschrock #define	ZIO_FLAG_MUSTSUCCEED		0x00000
123ea8dc4b6Seschrock #define	ZIO_FLAG_CANFAIL		0x00001
124ea8dc4b6Seschrock #define	ZIO_FLAG_FAILFAST		0x00002
125ea8dc4b6Seschrock #define	ZIO_FLAG_CONFIG_HELD		0x00004
126b3995adbSahrens #define	ZIO_FLAG_CONFIG_GRABBED		0x00008
127fa9e4066Sahrens 
128ea8dc4b6Seschrock #define	ZIO_FLAG_DONT_CACHE		0x00010
129ea8dc4b6Seschrock #define	ZIO_FLAG_DONT_QUEUE		0x00020
130ea8dc4b6Seschrock #define	ZIO_FLAG_DONT_PROPAGATE		0x00040
131ea8dc4b6Seschrock #define	ZIO_FLAG_DONT_RETRY		0x00080
132fa9e4066Sahrens 
133ea8dc4b6Seschrock #define	ZIO_FLAG_PHYSICAL		0x00100
134ea8dc4b6Seschrock #define	ZIO_FLAG_IO_BYPASS		0x00200
135ea8dc4b6Seschrock #define	ZIO_FLAG_IO_REPAIR		0x00400
136ea8dc4b6Seschrock #define	ZIO_FLAG_SPECULATIVE		0x00800
137fa9e4066Sahrens 
138ea8dc4b6Seschrock #define	ZIO_FLAG_RESILVER		0x01000
139ea8dc4b6Seschrock #define	ZIO_FLAG_SCRUB			0x02000
140d80c45e0Sbonwick #define	ZIO_FLAG_SCRUB_THREAD		0x04000
141d80c45e0Sbonwick #define	ZIO_FLAG_SUBBLOCK		0x08000
142ea8dc4b6Seschrock 
143ea8dc4b6Seschrock #define	ZIO_FLAG_NOBOOKMARK		0x10000
144faafa6e3Sahrens #define	ZIO_FLAG_USER			0x20000
145fa9e4066Sahrens 
1469bc11082Sek #define	ZIO_FLAG_METADATA		0x40000
1479bc11082Sek 
148fa9e4066Sahrens #define	ZIO_FLAG_GANG_INHERIT		\
149fa9e4066Sahrens 	(ZIO_FLAG_CANFAIL |		\
150fa9e4066Sahrens 	ZIO_FLAG_FAILFAST |		\
151fa9e4066Sahrens 	ZIO_FLAG_CONFIG_HELD |		\
152fa9e4066Sahrens 	ZIO_FLAG_DONT_RETRY |		\
153fa9e4066Sahrens 	ZIO_FLAG_IO_REPAIR |		\
154fa9e4066Sahrens 	ZIO_FLAG_SPECULATIVE |		\
155fa9e4066Sahrens 	ZIO_FLAG_RESILVER |		\
156d80c45e0Sbonwick 	ZIO_FLAG_SCRUB |		\
157d80c45e0Sbonwick 	ZIO_FLAG_SCRUB_THREAD)
158fa9e4066Sahrens 
159fa9e4066Sahrens #define	ZIO_FLAG_VDEV_INHERIT		\
160fa9e4066Sahrens 	(ZIO_FLAG_GANG_INHERIT |	\
161fa9e4066Sahrens 	ZIO_FLAG_DONT_CACHE |		\
162fa9e4066Sahrens 	ZIO_FLAG_PHYSICAL)
163fa9e4066Sahrens 
164fa9e4066Sahrens /*
165fa9e4066Sahrens  * We'll take the unused errno 'EBADE' (from the Convergent graveyard)
166fa9e4066Sahrens  * to indicate checksum errors.
167fa9e4066Sahrens  */
168fa9e4066Sahrens #define	ECKSUM	EBADE
169fa9e4066Sahrens 
170fa9e4066Sahrens typedef struct zio zio_t;
171fa9e4066Sahrens typedef void zio_done_func_t(zio_t *zio);
172fa9e4066Sahrens 
173fa9e4066Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE];
174fa9e4066Sahrens extern char *zio_type_name[ZIO_TYPES];
175fa9e4066Sahrens 
176ea8dc4b6Seschrock /*
177ea8dc4b6Seschrock  * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
178ea8dc4b6Seschrock  * identifies any block in the pool.  By convention, the meta-objset (MOS)
179ea8dc4b6Seschrock  * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is
180ea8dc4b6Seschrock  * level -1 of the meta-dnode, and intent log blocks (which are chained
181ea8dc4b6Seschrock  * off the root block) have blkid == sequence number.  In summary:
182ea8dc4b6Seschrock  *
183ea8dc4b6Seschrock  *	mos is objset 0
184ea8dc4b6Seschrock  *	meta-dnode is object 0
185ea8dc4b6Seschrock  *	root block is <objset, 0, -1, 0>
186ea8dc4b6Seschrock  *	intent log is <objset, 0, -1, ZIL sequence number>
187ea8dc4b6Seschrock  *
188ea8dc4b6Seschrock  * Note: this structure is called a bookmark because its first purpose was
189ea8dc4b6Seschrock  * to remember where to resume a pool-wide traverse.  The absolute ordering
190ea8dc4b6Seschrock  * for block visitation during traversal is defined in compare_bookmark().
191ea8dc4b6Seschrock  *
192ea8dc4b6Seschrock  * Note: this structure is passed between userland and the kernel.
193ea8dc4b6Seschrock  * Therefore it must not change size or alignment between 32/64 bit
194ea8dc4b6Seschrock  * compilation options.
195ea8dc4b6Seschrock  */
196ea8dc4b6Seschrock typedef struct zbookmark {
197ea8dc4b6Seschrock 	uint64_t	zb_objset;
198ea8dc4b6Seschrock 	uint64_t	zb_object;
199ea8dc4b6Seschrock 	int64_t		zb_level;
200ea8dc4b6Seschrock 	uint64_t	zb_blkid;
201ea8dc4b6Seschrock } zbookmark_t;
202ea8dc4b6Seschrock 
203fa9e4066Sahrens struct zio {
204fa9e4066Sahrens 	/* Core information about this I/O */
205fa9e4066Sahrens 	zio_t		*io_parent;
206fa9e4066Sahrens 	zio_t		*io_root;
207fa9e4066Sahrens 	spa_t		*io_spa;
208ea8dc4b6Seschrock 	zbookmark_t	io_bookmark;
20944cd46caSbillm 	enum zio_checksum io_checksum;
21044cd46caSbillm 	enum zio_compress io_compress;
21144cd46caSbillm 	int		io_ndvas;
212fa9e4066Sahrens 	uint64_t	io_txg;
213fa9e4066Sahrens 	blkptr_t	*io_bp;
214fa9e4066Sahrens 	blkptr_t	io_bp_copy;
215fa9e4066Sahrens 	zio_t		*io_child;
216fa9e4066Sahrens 	zio_t		*io_sibling_prev;
217fa9e4066Sahrens 	zio_t		*io_sibling_next;
218fa9e4066Sahrens 	zio_transform_t *io_transform_stack;
219ea8dc4b6Seschrock 	zio_t		*io_logical;
220fa9e4066Sahrens 
221fa9e4066Sahrens 	/* Callback info */
222c717a561Smaybee 	zio_done_func_t	*io_ready;
223fa9e4066Sahrens 	zio_done_func_t	*io_done;
224fa9e4066Sahrens 	void		*io_private;
225fa9e4066Sahrens 	blkptr_t	io_bp_orig;
226fa9e4066Sahrens 
227fa9e4066Sahrens 	/* Data represented by this I/O */
228fa9e4066Sahrens 	void		*io_data;
229fa9e4066Sahrens 	uint64_t	io_size;
230fa9e4066Sahrens 
231fa9e4066Sahrens 	/* Stuff for the vdev stack */
232fa9e4066Sahrens 	vdev_t		*io_vd;
233fa9e4066Sahrens 	void		*io_vsd;
234fa9e4066Sahrens 	uint64_t	io_offset;
235fa9e4066Sahrens 	uint64_t	io_deadline;
236fa9e4066Sahrens 	uint64_t	io_timestamp;
237fa9e4066Sahrens 	avl_node_t	io_offset_node;
238fa9e4066Sahrens 	avl_node_t	io_deadline_node;
239fa9e4066Sahrens 	avl_tree_t	*io_vdev_tree;
240fa9e4066Sahrens 	zio_t		*io_delegate_list;
241fa9e4066Sahrens 	zio_t		*io_delegate_next;
242fa9e4066Sahrens 
243fa9e4066Sahrens 	/* Internal pipeline state */
244fa9e4066Sahrens 	int		io_flags;
24544cd46caSbillm 	enum zio_type	io_type;
24644cd46caSbillm 	enum zio_stage	io_stage;
247fa9e4066Sahrens 	uint8_t		io_stalled;
248fa9e4066Sahrens 	uint8_t		io_priority;
249fa9e4066Sahrens 	struct dk_callback io_dk_callback;
250fa9e4066Sahrens 	int		io_cmd;
251fa9e4066Sahrens 	int		io_retries;
252fa9e4066Sahrens 	int		io_error;
253fa9e4066Sahrens 	uint32_t	io_numerrors;
254fa9e4066Sahrens 	uint32_t	io_pipeline;
255fa9e4066Sahrens 	uint32_t	io_async_stages;
256fa9e4066Sahrens 	uint64_t	io_children_notready;
257fa9e4066Sahrens 	uint64_t	io_children_notdone;
258fa9e4066Sahrens 	void		*io_waiter;
259fa9e4066Sahrens 	kmutex_t	io_lock;
260fa9e4066Sahrens 	kcondvar_t	io_cv;
261ea8dc4b6Seschrock 
262ea8dc4b6Seschrock 	/* FMA state */
263ea8dc4b6Seschrock 	uint64_t	io_ena;
264fa9e4066Sahrens };
265fa9e4066Sahrens 
266fa9e4066Sahrens extern zio_t *zio_null(zio_t *pio, spa_t *spa,
267fa9e4066Sahrens     zio_done_func_t *done, void *private, int flags);
268fa9e4066Sahrens 
269fa9e4066Sahrens extern zio_t *zio_root(spa_t *spa,
270fa9e4066Sahrens     zio_done_func_t *done, void *private, int flags);
271fa9e4066Sahrens 
272fa9e4066Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, blkptr_t *bp, void *data,
273fa9e4066Sahrens     uint64_t size, zio_done_func_t *done, void *private,
274ea8dc4b6Seschrock     int priority, int flags, zbookmark_t *zb);
275fa9e4066Sahrens 
276fa9e4066Sahrens extern zio_t *zio_write(zio_t *pio, spa_t *spa, int checksum, int compress,
27744cd46caSbillm     int ncopies, uint64_t txg, blkptr_t *bp, void *data, uint64_t size,
278c717a561Smaybee     zio_done_func_t *ready, zio_done_func_t *done, void *private, int priority,
279c717a561Smaybee     int flags, zbookmark_t *zb);
280fa9e4066Sahrens 
281fa9e4066Sahrens extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, int checksum,
282fa9e4066Sahrens     uint64_t txg, blkptr_t *bp, void *data, uint64_t size,
283ea8dc4b6Seschrock     zio_done_func_t *done, void *private, int priority, int flags,
284ea8dc4b6Seschrock     zbookmark_t *zb);
285fa9e4066Sahrens 
286fa9e4066Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
287fa9e4066Sahrens     zio_done_func_t *done, void *private);
288fa9e4066Sahrens 
289fa9e4066Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
290fa9e4066Sahrens     zio_done_func_t *done, void *private);
291fa9e4066Sahrens 
292fa9e4066Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
293fa9e4066Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
294fa9e4066Sahrens 
295fa9e4066Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
296fa9e4066Sahrens     uint64_t size, void *data, int checksum,
297fa9e4066Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
298fa9e4066Sahrens 
299fa9e4066Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
300fa9e4066Sahrens     uint64_t size, void *data, int checksum,
301fa9e4066Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
302fa9e4066Sahrens 
30367bd71c6Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp,
30467bd71c6Sperrin     blkptr_t *old_bp, uint64_t txg);
305fa9e4066Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
306fa9e4066Sahrens 
307fa9e4066Sahrens extern int zio_wait(zio_t *zio);
308fa9e4066Sahrens extern void zio_nowait(zio_t *zio);
309fa9e4066Sahrens 
310fa9e4066Sahrens extern void *zio_buf_alloc(size_t size);
311fa9e4066Sahrens extern void zio_buf_free(void *buf, size_t size);
312ad23a2dbSjohansen extern void *zio_data_buf_alloc(size_t size);
313ad23a2dbSjohansen extern void zio_data_buf_free(void *buf, size_t size);
314fa9e4066Sahrens 
315fa9e4066Sahrens /*
316fa9e4066Sahrens  * Move an I/O to the next stage of the pipeline and execute that stage.
317fa9e4066Sahrens  * There's no locking on io_stage because there's no legitimate way for
318fa9e4066Sahrens  * multiple threads to be attempting to process the same I/O.
319fa9e4066Sahrens  */
320fa9e4066Sahrens extern void zio_next_stage(zio_t *zio);
321fa9e4066Sahrens extern void zio_next_stage_async(zio_t *zio);
322fa9e4066Sahrens extern void zio_wait_children_done(zio_t *zio);
323fa9e4066Sahrens 
324fa9e4066Sahrens /*
325fa9e4066Sahrens  * Delegate I/O to a child vdev.
326fa9e4066Sahrens  */
327fa9e4066Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
328fa9e4066Sahrens     uint64_t offset, void *data, uint64_t size, int type, int priority,
329fa9e4066Sahrens     int flags, zio_done_func_t *done, void *private);
330fa9e4066Sahrens 
331fa9e4066Sahrens extern void zio_vdev_io_bypass(zio_t *zio);
332fa9e4066Sahrens extern void zio_vdev_io_reissue(zio_t *zio);
333fa9e4066Sahrens extern void zio_vdev_io_redone(zio_t *zio);
334fa9e4066Sahrens 
335fa9e4066Sahrens extern void zio_checksum_verified(zio_t *zio);
336fa9e4066Sahrens extern void zio_set_gang_verifier(zio_t *zio, zio_cksum_t *zcp);
337fa9e4066Sahrens 
338fa9e4066Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
339fa9e4066Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
340fa9e4066Sahrens 
341ea8dc4b6Seschrock boolean_t zio_should_retry(zio_t *zio);
342ea8dc4b6Seschrock 
343fa9e4066Sahrens /*
344fa9e4066Sahrens  * Initial setup and teardown.
345fa9e4066Sahrens  */
346fa9e4066Sahrens extern void zio_init(void);
347fa9e4066Sahrens extern void zio_fini(void);
348fa9e4066Sahrens 
349ea8dc4b6Seschrock /*
350ea8dc4b6Seschrock  * Fault injection
351ea8dc4b6Seschrock  */
352ea8dc4b6Seschrock struct zinject_record;
353ea8dc4b6Seschrock extern uint32_t zio_injection_enabled;
354ea8dc4b6Seschrock extern int zio_inject_fault(char *name, int flags, int *id,
355ea8dc4b6Seschrock     struct zinject_record *record);
356ea8dc4b6Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen,
357ea8dc4b6Seschrock     struct zinject_record *record);
358ea8dc4b6Seschrock extern int zio_clear_fault(int id);
359ea8dc4b6Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error);
360ea8dc4b6Seschrock extern int zio_handle_device_injection(vdev_t *vd, int error);
361ea8dc4b6Seschrock 
362fa9e4066Sahrens #ifdef	__cplusplus
363fa9e4066Sahrens }
364fa9e4066Sahrens #endif
365fa9e4066Sahrens 
366fa9e4066Sahrens #endif	/* _ZIO_H */
367