xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/zio.h (revision 7754)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
51544Seschrock  * Common Development and Distribution License (the "License").
61544Seschrock  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
213886Sahl 
22789Sahrens /*
236423Sgw25295  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24789Sahrens  * Use is subject to license terms.
25789Sahrens  */
26789Sahrens 
27789Sahrens #ifndef _ZIO_H
28789Sahrens #define	_ZIO_H
29789Sahrens 
30789Sahrens #include <sys/zfs_context.h>
31789Sahrens #include <sys/spa.h>
32789Sahrens #include <sys/txg.h>
33789Sahrens #include <sys/avl.h>
34789Sahrens #include <sys/fs/zfs.h>
351775Sbillm #include <sys/zio_impl.h>
36789Sahrens 
37789Sahrens #ifdef	__cplusplus
38789Sahrens extern "C" {
39789Sahrens #endif
40789Sahrens 
41789Sahrens #define	ZBT_MAGIC	0x210da7ab10c7a11ULL	/* zio data bloc tail */
42789Sahrens 
43789Sahrens typedef struct zio_block_tail {
44789Sahrens 	uint64_t	zbt_magic;	/* for validation, endianness	*/
45789Sahrens 	zio_cksum_t	zbt_cksum;	/* 256-bit checksum		*/
46789Sahrens } zio_block_tail_t;
47789Sahrens 
48789Sahrens /*
49789Sahrens  * Gang block headers are self-checksumming and contain an array
50789Sahrens  * of block pointers.
51789Sahrens  */
52789Sahrens #define	SPA_GANGBLOCKSIZE	SPA_MINBLOCKSIZE
53789Sahrens #define	SPA_GBH_NBLKPTRS	((SPA_GANGBLOCKSIZE - \
54789Sahrens 	sizeof (zio_block_tail_t)) / sizeof (blkptr_t))
55789Sahrens #define	SPA_GBH_FILLER		((SPA_GANGBLOCKSIZE - \
56789Sahrens 	sizeof (zio_block_tail_t) - \
57789Sahrens 	(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
58789Sahrens 	sizeof (uint64_t))
59789Sahrens 
60789Sahrens typedef struct zio_gbh {
61789Sahrens 	blkptr_t		zg_blkptr[SPA_GBH_NBLKPTRS];
62789Sahrens 	uint64_t		zg_filler[SPA_GBH_FILLER];
63789Sahrens 	zio_block_tail_t	zg_tail;
64789Sahrens } zio_gbh_phys_t;
65789Sahrens 
66789Sahrens enum zio_checksum {
67789Sahrens 	ZIO_CHECKSUM_INHERIT = 0,
68789Sahrens 	ZIO_CHECKSUM_ON,
69789Sahrens 	ZIO_CHECKSUM_OFF,
70789Sahrens 	ZIO_CHECKSUM_LABEL,
71789Sahrens 	ZIO_CHECKSUM_GANG_HEADER,
72789Sahrens 	ZIO_CHECKSUM_ZILOG,
73789Sahrens 	ZIO_CHECKSUM_FLETCHER_2,
74789Sahrens 	ZIO_CHECKSUM_FLETCHER_4,
75789Sahrens 	ZIO_CHECKSUM_SHA256,
76789Sahrens 	ZIO_CHECKSUM_FUNCTIONS
77789Sahrens };
78789Sahrens 
79789Sahrens #define	ZIO_CHECKSUM_ON_VALUE	ZIO_CHECKSUM_FLETCHER_2
80789Sahrens #define	ZIO_CHECKSUM_DEFAULT	ZIO_CHECKSUM_ON
81789Sahrens 
82789Sahrens enum zio_compress {
83789Sahrens 	ZIO_COMPRESS_INHERIT = 0,
84789Sahrens 	ZIO_COMPRESS_ON,
85789Sahrens 	ZIO_COMPRESS_OFF,
86789Sahrens 	ZIO_COMPRESS_LZJB,
872986Sek110237 	ZIO_COMPRESS_EMPTY,
883886Sahl 	ZIO_COMPRESS_GZIP_1,
893886Sahl 	ZIO_COMPRESS_GZIP_2,
903886Sahl 	ZIO_COMPRESS_GZIP_3,
913886Sahl 	ZIO_COMPRESS_GZIP_4,
923886Sahl 	ZIO_COMPRESS_GZIP_5,
933886Sahl 	ZIO_COMPRESS_GZIP_6,
943886Sahl 	ZIO_COMPRESS_GZIP_7,
953886Sahl 	ZIO_COMPRESS_GZIP_8,
963886Sahl 	ZIO_COMPRESS_GZIP_9,
97789Sahrens 	ZIO_COMPRESS_FUNCTIONS
98789Sahrens };
99789Sahrens 
100789Sahrens #define	ZIO_COMPRESS_ON_VALUE	ZIO_COMPRESS_LZJB
101789Sahrens #define	ZIO_COMPRESS_DEFAULT	ZIO_COMPRESS_OFF
102789Sahrens 
1035329Sgw25295 #define	ZIO_FAILURE_MODE_WAIT		0
1045329Sgw25295 #define	ZIO_FAILURE_MODE_CONTINUE	1
1055329Sgw25295 #define	ZIO_FAILURE_MODE_PANIC		2
1065329Sgw25295 
107789Sahrens #define	ZIO_PRIORITY_NOW		(zio_priority_table[0])
108789Sahrens #define	ZIO_PRIORITY_SYNC_READ		(zio_priority_table[1])
109789Sahrens #define	ZIO_PRIORITY_SYNC_WRITE		(zio_priority_table[2])
110789Sahrens #define	ZIO_PRIORITY_ASYNC_READ		(zio_priority_table[3])
111789Sahrens #define	ZIO_PRIORITY_ASYNC_WRITE	(zio_priority_table[4])
112789Sahrens #define	ZIO_PRIORITY_FREE		(zio_priority_table[5])
113789Sahrens #define	ZIO_PRIORITY_CACHE_FILL		(zio_priority_table[6])
114789Sahrens #define	ZIO_PRIORITY_LOG_WRITE		(zio_priority_table[7])
115789Sahrens #define	ZIO_PRIORITY_RESILVER		(zio_priority_table[8])
116789Sahrens #define	ZIO_PRIORITY_SCRUB		(zio_priority_table[9])
117789Sahrens #define	ZIO_PRIORITY_TABLE_SIZE		10
118789Sahrens 
1191544Seschrock #define	ZIO_FLAG_MUSTSUCCEED		0x00000
1201544Seschrock #define	ZIO_FLAG_CANFAIL		0x00001
121*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SPECULATIVE		0x00002
122*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_CONFIG_WRITER		0x00004
123*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_DONT_RETRY		0x00008
1241544Seschrock 
1251544Seschrock #define	ZIO_FLAG_DONT_CACHE		0x00010
1261544Seschrock #define	ZIO_FLAG_DONT_QUEUE		0x00020
127*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_DONT_AGGREGATE		0x00040
128*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_DONT_PROPAGATE		0x00080
129789Sahrens 
130*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_BYPASS		0x00100
131*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_REPAIR		0x00200
132*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_RETRY		0x00400
133*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_REWRITE		0x00800
134789Sahrens 
135*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_PROBE			0x01000
136*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_RESILVER		0x02000
137*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SCRUB			0x04000
138*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SCRUB_THREAD		0x08000
139*7754SJeff.Bonwick@Sun.COM 
140*7754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_GANG_CHILD		0x10000
1413689Sek110237 
142789Sahrens #define	ZIO_FLAG_GANG_INHERIT		\
143789Sahrens 	(ZIO_FLAG_CANFAIL |		\
144*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SPECULATIVE |		\
145*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_CONFIG_WRITER |	\
146*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_RETRY |		\
1475530Sbonwick 	ZIO_FLAG_DONT_CACHE |		\
148*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_AGGREGATE |	\
149789Sahrens 	ZIO_FLAG_RESILVER |		\
1501807Sbonwick 	ZIO_FLAG_SCRUB |		\
151*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB_THREAD)
152789Sahrens 
153789Sahrens #define	ZIO_FLAG_VDEV_INHERIT		\
154789Sahrens 	(ZIO_FLAG_GANG_INHERIT |	\
155*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_REPAIR |		\
156*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_RETRY |		\
157*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_PROBE)
1585688Sbonwick 
1595530Sbonwick #define	ZIO_PIPELINE_CONTINUE		0x100
1605530Sbonwick #define	ZIO_PIPELINE_STOP		0x101
1615530Sbonwick 
162*7754SJeff.Bonwick@Sun.COM #define	ZIO_GANG_CHILD_FLAGS(zio)				\
163*7754SJeff.Bonwick@Sun.COM 	(((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) |		\
164*7754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL)
165*7754SJeff.Bonwick@Sun.COM 
166*7754SJeff.Bonwick@Sun.COM enum zio_child {
167*7754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_VDEV = 0,
168*7754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_GANG,
169*7754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_LOGICAL,
170*7754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_TYPES
171*7754SJeff.Bonwick@Sun.COM };
172*7754SJeff.Bonwick@Sun.COM 
173*7754SJeff.Bonwick@Sun.COM enum zio_wait_type {
174*7754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_READY = 0,
175*7754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_DONE,
176*7754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_TYPES
177*7754SJeff.Bonwick@Sun.COM };
178*7754SJeff.Bonwick@Sun.COM 
179789Sahrens /*
1806423Sgw25295  * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent
1816423Sgw25295  * graveyard) to indicate checksum errors and fragmentation.
182789Sahrens  */
183789Sahrens #define	ECKSUM	EBADE
1846423Sgw25295 #define	EFRAGS	EBADR
185789Sahrens 
186789Sahrens typedef struct zio zio_t;
187789Sahrens typedef void zio_done_func_t(zio_t *zio);
188789Sahrens 
189789Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE];
190789Sahrens extern char *zio_type_name[ZIO_TYPES];
191789Sahrens 
1921544Seschrock /*
1931544Seschrock  * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
1941544Seschrock  * identifies any block in the pool.  By convention, the meta-objset (MOS)
1951544Seschrock  * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is
1961544Seschrock  * level -1 of the meta-dnode, and intent log blocks (which are chained
1971544Seschrock  * off the root block) have blkid == sequence number.  In summary:
1981544Seschrock  *
1991544Seschrock  *	mos is objset 0
2001544Seschrock  *	meta-dnode is object 0
2011544Seschrock  *	root block is <objset, 0, -1, 0>
2021544Seschrock  *	intent log is <objset, 0, -1, ZIL sequence number>
2031544Seschrock  *
2041544Seschrock  * Note: this structure is called a bookmark because its first purpose was
2051544Seschrock  * to remember where to resume a pool-wide traverse.  The absolute ordering
2061544Seschrock  * for block visitation during traversal is defined in compare_bookmark().
2071544Seschrock  *
2081544Seschrock  * Note: this structure is passed between userland and the kernel.
2091544Seschrock  * Therefore it must not change size or alignment between 32/64 bit
2101544Seschrock  * compilation options.
2111544Seschrock  */
2121544Seschrock typedef struct zbookmark {
2131544Seschrock 	uint64_t	zb_objset;
2141544Seschrock 	uint64_t	zb_object;
2151544Seschrock 	int64_t		zb_level;
2161544Seschrock 	uint64_t	zb_blkid;
2171544Seschrock } zbookmark_t;
2181544Seschrock 
219*7754SJeff.Bonwick@Sun.COM typedef struct zio_prop {
220*7754SJeff.Bonwick@Sun.COM 	enum zio_checksum	zp_checksum;
221*7754SJeff.Bonwick@Sun.COM 	enum zio_compress	zp_compress;
222*7754SJeff.Bonwick@Sun.COM 	dmu_object_type_t	zp_type;
223*7754SJeff.Bonwick@Sun.COM 	uint8_t			zp_level;
224*7754SJeff.Bonwick@Sun.COM 	uint8_t			zp_ndvas;
225*7754SJeff.Bonwick@Sun.COM } zio_prop_t;
226*7754SJeff.Bonwick@Sun.COM 
227*7754SJeff.Bonwick@Sun.COM typedef struct zio_gang_node {
228*7754SJeff.Bonwick@Sun.COM 	zio_gbh_phys_t		*gn_gbh;
229*7754SJeff.Bonwick@Sun.COM 	struct zio_gang_node	*gn_child[SPA_GBH_NBLKPTRS];
230*7754SJeff.Bonwick@Sun.COM } zio_gang_node_t;
231*7754SJeff.Bonwick@Sun.COM 
232*7754SJeff.Bonwick@Sun.COM typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp,
233*7754SJeff.Bonwick@Sun.COM     zio_gang_node_t *gn, void *data);
234*7754SJeff.Bonwick@Sun.COM 
235*7754SJeff.Bonwick@Sun.COM typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size);
236*7754SJeff.Bonwick@Sun.COM 
237*7754SJeff.Bonwick@Sun.COM typedef struct zio_transform {
238*7754SJeff.Bonwick@Sun.COM 	void			*zt_orig_data;
239*7754SJeff.Bonwick@Sun.COM 	uint64_t		zt_orig_size;
240*7754SJeff.Bonwick@Sun.COM 	uint64_t		zt_bufsize;
241*7754SJeff.Bonwick@Sun.COM 	zio_transform_func_t	*zt_transform;
242*7754SJeff.Bonwick@Sun.COM 	struct zio_transform	*zt_next;
243*7754SJeff.Bonwick@Sun.COM } zio_transform_t;
244*7754SJeff.Bonwick@Sun.COM 
245*7754SJeff.Bonwick@Sun.COM typedef int zio_pipe_stage_t(zio_t *zio);
246*7754SJeff.Bonwick@Sun.COM 
247*7754SJeff.Bonwick@Sun.COM /*
248*7754SJeff.Bonwick@Sun.COM  * The io_reexecute flags are distinct from io_flags because the child must
249*7754SJeff.Bonwick@Sun.COM  * be able to propagate them to the parent.  The normal io_flags are local
250*7754SJeff.Bonwick@Sun.COM  * to the zio, not protected by any lock, and not modifiable by children;
251*7754SJeff.Bonwick@Sun.COM  * the reexecute flags are protected by io_lock, modifiable by children,
252*7754SJeff.Bonwick@Sun.COM  * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set.
253*7754SJeff.Bonwick@Sun.COM  */
254*7754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_NOW	0x01
255*7754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_SUSPEND	0x02
256*7754SJeff.Bonwick@Sun.COM 
257789Sahrens struct zio {
258789Sahrens 	/* Core information about this I/O */
259*7754SJeff.Bonwick@Sun.COM 	zbookmark_t	io_bookmark;
260*7754SJeff.Bonwick@Sun.COM 	zio_prop_t	io_prop;
261*7754SJeff.Bonwick@Sun.COM 	zio_type_t	io_type;
262*7754SJeff.Bonwick@Sun.COM 	enum zio_child	io_child_type;
263*7754SJeff.Bonwick@Sun.COM 	int		io_cmd;
264*7754SJeff.Bonwick@Sun.COM 	uint8_t		io_priority;
265*7754SJeff.Bonwick@Sun.COM 	uint8_t		io_reexecute;
266*7754SJeff.Bonwick@Sun.COM 	uint8_t		io_async_root;
267*7754SJeff.Bonwick@Sun.COM 	uint64_t	io_txg;
268789Sahrens 	spa_t		*io_spa;
269789Sahrens 	blkptr_t	*io_bp;
270789Sahrens 	blkptr_t	io_bp_copy;
271*7754SJeff.Bonwick@Sun.COM 	zio_t		*io_parent;
272789Sahrens 	zio_t		*io_child;
273789Sahrens 	zio_t		*io_sibling_prev;
274789Sahrens 	zio_t		*io_sibling_next;
275*7754SJeff.Bonwick@Sun.COM 	zio_t		*io_logical;
276789Sahrens 	zio_transform_t *io_transform_stack;
277789Sahrens 
278789Sahrens 	/* Callback info */
2793547Smaybee 	zio_done_func_t	*io_ready;
280789Sahrens 	zio_done_func_t	*io_done;
281789Sahrens 	void		*io_private;
282789Sahrens 	blkptr_t	io_bp_orig;
283789Sahrens 
284789Sahrens 	/* Data represented by this I/O */
285789Sahrens 	void		*io_data;
286789Sahrens 	uint64_t	io_size;
287789Sahrens 
288789Sahrens 	/* Stuff for the vdev stack */
289789Sahrens 	vdev_t		*io_vd;
290789Sahrens 	void		*io_vsd;
291*7754SJeff.Bonwick@Sun.COM 	zio_done_func_t	*io_vsd_free;
292789Sahrens 	uint64_t	io_offset;
293789Sahrens 	uint64_t	io_deadline;
294789Sahrens 	avl_node_t	io_offset_node;
295789Sahrens 	avl_node_t	io_deadline_node;
296789Sahrens 	avl_tree_t	*io_vdev_tree;
297789Sahrens 	zio_t		*io_delegate_list;
298789Sahrens 	zio_t		*io_delegate_next;
299789Sahrens 
300789Sahrens 	/* Internal pipeline state */
301789Sahrens 	int		io_flags;
302*7754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_stage;
303*7754SJeff.Bonwick@Sun.COM 	uint32_t	io_pipeline;
3045329Sgw25295 	int		io_orig_flags;
305*7754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_orig_stage;
306*7754SJeff.Bonwick@Sun.COM 	uint32_t	io_orig_pipeline;
307789Sahrens 	int		io_error;
308*7754SJeff.Bonwick@Sun.COM 	int		io_child_error[ZIO_CHILD_TYPES];
309*7754SJeff.Bonwick@Sun.COM 	uint64_t	io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES];
310*7754SJeff.Bonwick@Sun.COM 	uint64_t	*io_stall;
311*7754SJeff.Bonwick@Sun.COM 	zio_gang_node_t	*io_gang_tree;
312*7754SJeff.Bonwick@Sun.COM 	void		*io_executor;
313789Sahrens 	void		*io_waiter;
314789Sahrens 	kmutex_t	io_lock;
315789Sahrens 	kcondvar_t	io_cv;
3161544Seschrock 
3171544Seschrock 	/* FMA state */
3181544Seschrock 	uint64_t	io_ena;
319789Sahrens };
320789Sahrens 
321789Sahrens extern zio_t *zio_null(zio_t *pio, spa_t *spa,
322789Sahrens     zio_done_func_t *done, void *private, int flags);
323789Sahrens 
324789Sahrens extern zio_t *zio_root(spa_t *spa,
325789Sahrens     zio_done_func_t *done, void *private, int flags);
326789Sahrens 
3277046Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data,
328789Sahrens     uint64_t size, zio_done_func_t *done, void *private,
3297046Sahrens     int priority, int flags, const zbookmark_t *zb);
330789Sahrens 
331*7754SJeff.Bonwick@Sun.COM extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
332*7754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_prop_t *zp,
333*7754SJeff.Bonwick@Sun.COM     zio_done_func_t *ready, zio_done_func_t *done, void *private,
334*7754SJeff.Bonwick@Sun.COM     int priority, int flags, const zbookmark_t *zb);
335789Sahrens 
336*7754SJeff.Bonwick@Sun.COM extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
337*7754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_done_func_t *done, void *private,
338*7754SJeff.Bonwick@Sun.COM     int priority, int flags, zbookmark_t *zb);
339789Sahrens 
340789Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
341*7754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
342789Sahrens 
343789Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
344*7754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
345789Sahrens 
346789Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
347789Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
348789Sahrens 
349789Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
350789Sahrens     uint64_t size, void *data, int checksum,
3515450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
3525450Sbrendan     boolean_t labels);
353789Sahrens 
354789Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
355789Sahrens     uint64_t size, void *data, int checksum,
3565450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
3575450Sbrendan     boolean_t labels);
358789Sahrens 
3593063Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp,
3603063Sperrin     blkptr_t *old_bp, uint64_t txg);
361789Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
3625688Sbonwick extern void zio_flush(zio_t *zio, vdev_t *vd);
363789Sahrens 
364789Sahrens extern int zio_wait(zio_t *zio);
365789Sahrens extern void zio_nowait(zio_t *zio);
3665530Sbonwick extern void zio_execute(zio_t *zio);
3675530Sbonwick extern void zio_interrupt(zio_t *zio);
3685530Sbonwick 
369789Sahrens extern void *zio_buf_alloc(size_t size);
370789Sahrens extern void zio_buf_free(void *buf, size_t size);
3713290Sjohansen extern void *zio_data_buf_alloc(size_t size);
3723290Sjohansen extern void zio_data_buf_free(void *buf, size_t size);
373789Sahrens 
3745329Sgw25295 extern void zio_resubmit_stage_async(void *);
375789Sahrens 
376789Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
377789Sahrens     uint64_t offset, void *data, uint64_t size, int type, int priority,
378789Sahrens     int flags, zio_done_func_t *done, void *private);
379789Sahrens 
380*7754SJeff.Bonwick@Sun.COM extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset,
381*7754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, int type, int priority,
382*7754SJeff.Bonwick@Sun.COM     int flags, zio_done_func_t *done, void *private);
383*7754SJeff.Bonwick@Sun.COM 
384789Sahrens extern void zio_vdev_io_bypass(zio_t *zio);
385789Sahrens extern void zio_vdev_io_reissue(zio_t *zio);
386789Sahrens extern void zio_vdev_io_redone(zio_t *zio);
387789Sahrens 
388789Sahrens extern void zio_checksum_verified(zio_t *zio);
389*7754SJeff.Bonwick@Sun.COM extern int zio_worst_error(int e1, int e2);
390789Sahrens 
391789Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
392789Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
393789Sahrens 
394*7754SJeff.Bonwick@Sun.COM extern void zio_suspend(spa_t *spa, zio_t *zio);
395*7754SJeff.Bonwick@Sun.COM extern void zio_resume(spa_t *spa);
396*7754SJeff.Bonwick@Sun.COM extern void zio_resume_wait(spa_t *spa);
3971544Seschrock 
398789Sahrens /*
399789Sahrens  * Initial setup and teardown.
400789Sahrens  */
401789Sahrens extern void zio_init(void);
402789Sahrens extern void zio_fini(void);
403789Sahrens 
4041544Seschrock /*
4051544Seschrock  * Fault injection
4061544Seschrock  */
4071544Seschrock struct zinject_record;
4081544Seschrock extern uint32_t zio_injection_enabled;
4091544Seschrock extern int zio_inject_fault(char *name, int flags, int *id,
4101544Seschrock     struct zinject_record *record);
4111544Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen,
4121544Seschrock     struct zinject_record *record);
4131544Seschrock extern int zio_clear_fault(int id);
4141544Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error);
4151544Seschrock extern int zio_handle_device_injection(vdev_t *vd, int error);
4166615Sgw25295 extern int zio_handle_label_injection(zio_t *zio, int error);
4171544Seschrock 
418789Sahrens #ifdef	__cplusplus
419789Sahrens }
420789Sahrens #endif
421789Sahrens 
422789Sahrens #endif	/* _ZIO_H */
423