xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/zio.h (revision 7872)
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
1217754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SPECULATIVE		0x00002
1227754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_CONFIG_WRITER		0x00004
1237754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_DONT_RETRY		0x00008
1241544Seschrock 
1251544Seschrock #define	ZIO_FLAG_DONT_CACHE		0x00010
1261544Seschrock #define	ZIO_FLAG_DONT_QUEUE		0x00020
1277754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_DONT_AGGREGATE		0x00040
1287754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_DONT_PROPAGATE		0x00080
129789Sahrens 
1307754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_BYPASS		0x00100
1317754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_REPAIR		0x00200
1327754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_RETRY		0x00400
1337754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_IO_REWRITE		0x00800
134789Sahrens 
1357754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_PROBE			0x01000
1367754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_RESILVER		0x02000
1377754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SCRUB			0x04000
1387754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SCRUB_THREAD		0x08000
1397754SJeff.Bonwick@Sun.COM 
1407754SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_GANG_CHILD		0x10000
1413689Sek110237 
142789Sahrens #define	ZIO_FLAG_GANG_INHERIT		\
143789Sahrens 	(ZIO_FLAG_CANFAIL |		\
1447754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SPECULATIVE |		\
1457754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_CONFIG_WRITER |	\
1467754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_RETRY |		\
1475530Sbonwick 	ZIO_FLAG_DONT_CACHE |		\
1487754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_AGGREGATE |	\
149789Sahrens 	ZIO_FLAG_RESILVER |		\
1501807Sbonwick 	ZIO_FLAG_SCRUB |		\
1517754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB_THREAD)
152789Sahrens 
153789Sahrens #define	ZIO_FLAG_VDEV_INHERIT		\
154789Sahrens 	(ZIO_FLAG_GANG_INHERIT |	\
1557754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_REPAIR |		\
1567754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_RETRY |		\
1577754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_PROBE)
1585688Sbonwick 
1595530Sbonwick #define	ZIO_PIPELINE_CONTINUE		0x100
1605530Sbonwick #define	ZIO_PIPELINE_STOP		0x101
1615530Sbonwick 
1627754SJeff.Bonwick@Sun.COM #define	ZIO_GANG_CHILD_FLAGS(zio)				\
1637754SJeff.Bonwick@Sun.COM 	(((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) |		\
1647754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL)
1657754SJeff.Bonwick@Sun.COM 
1667754SJeff.Bonwick@Sun.COM enum zio_child {
1677754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_VDEV = 0,
1687754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_GANG,
1697754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_LOGICAL,
1707754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_TYPES
1717754SJeff.Bonwick@Sun.COM };
1727754SJeff.Bonwick@Sun.COM 
1737754SJeff.Bonwick@Sun.COM enum zio_wait_type {
1747754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_READY = 0,
1757754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_DONE,
1767754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_TYPES
1777754SJeff.Bonwick@Sun.COM };
1787754SJeff.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 
2197754SJeff.Bonwick@Sun.COM typedef struct zio_prop {
2207754SJeff.Bonwick@Sun.COM 	enum zio_checksum	zp_checksum;
2217754SJeff.Bonwick@Sun.COM 	enum zio_compress	zp_compress;
2227754SJeff.Bonwick@Sun.COM 	dmu_object_type_t	zp_type;
2237754SJeff.Bonwick@Sun.COM 	uint8_t			zp_level;
2247754SJeff.Bonwick@Sun.COM 	uint8_t			zp_ndvas;
2257754SJeff.Bonwick@Sun.COM } zio_prop_t;
2267754SJeff.Bonwick@Sun.COM 
2277754SJeff.Bonwick@Sun.COM typedef struct zio_gang_node {
2287754SJeff.Bonwick@Sun.COM 	zio_gbh_phys_t		*gn_gbh;
2297754SJeff.Bonwick@Sun.COM 	struct zio_gang_node	*gn_child[SPA_GBH_NBLKPTRS];
2307754SJeff.Bonwick@Sun.COM } zio_gang_node_t;
2317754SJeff.Bonwick@Sun.COM 
2327754SJeff.Bonwick@Sun.COM typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp,
2337754SJeff.Bonwick@Sun.COM     zio_gang_node_t *gn, void *data);
2347754SJeff.Bonwick@Sun.COM 
2357754SJeff.Bonwick@Sun.COM typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size);
2367754SJeff.Bonwick@Sun.COM 
2377754SJeff.Bonwick@Sun.COM typedef struct zio_transform {
2387754SJeff.Bonwick@Sun.COM 	void			*zt_orig_data;
2397754SJeff.Bonwick@Sun.COM 	uint64_t		zt_orig_size;
2407754SJeff.Bonwick@Sun.COM 	uint64_t		zt_bufsize;
2417754SJeff.Bonwick@Sun.COM 	zio_transform_func_t	*zt_transform;
2427754SJeff.Bonwick@Sun.COM 	struct zio_transform	*zt_next;
2437754SJeff.Bonwick@Sun.COM } zio_transform_t;
2447754SJeff.Bonwick@Sun.COM 
2457754SJeff.Bonwick@Sun.COM typedef int zio_pipe_stage_t(zio_t *zio);
2467754SJeff.Bonwick@Sun.COM 
2477754SJeff.Bonwick@Sun.COM /*
2487754SJeff.Bonwick@Sun.COM  * The io_reexecute flags are distinct from io_flags because the child must
2497754SJeff.Bonwick@Sun.COM  * be able to propagate them to the parent.  The normal io_flags are local
2507754SJeff.Bonwick@Sun.COM  * to the zio, not protected by any lock, and not modifiable by children;
2517754SJeff.Bonwick@Sun.COM  * the reexecute flags are protected by io_lock, modifiable by children,
2527754SJeff.Bonwick@Sun.COM  * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set.
2537754SJeff.Bonwick@Sun.COM  */
2547754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_NOW	0x01
2557754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_SUSPEND	0x02
2567754SJeff.Bonwick@Sun.COM 
257789Sahrens struct zio {
258789Sahrens 	/* Core information about this I/O */
2597754SJeff.Bonwick@Sun.COM 	zbookmark_t	io_bookmark;
2607754SJeff.Bonwick@Sun.COM 	zio_prop_t	io_prop;
2617754SJeff.Bonwick@Sun.COM 	zio_type_t	io_type;
2627754SJeff.Bonwick@Sun.COM 	enum zio_child	io_child_type;
2637754SJeff.Bonwick@Sun.COM 	int		io_cmd;
2647754SJeff.Bonwick@Sun.COM 	uint8_t		io_priority;
2657754SJeff.Bonwick@Sun.COM 	uint8_t		io_reexecute;
2667754SJeff.Bonwick@Sun.COM 	uint8_t		io_async_root;
2677754SJeff.Bonwick@Sun.COM 	uint64_t	io_txg;
268789Sahrens 	spa_t		*io_spa;
269789Sahrens 	blkptr_t	*io_bp;
270789Sahrens 	blkptr_t	io_bp_copy;
2717754SJeff.Bonwick@Sun.COM 	zio_t		*io_parent;
272789Sahrens 	zio_t		*io_child;
273789Sahrens 	zio_t		*io_sibling_prev;
274789Sahrens 	zio_t		*io_sibling_next;
2757754SJeff.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;
2917754SJeff.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;
3027754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_stage;
3037754SJeff.Bonwick@Sun.COM 	uint32_t	io_pipeline;
3045329Sgw25295 	int		io_orig_flags;
3057754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_orig_stage;
3067754SJeff.Bonwick@Sun.COM 	uint32_t	io_orig_pipeline;
307789Sahrens 	int		io_error;
3087754SJeff.Bonwick@Sun.COM 	int		io_child_error[ZIO_CHILD_TYPES];
3097754SJeff.Bonwick@Sun.COM 	uint64_t	io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES];
3107754SJeff.Bonwick@Sun.COM 	uint64_t	*io_stall;
3117754SJeff.Bonwick@Sun.COM 	zio_gang_node_t	*io_gang_tree;
3127754SJeff.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 
3317754SJeff.Bonwick@Sun.COM extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3327754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_prop_t *zp,
3337754SJeff.Bonwick@Sun.COM     zio_done_func_t *ready, zio_done_func_t *done, void *private,
3347754SJeff.Bonwick@Sun.COM     int priority, int flags, const zbookmark_t *zb);
335789Sahrens 
3367754SJeff.Bonwick@Sun.COM extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3377754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_done_func_t *done, void *private,
3387754SJeff.Bonwick@Sun.COM     int priority, int flags, zbookmark_t *zb);
339789Sahrens 
340*7872STim.Haley@Sun.COM extern void zio_skip_write(zio_t *zio);
341*7872STim.Haley@Sun.COM 
342789Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3437754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
344789Sahrens 
345789Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3467754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
347789Sahrens 
348789Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
349789Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
350789Sahrens 
351789Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
352789Sahrens     uint64_t size, void *data, int checksum,
3535450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
3545450Sbrendan     boolean_t labels);
355789Sahrens 
356789Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
357789Sahrens     uint64_t size, void *data, int checksum,
3585450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
3595450Sbrendan     boolean_t labels);
360789Sahrens 
3613063Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp,
3623063Sperrin     blkptr_t *old_bp, uint64_t txg);
363789Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
3645688Sbonwick extern void zio_flush(zio_t *zio, vdev_t *vd);
365789Sahrens 
366789Sahrens extern int zio_wait(zio_t *zio);
367789Sahrens extern void zio_nowait(zio_t *zio);
3685530Sbonwick extern void zio_execute(zio_t *zio);
3695530Sbonwick extern void zio_interrupt(zio_t *zio);
3705530Sbonwick 
371789Sahrens extern void *zio_buf_alloc(size_t size);
372789Sahrens extern void zio_buf_free(void *buf, size_t size);
3733290Sjohansen extern void *zio_data_buf_alloc(size_t size);
3743290Sjohansen extern void zio_data_buf_free(void *buf, size_t size);
375789Sahrens 
3765329Sgw25295 extern void zio_resubmit_stage_async(void *);
377789Sahrens 
378789Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
379789Sahrens     uint64_t offset, void *data, uint64_t size, int type, int priority,
380789Sahrens     int flags, zio_done_func_t *done, void *private);
381789Sahrens 
3827754SJeff.Bonwick@Sun.COM extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset,
3837754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, int type, int priority,
3847754SJeff.Bonwick@Sun.COM     int flags, zio_done_func_t *done, void *private);
3857754SJeff.Bonwick@Sun.COM 
386789Sahrens extern void zio_vdev_io_bypass(zio_t *zio);
387789Sahrens extern void zio_vdev_io_reissue(zio_t *zio);
388789Sahrens extern void zio_vdev_io_redone(zio_t *zio);
389789Sahrens 
390789Sahrens extern void zio_checksum_verified(zio_t *zio);
3917754SJeff.Bonwick@Sun.COM extern int zio_worst_error(int e1, int e2);
392789Sahrens 
393789Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
394789Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
395789Sahrens 
3967754SJeff.Bonwick@Sun.COM extern void zio_suspend(spa_t *spa, zio_t *zio);
3977754SJeff.Bonwick@Sun.COM extern void zio_resume(spa_t *spa);
3987754SJeff.Bonwick@Sun.COM extern void zio_resume_wait(spa_t *spa);
3991544Seschrock 
400789Sahrens /*
401789Sahrens  * Initial setup and teardown.
402789Sahrens  */
403789Sahrens extern void zio_init(void);
404789Sahrens extern void zio_fini(void);
405789Sahrens 
4061544Seschrock /*
4071544Seschrock  * Fault injection
4081544Seschrock  */
4091544Seschrock struct zinject_record;
4101544Seschrock extern uint32_t zio_injection_enabled;
4111544Seschrock extern int zio_inject_fault(char *name, int flags, int *id,
4121544Seschrock     struct zinject_record *record);
4131544Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen,
4141544Seschrock     struct zinject_record *record);
4151544Seschrock extern int zio_clear_fault(int id);
4161544Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error);
4171544Seschrock extern int zio_handle_device_injection(vdev_t *vd, int error);
4186615Sgw25295 extern int zio_handle_label_injection(zio_t *zio, int error);
4191544Seschrock 
420789Sahrens #ifdef	__cplusplus
421789Sahrens }
422789Sahrens #endif
423789Sahrens 
424789Sahrens #endif	/* _ZIO_H */
425