xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zio.h (revision e14bb3258d05c1b1077e2db7cf77088924e56919)
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  */
21c9431fa1Sahl 
22fa9e4066Sahrens /*
23e7cbe64fSgw  * Copyright 2008 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 #include <sys/zfs_context.h>
31fa9e4066Sahrens #include <sys/spa.h>
32fa9e4066Sahrens #include <sys/txg.h>
33fa9e4066Sahrens #include <sys/avl.h>
34fa9e4066Sahrens #include <sys/fs/zfs.h>
3544cd46caSbillm #include <sys/zio_impl.h>
36fa9e4066Sahrens 
37fa9e4066Sahrens #ifdef	__cplusplus
38fa9e4066Sahrens extern "C" {
39fa9e4066Sahrens #endif
40fa9e4066Sahrens 
41fa9e4066Sahrens #define	ZBT_MAGIC	0x210da7ab10c7a11ULL	/* zio data bloc tail */
42fa9e4066Sahrens 
43fa9e4066Sahrens typedef struct zio_block_tail {
44fa9e4066Sahrens 	uint64_t	zbt_magic;	/* for validation, endianness	*/
45fa9e4066Sahrens 	zio_cksum_t	zbt_cksum;	/* 256-bit checksum		*/
46fa9e4066Sahrens } zio_block_tail_t;
47fa9e4066Sahrens 
48fa9e4066Sahrens /*
49fa9e4066Sahrens  * Gang block headers are self-checksumming and contain an array
50fa9e4066Sahrens  * of block pointers.
51fa9e4066Sahrens  */
52fa9e4066Sahrens #define	SPA_GANGBLOCKSIZE	SPA_MINBLOCKSIZE
53fa9e4066Sahrens #define	SPA_GBH_NBLKPTRS	((SPA_GANGBLOCKSIZE - \
54fa9e4066Sahrens 	sizeof (zio_block_tail_t)) / sizeof (blkptr_t))
55fa9e4066Sahrens #define	SPA_GBH_FILLER		((SPA_GANGBLOCKSIZE - \
56fa9e4066Sahrens 	sizeof (zio_block_tail_t) - \
57fa9e4066Sahrens 	(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
58fa9e4066Sahrens 	sizeof (uint64_t))
59fa9e4066Sahrens 
60fa9e4066Sahrens typedef struct zio_gbh {
61fa9e4066Sahrens 	blkptr_t		zg_blkptr[SPA_GBH_NBLKPTRS];
62fa9e4066Sahrens 	uint64_t		zg_filler[SPA_GBH_FILLER];
63fa9e4066Sahrens 	zio_block_tail_t	zg_tail;
64fa9e4066Sahrens } zio_gbh_phys_t;
65fa9e4066Sahrens 
66fa9e4066Sahrens enum zio_checksum {
67fa9e4066Sahrens 	ZIO_CHECKSUM_INHERIT = 0,
68fa9e4066Sahrens 	ZIO_CHECKSUM_ON,
69fa9e4066Sahrens 	ZIO_CHECKSUM_OFF,
70fa9e4066Sahrens 	ZIO_CHECKSUM_LABEL,
71fa9e4066Sahrens 	ZIO_CHECKSUM_GANG_HEADER,
72fa9e4066Sahrens 	ZIO_CHECKSUM_ZILOG,
73fa9e4066Sahrens 	ZIO_CHECKSUM_FLETCHER_2,
74fa9e4066Sahrens 	ZIO_CHECKSUM_FLETCHER_4,
75fa9e4066Sahrens 	ZIO_CHECKSUM_SHA256,
76fa9e4066Sahrens 	ZIO_CHECKSUM_FUNCTIONS
77fa9e4066Sahrens };
78fa9e4066Sahrens 
79fa9e4066Sahrens #define	ZIO_CHECKSUM_ON_VALUE	ZIO_CHECKSUM_FLETCHER_2
80fa9e4066Sahrens #define	ZIO_CHECKSUM_DEFAULT	ZIO_CHECKSUM_ON
81fa9e4066Sahrens 
82fa9e4066Sahrens enum zio_compress {
83fa9e4066Sahrens 	ZIO_COMPRESS_INHERIT = 0,
84fa9e4066Sahrens 	ZIO_COMPRESS_ON,
85fa9e4066Sahrens 	ZIO_COMPRESS_OFF,
86fa9e4066Sahrens 	ZIO_COMPRESS_LZJB,
87416e0cd8Sek 	ZIO_COMPRESS_EMPTY,
88c9431fa1Sahl 	ZIO_COMPRESS_GZIP_1,
89c9431fa1Sahl 	ZIO_COMPRESS_GZIP_2,
90c9431fa1Sahl 	ZIO_COMPRESS_GZIP_3,
91c9431fa1Sahl 	ZIO_COMPRESS_GZIP_4,
92c9431fa1Sahl 	ZIO_COMPRESS_GZIP_5,
93c9431fa1Sahl 	ZIO_COMPRESS_GZIP_6,
94c9431fa1Sahl 	ZIO_COMPRESS_GZIP_7,
95c9431fa1Sahl 	ZIO_COMPRESS_GZIP_8,
96c9431fa1Sahl 	ZIO_COMPRESS_GZIP_9,
97fa9e4066Sahrens 	ZIO_COMPRESS_FUNCTIONS
98fa9e4066Sahrens };
99fa9e4066Sahrens 
100fa9e4066Sahrens #define	ZIO_COMPRESS_ON_VALUE	ZIO_COMPRESS_LZJB
101fa9e4066Sahrens #define	ZIO_COMPRESS_DEFAULT	ZIO_COMPRESS_OFF
102fa9e4066Sahrens 
1030a4e9518Sgw #define	ZIO_FAILURE_MODE_WAIT		0
1040a4e9518Sgw #define	ZIO_FAILURE_MODE_CONTINUE	1
1050a4e9518Sgw #define	ZIO_FAILURE_MODE_PANIC		2
1060a4e9518Sgw 
107fa9e4066Sahrens #define	ZIO_PRIORITY_NOW		(zio_priority_table[0])
108fa9e4066Sahrens #define	ZIO_PRIORITY_SYNC_READ		(zio_priority_table[1])
109fa9e4066Sahrens #define	ZIO_PRIORITY_SYNC_WRITE		(zio_priority_table[2])
110fa9e4066Sahrens #define	ZIO_PRIORITY_ASYNC_READ		(zio_priority_table[3])
111fa9e4066Sahrens #define	ZIO_PRIORITY_ASYNC_WRITE	(zio_priority_table[4])
112fa9e4066Sahrens #define	ZIO_PRIORITY_FREE		(zio_priority_table[5])
113fa9e4066Sahrens #define	ZIO_PRIORITY_CACHE_FILL		(zio_priority_table[6])
114fa9e4066Sahrens #define	ZIO_PRIORITY_LOG_WRITE		(zio_priority_table[7])
115fa9e4066Sahrens #define	ZIO_PRIORITY_RESILVER		(zio_priority_table[8])
116fa9e4066Sahrens #define	ZIO_PRIORITY_SCRUB		(zio_priority_table[9])
117fa9e4066Sahrens #define	ZIO_PRIORITY_TABLE_SIZE		10
118fa9e4066Sahrens 
119ea8dc4b6Seschrock #define	ZIO_FLAG_MUSTSUCCEED		0x00000
120ea8dc4b6Seschrock #define	ZIO_FLAG_CANFAIL		0x00001
121*e14bb325SJeff Bonwick #define	ZIO_FLAG_SPECULATIVE		0x00002
122*e14bb325SJeff Bonwick #define	ZIO_FLAG_CONFIG_WRITER		0x00004
123*e14bb325SJeff Bonwick #define	ZIO_FLAG_DONT_RETRY		0x00008
124fa9e4066Sahrens 
125ea8dc4b6Seschrock #define	ZIO_FLAG_DONT_CACHE		0x00010
126ea8dc4b6Seschrock #define	ZIO_FLAG_DONT_QUEUE		0x00020
127*e14bb325SJeff Bonwick #define	ZIO_FLAG_DONT_AGGREGATE		0x00040
128*e14bb325SJeff Bonwick #define	ZIO_FLAG_DONT_PROPAGATE		0x00080
129fa9e4066Sahrens 
130*e14bb325SJeff Bonwick #define	ZIO_FLAG_IO_BYPASS		0x00100
131*e14bb325SJeff Bonwick #define	ZIO_FLAG_IO_REPAIR		0x00200
132*e14bb325SJeff Bonwick #define	ZIO_FLAG_IO_RETRY		0x00400
133*e14bb325SJeff Bonwick #define	ZIO_FLAG_IO_REWRITE		0x00800
134fa9e4066Sahrens 
135*e14bb325SJeff Bonwick #define	ZIO_FLAG_PROBE			0x01000
136*e14bb325SJeff Bonwick #define	ZIO_FLAG_RESILVER		0x02000
137*e14bb325SJeff Bonwick #define	ZIO_FLAG_SCRUB			0x04000
138*e14bb325SJeff Bonwick #define	ZIO_FLAG_SCRUB_THREAD		0x08000
139ea8dc4b6Seschrock 
140*e14bb325SJeff Bonwick #define	ZIO_FLAG_GANG_CHILD		0x10000
1419bc11082Sek 
142fa9e4066Sahrens #define	ZIO_FLAG_GANG_INHERIT		\
143fa9e4066Sahrens 	(ZIO_FLAG_CANFAIL |		\
144fa9e4066Sahrens 	ZIO_FLAG_SPECULATIVE |		\
145*e14bb325SJeff Bonwick 	ZIO_FLAG_CONFIG_WRITER |	\
146*e14bb325SJeff Bonwick 	ZIO_FLAG_DONT_RETRY |		\
147*e14bb325SJeff Bonwick 	ZIO_FLAG_DONT_CACHE |		\
148*e14bb325SJeff Bonwick 	ZIO_FLAG_DONT_AGGREGATE |	\
149fa9e4066Sahrens 	ZIO_FLAG_RESILVER |		\
150d80c45e0Sbonwick 	ZIO_FLAG_SCRUB |		\
151*e14bb325SJeff Bonwick 	ZIO_FLAG_SCRUB_THREAD)
152fa9e4066Sahrens 
153fa9e4066Sahrens #define	ZIO_FLAG_VDEV_INHERIT		\
154fa9e4066Sahrens 	(ZIO_FLAG_GANG_INHERIT |	\
155*e14bb325SJeff Bonwick 	ZIO_FLAG_IO_REPAIR |		\
156*e14bb325SJeff Bonwick 	ZIO_FLAG_IO_RETRY |		\
157*e14bb325SJeff Bonwick 	ZIO_FLAG_PROBE)
15817f17c2dSbonwick 
159e05725b1Sbonwick #define	ZIO_PIPELINE_CONTINUE		0x100
160e05725b1Sbonwick #define	ZIO_PIPELINE_STOP		0x101
161e05725b1Sbonwick 
162*e14bb325SJeff Bonwick #define	ZIO_GANG_CHILD_FLAGS(zio)				\
163*e14bb325SJeff Bonwick 	(((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) |		\
164*e14bb325SJeff Bonwick 	ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL)
165*e14bb325SJeff Bonwick 
166*e14bb325SJeff Bonwick enum zio_child {
167*e14bb325SJeff Bonwick 	ZIO_CHILD_VDEV = 0,
168*e14bb325SJeff Bonwick 	ZIO_CHILD_GANG,
169*e14bb325SJeff Bonwick 	ZIO_CHILD_LOGICAL,
170*e14bb325SJeff Bonwick 	ZIO_CHILD_TYPES
171*e14bb325SJeff Bonwick };
172*e14bb325SJeff Bonwick 
173*e14bb325SJeff Bonwick enum zio_wait_type {
174*e14bb325SJeff Bonwick 	ZIO_WAIT_READY = 0,
175*e14bb325SJeff Bonwick 	ZIO_WAIT_DONE,
176*e14bb325SJeff Bonwick 	ZIO_WAIT_TYPES
177*e14bb325SJeff Bonwick };
178*e14bb325SJeff Bonwick 
179fa9e4066Sahrens /*
180e7cbe64fSgw  * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent
181e7cbe64fSgw  * graveyard) to indicate checksum errors and fragmentation.
182fa9e4066Sahrens  */
183fa9e4066Sahrens #define	ECKSUM	EBADE
184e7cbe64fSgw #define	EFRAGS	EBADR
185fa9e4066Sahrens 
186fa9e4066Sahrens typedef struct zio zio_t;
187fa9e4066Sahrens typedef void zio_done_func_t(zio_t *zio);
188fa9e4066Sahrens 
189fa9e4066Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE];
190fa9e4066Sahrens extern char *zio_type_name[ZIO_TYPES];
191fa9e4066Sahrens 
192ea8dc4b6Seschrock /*
193ea8dc4b6Seschrock  * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
194ea8dc4b6Seschrock  * identifies any block in the pool.  By convention, the meta-objset (MOS)
195ea8dc4b6Seschrock  * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is
196ea8dc4b6Seschrock  * level -1 of the meta-dnode, and intent log blocks (which are chained
197ea8dc4b6Seschrock  * off the root block) have blkid == sequence number.  In summary:
198ea8dc4b6Seschrock  *
199ea8dc4b6Seschrock  *	mos is objset 0
200ea8dc4b6Seschrock  *	meta-dnode is object 0
201ea8dc4b6Seschrock  *	root block is <objset, 0, -1, 0>
202ea8dc4b6Seschrock  *	intent log is <objset, 0, -1, ZIL sequence number>
203ea8dc4b6Seschrock  *
204ea8dc4b6Seschrock  * Note: this structure is called a bookmark because its first purpose was
205ea8dc4b6Seschrock  * to remember where to resume a pool-wide traverse.  The absolute ordering
206ea8dc4b6Seschrock  * for block visitation during traversal is defined in compare_bookmark().
207ea8dc4b6Seschrock  *
208ea8dc4b6Seschrock  * Note: this structure is passed between userland and the kernel.
209ea8dc4b6Seschrock  * Therefore it must not change size or alignment between 32/64 bit
210ea8dc4b6Seschrock  * compilation options.
211ea8dc4b6Seschrock  */
212ea8dc4b6Seschrock typedef struct zbookmark {
213ea8dc4b6Seschrock 	uint64_t	zb_objset;
214ea8dc4b6Seschrock 	uint64_t	zb_object;
215ea8dc4b6Seschrock 	int64_t		zb_level;
216ea8dc4b6Seschrock 	uint64_t	zb_blkid;
217ea8dc4b6Seschrock } zbookmark_t;
218ea8dc4b6Seschrock 
219*e14bb325SJeff Bonwick typedef struct zio_prop {
220*e14bb325SJeff Bonwick 	enum zio_checksum	zp_checksum;
221*e14bb325SJeff Bonwick 	enum zio_compress	zp_compress;
222*e14bb325SJeff Bonwick 	dmu_object_type_t	zp_type;
223*e14bb325SJeff Bonwick 	uint8_t			zp_level;
224*e14bb325SJeff Bonwick 	uint8_t			zp_ndvas;
225*e14bb325SJeff Bonwick } zio_prop_t;
226*e14bb325SJeff Bonwick 
227*e14bb325SJeff Bonwick typedef struct zio_gang_node {
228*e14bb325SJeff Bonwick 	zio_gbh_phys_t		*gn_gbh;
229*e14bb325SJeff Bonwick 	struct zio_gang_node	*gn_child[SPA_GBH_NBLKPTRS];
230*e14bb325SJeff Bonwick } zio_gang_node_t;
231*e14bb325SJeff Bonwick 
232*e14bb325SJeff Bonwick typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp,
233*e14bb325SJeff Bonwick     zio_gang_node_t *gn, void *data);
234*e14bb325SJeff Bonwick 
235*e14bb325SJeff Bonwick typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size);
236*e14bb325SJeff Bonwick 
237*e14bb325SJeff Bonwick typedef struct zio_transform {
238*e14bb325SJeff Bonwick 	void			*zt_orig_data;
239*e14bb325SJeff Bonwick 	uint64_t		zt_orig_size;
240*e14bb325SJeff Bonwick 	uint64_t		zt_bufsize;
241*e14bb325SJeff Bonwick 	zio_transform_func_t	*zt_transform;
242*e14bb325SJeff Bonwick 	struct zio_transform	*zt_next;
243*e14bb325SJeff Bonwick } zio_transform_t;
244*e14bb325SJeff Bonwick 
245*e14bb325SJeff Bonwick typedef int zio_pipe_stage_t(zio_t *zio);
246*e14bb325SJeff Bonwick 
247*e14bb325SJeff Bonwick /*
248*e14bb325SJeff Bonwick  * The io_reexecute flags are distinct from io_flags because the child must
249*e14bb325SJeff Bonwick  * be able to propagate them to the parent.  The normal io_flags are local
250*e14bb325SJeff Bonwick  * to the zio, not protected by any lock, and not modifiable by children;
251*e14bb325SJeff Bonwick  * the reexecute flags are protected by io_lock, modifiable by children,
252*e14bb325SJeff Bonwick  * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set.
253*e14bb325SJeff Bonwick  */
254*e14bb325SJeff Bonwick #define	ZIO_REEXECUTE_NOW	0x01
255*e14bb325SJeff Bonwick #define	ZIO_REEXECUTE_SUSPEND	0x02
256*e14bb325SJeff Bonwick 
257fa9e4066Sahrens struct zio {
258fa9e4066Sahrens 	/* Core information about this I/O */
259ea8dc4b6Seschrock 	zbookmark_t	io_bookmark;
260*e14bb325SJeff Bonwick 	zio_prop_t	io_prop;
261*e14bb325SJeff Bonwick 	zio_type_t	io_type;
262*e14bb325SJeff Bonwick 	enum zio_child	io_child_type;
263*e14bb325SJeff Bonwick 	int		io_cmd;
264*e14bb325SJeff Bonwick 	uint8_t		io_priority;
265*e14bb325SJeff Bonwick 	uint8_t		io_reexecute;
266*e14bb325SJeff Bonwick 	uint8_t		io_async_root;
267fa9e4066Sahrens 	uint64_t	io_txg;
268*e14bb325SJeff Bonwick 	spa_t		*io_spa;
269fa9e4066Sahrens 	blkptr_t	*io_bp;
270fa9e4066Sahrens 	blkptr_t	io_bp_copy;
271*e14bb325SJeff Bonwick 	zio_t		*io_parent;
272fa9e4066Sahrens 	zio_t		*io_child;
273fa9e4066Sahrens 	zio_t		*io_sibling_prev;
274fa9e4066Sahrens 	zio_t		*io_sibling_next;
275ea8dc4b6Seschrock 	zio_t		*io_logical;
276*e14bb325SJeff Bonwick 	zio_transform_t *io_transform_stack;
277fa9e4066Sahrens 
278fa9e4066Sahrens 	/* Callback info */
279c717a561Smaybee 	zio_done_func_t	*io_ready;
280fa9e4066Sahrens 	zio_done_func_t	*io_done;
281fa9e4066Sahrens 	void		*io_private;
282fa9e4066Sahrens 	blkptr_t	io_bp_orig;
283fa9e4066Sahrens 
284fa9e4066Sahrens 	/* Data represented by this I/O */
285fa9e4066Sahrens 	void		*io_data;
286fa9e4066Sahrens 	uint64_t	io_size;
287fa9e4066Sahrens 
288fa9e4066Sahrens 	/* Stuff for the vdev stack */
289fa9e4066Sahrens 	vdev_t		*io_vd;
290fa9e4066Sahrens 	void		*io_vsd;
291*e14bb325SJeff Bonwick 	zio_done_func_t	*io_vsd_free;
292fa9e4066Sahrens 	uint64_t	io_offset;
293fa9e4066Sahrens 	uint64_t	io_deadline;
294fa9e4066Sahrens 	avl_node_t	io_offset_node;
295fa9e4066Sahrens 	avl_node_t	io_deadline_node;
296fa9e4066Sahrens 	avl_tree_t	*io_vdev_tree;
297fa9e4066Sahrens 	zio_t		*io_delegate_list;
298fa9e4066Sahrens 	zio_t		*io_delegate_next;
299fa9e4066Sahrens 
300fa9e4066Sahrens 	/* Internal pipeline state */
301fa9e4066Sahrens 	int		io_flags;
302*e14bb325SJeff Bonwick 	zio_stage_t	io_stage;
303fa9e4066Sahrens 	uint32_t	io_pipeline;
304*e14bb325SJeff Bonwick 	int		io_orig_flags;
305*e14bb325SJeff Bonwick 	zio_stage_t	io_orig_stage;
3060a4e9518Sgw 	uint32_t	io_orig_pipeline;
307*e14bb325SJeff Bonwick 	int		io_error;
308*e14bb325SJeff Bonwick 	int		io_child_error[ZIO_CHILD_TYPES];
309*e14bb325SJeff Bonwick 	uint64_t	io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES];
310*e14bb325SJeff Bonwick 	uint64_t	*io_stall;
311*e14bb325SJeff Bonwick 	zio_gang_node_t	*io_gang_tree;
312*e14bb325SJeff Bonwick 	void		*io_executor;
313fa9e4066Sahrens 	void		*io_waiter;
314fa9e4066Sahrens 	kmutex_t	io_lock;
315fa9e4066Sahrens 	kcondvar_t	io_cv;
316ea8dc4b6Seschrock 
317ea8dc4b6Seschrock 	/* FMA state */
318ea8dc4b6Seschrock 	uint64_t	io_ena;
319fa9e4066Sahrens };
320fa9e4066Sahrens 
321fa9e4066Sahrens extern zio_t *zio_null(zio_t *pio, spa_t *spa,
322fa9e4066Sahrens     zio_done_func_t *done, void *private, int flags);
323fa9e4066Sahrens 
324fa9e4066Sahrens extern zio_t *zio_root(spa_t *spa,
325fa9e4066Sahrens     zio_done_func_t *done, void *private, int flags);
326fa9e4066Sahrens 
327088f3894Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data,
328fa9e4066Sahrens     uint64_t size, zio_done_func_t *done, void *private,
329088f3894Sahrens     int priority, int flags, const zbookmark_t *zb);
330fa9e4066Sahrens 
331*e14bb325SJeff Bonwick extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
332*e14bb325SJeff Bonwick     void *data, uint64_t size, zio_prop_t *zp,
333*e14bb325SJeff Bonwick     zio_done_func_t *ready, zio_done_func_t *done, void *private,
334*e14bb325SJeff Bonwick     int priority, int flags, const zbookmark_t *zb);
335fa9e4066Sahrens 
336*e14bb325SJeff Bonwick extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
337*e14bb325SJeff Bonwick     void *data, uint64_t size, zio_done_func_t *done, void *private,
338*e14bb325SJeff Bonwick     int priority, int flags, zbookmark_t *zb);
339fa9e4066Sahrens 
340fa9e4066Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
341*e14bb325SJeff Bonwick     zio_done_func_t *done, void *private, int flags);
342fa9e4066Sahrens 
343fa9e4066Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
344*e14bb325SJeff Bonwick     zio_done_func_t *done, void *private, int flags);
345fa9e4066Sahrens 
346fa9e4066Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
347fa9e4066Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
348fa9e4066Sahrens 
349fa9e4066Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
350fa9e4066Sahrens     uint64_t size, void *data, int checksum,
351fa94a07fSbrendan     zio_done_func_t *done, void *private, int priority, int flags,
352fa94a07fSbrendan     boolean_t labels);
353fa9e4066Sahrens 
354fa9e4066Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
355fa9e4066Sahrens     uint64_t size, void *data, int checksum,
356fa94a07fSbrendan     zio_done_func_t *done, void *private, int priority, int flags,
357fa94a07fSbrendan     boolean_t labels);
358fa9e4066Sahrens 
35967bd71c6Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp,
36067bd71c6Sperrin     blkptr_t *old_bp, uint64_t txg);
361fa9e4066Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
36217f17c2dSbonwick extern void zio_flush(zio_t *zio, vdev_t *vd);
363fa9e4066Sahrens 
364fa9e4066Sahrens extern int zio_wait(zio_t *zio);
365fa9e4066Sahrens extern void zio_nowait(zio_t *zio);
366e05725b1Sbonwick extern void zio_execute(zio_t *zio);
367e05725b1Sbonwick extern void zio_interrupt(zio_t *zio);
368e05725b1Sbonwick 
369fa9e4066Sahrens extern void *zio_buf_alloc(size_t size);
370fa9e4066Sahrens extern void zio_buf_free(void *buf, size_t size);
371ad23a2dbSjohansen extern void *zio_data_buf_alloc(size_t size);
372ad23a2dbSjohansen extern void zio_data_buf_free(void *buf, size_t size);
373fa9e4066Sahrens 
3740a4e9518Sgw extern void zio_resubmit_stage_async(void *);
375fa9e4066Sahrens 
376fa9e4066Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
377fa9e4066Sahrens     uint64_t offset, void *data, uint64_t size, int type, int priority,
378fa9e4066Sahrens     int flags, zio_done_func_t *done, void *private);
379fa9e4066Sahrens 
380*e14bb325SJeff Bonwick extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset,
381*e14bb325SJeff Bonwick     void *data, uint64_t size, int type, int priority,
382*e14bb325SJeff Bonwick     int flags, zio_done_func_t *done, void *private);
383*e14bb325SJeff Bonwick 
384fa9e4066Sahrens extern void zio_vdev_io_bypass(zio_t *zio);
385fa9e4066Sahrens extern void zio_vdev_io_reissue(zio_t *zio);
386fa9e4066Sahrens extern void zio_vdev_io_redone(zio_t *zio);
387fa9e4066Sahrens 
388fa9e4066Sahrens extern void zio_checksum_verified(zio_t *zio);
389*e14bb325SJeff Bonwick extern int zio_worst_error(int e1, int e2);
390fa9e4066Sahrens 
391fa9e4066Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
392fa9e4066Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
393fa9e4066Sahrens 
394*e14bb325SJeff Bonwick extern void zio_suspend(spa_t *spa, zio_t *zio);
395*e14bb325SJeff Bonwick extern void zio_resume(spa_t *spa);
396*e14bb325SJeff Bonwick extern void zio_resume_wait(spa_t *spa);
397ea8dc4b6Seschrock 
398fa9e4066Sahrens /*
399fa9e4066Sahrens  * Initial setup and teardown.
400fa9e4066Sahrens  */
401fa9e4066Sahrens extern void zio_init(void);
402fa9e4066Sahrens extern void zio_fini(void);
403fa9e4066Sahrens 
404ea8dc4b6Seschrock /*
405ea8dc4b6Seschrock  * Fault injection
406ea8dc4b6Seschrock  */
407ea8dc4b6Seschrock struct zinject_record;
408ea8dc4b6Seschrock extern uint32_t zio_injection_enabled;
409ea8dc4b6Seschrock extern int zio_inject_fault(char *name, int flags, int *id,
410ea8dc4b6Seschrock     struct zinject_record *record);
411ea8dc4b6Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen,
412ea8dc4b6Seschrock     struct zinject_record *record);
413ea8dc4b6Seschrock extern int zio_clear_fault(int id);
414ea8dc4b6Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error);
415ea8dc4b6Seschrock extern int zio_handle_device_injection(vdev_t *vd, int error);
41621bf64a7Sgw extern int zio_handle_label_injection(zio_t *zio, int error);
417ea8dc4b6Seschrock 
418fa9e4066Sahrens #ifdef	__cplusplus
419fa9e4066Sahrens }
420fa9e4066Sahrens #endif
421fa9e4066Sahrens 
422fa9e4066Sahrens #endif	/* _ZIO_H */
423