xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/zio.h (revision 9443)
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 /*
238632SBill.Moore@Sun.COM  * Copyright 2009 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 
1358241SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_SELF_HEAL		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 
1408241SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_PROBE			0x10000
1418241SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_GANG_CHILD		0x20000
1428274SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_RAW			0x40000
1439234SGeorge.Wilson@Sun.COM #define	ZIO_FLAG_GODFATHER		0x80000
1443689Sek110237 
145789Sahrens #define	ZIO_FLAG_GANG_INHERIT		\
146789Sahrens 	(ZIO_FLAG_CANFAIL |		\
1477754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SPECULATIVE |		\
1487754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_CONFIG_WRITER |	\
1497754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_RETRY |		\
1505530Sbonwick 	ZIO_FLAG_DONT_CACHE |		\
1517754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_AGGREGATE |	\
1528241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SELF_HEAL |		\
153789Sahrens 	ZIO_FLAG_RESILVER |		\
1541807Sbonwick 	ZIO_FLAG_SCRUB |		\
1557754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB_THREAD)
156789Sahrens 
157789Sahrens #define	ZIO_FLAG_VDEV_INHERIT		\
158789Sahrens 	(ZIO_FLAG_GANG_INHERIT |	\
1597754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_REPAIR |		\
1607754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_RETRY |		\
1617754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_PROBE)
1625688Sbonwick 
1638241SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_AGG_INHERIT		\
1648241SJeff.Bonwick@Sun.COM 	(ZIO_FLAG_DONT_AGGREGATE |	\
1658241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_REPAIR |		\
1668241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SELF_HEAL |		\
1678241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_RESILVER |		\
1688241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB |		\
1698241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB_THREAD)
1708241SJeff.Bonwick@Sun.COM 
1715530Sbonwick #define	ZIO_PIPELINE_CONTINUE		0x100
1725530Sbonwick #define	ZIO_PIPELINE_STOP		0x101
1735530Sbonwick 
1747754SJeff.Bonwick@Sun.COM #define	ZIO_GANG_CHILD_FLAGS(zio)				\
1757754SJeff.Bonwick@Sun.COM 	(((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) |		\
1767754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL)
1777754SJeff.Bonwick@Sun.COM 
1787754SJeff.Bonwick@Sun.COM enum zio_child {
1797754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_VDEV = 0,
1807754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_GANG,
1817754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_LOGICAL,
1827754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_TYPES
1837754SJeff.Bonwick@Sun.COM };
1847754SJeff.Bonwick@Sun.COM 
1857754SJeff.Bonwick@Sun.COM enum zio_wait_type {
1867754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_READY = 0,
1877754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_DONE,
1887754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_TYPES
1897754SJeff.Bonwick@Sun.COM };
1907754SJeff.Bonwick@Sun.COM 
191789Sahrens /*
1926423Sgw25295  * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent
1936423Sgw25295  * graveyard) to indicate checksum errors and fragmentation.
194789Sahrens  */
195789Sahrens #define	ECKSUM	EBADE
1966423Sgw25295 #define	EFRAGS	EBADR
197789Sahrens 
198789Sahrens typedef struct zio zio_t;
199789Sahrens typedef void zio_done_func_t(zio_t *zio);
200789Sahrens 
201789Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE];
202789Sahrens extern char *zio_type_name[ZIO_TYPES];
203789Sahrens 
2041544Seschrock /*
2051544Seschrock  * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
2061544Seschrock  * identifies any block in the pool.  By convention, the meta-objset (MOS)
2071544Seschrock  * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is
2081544Seschrock  * level -1 of the meta-dnode, and intent log blocks (which are chained
2091544Seschrock  * off the root block) have blkid == sequence number.  In summary:
2101544Seschrock  *
2111544Seschrock  *	mos is objset 0
2121544Seschrock  *	meta-dnode is object 0
2131544Seschrock  *	root block is <objset, 0, -1, 0>
2141544Seschrock  *	intent log is <objset, 0, -1, ZIL sequence number>
2151544Seschrock  *
2161544Seschrock  * Note: this structure is called a bookmark because its first purpose was
2171544Seschrock  * to remember where to resume a pool-wide traverse.  The absolute ordering
2181544Seschrock  * for block visitation during traversal is defined in compare_bookmark().
2191544Seschrock  *
2201544Seschrock  * Note: this structure is passed between userland and the kernel.
2211544Seschrock  * Therefore it must not change size or alignment between 32/64 bit
2221544Seschrock  * compilation options.
2231544Seschrock  */
2241544Seschrock typedef struct zbookmark {
2251544Seschrock 	uint64_t	zb_objset;
2261544Seschrock 	uint64_t	zb_object;
2271544Seschrock 	int64_t		zb_level;
2281544Seschrock 	uint64_t	zb_blkid;
2291544Seschrock } zbookmark_t;
2301544Seschrock 
2317754SJeff.Bonwick@Sun.COM typedef struct zio_prop {
2327754SJeff.Bonwick@Sun.COM 	enum zio_checksum	zp_checksum;
2337754SJeff.Bonwick@Sun.COM 	enum zio_compress	zp_compress;
2347754SJeff.Bonwick@Sun.COM 	dmu_object_type_t	zp_type;
2357754SJeff.Bonwick@Sun.COM 	uint8_t			zp_level;
2367754SJeff.Bonwick@Sun.COM 	uint8_t			zp_ndvas;
2377754SJeff.Bonwick@Sun.COM } zio_prop_t;
2387754SJeff.Bonwick@Sun.COM 
2397754SJeff.Bonwick@Sun.COM typedef struct zio_gang_node {
2407754SJeff.Bonwick@Sun.COM 	zio_gbh_phys_t		*gn_gbh;
2417754SJeff.Bonwick@Sun.COM 	struct zio_gang_node	*gn_child[SPA_GBH_NBLKPTRS];
2427754SJeff.Bonwick@Sun.COM } zio_gang_node_t;
2437754SJeff.Bonwick@Sun.COM 
2447754SJeff.Bonwick@Sun.COM typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp,
2457754SJeff.Bonwick@Sun.COM     zio_gang_node_t *gn, void *data);
2467754SJeff.Bonwick@Sun.COM 
2477754SJeff.Bonwick@Sun.COM typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size);
2487754SJeff.Bonwick@Sun.COM 
2497754SJeff.Bonwick@Sun.COM typedef struct zio_transform {
2507754SJeff.Bonwick@Sun.COM 	void			*zt_orig_data;
2517754SJeff.Bonwick@Sun.COM 	uint64_t		zt_orig_size;
2527754SJeff.Bonwick@Sun.COM 	uint64_t		zt_bufsize;
2537754SJeff.Bonwick@Sun.COM 	zio_transform_func_t	*zt_transform;
2547754SJeff.Bonwick@Sun.COM 	struct zio_transform	*zt_next;
2557754SJeff.Bonwick@Sun.COM } zio_transform_t;
2567754SJeff.Bonwick@Sun.COM 
2577754SJeff.Bonwick@Sun.COM typedef int zio_pipe_stage_t(zio_t *zio);
2587754SJeff.Bonwick@Sun.COM 
2597754SJeff.Bonwick@Sun.COM /*
2607754SJeff.Bonwick@Sun.COM  * The io_reexecute flags are distinct from io_flags because the child must
2617754SJeff.Bonwick@Sun.COM  * be able to propagate them to the parent.  The normal io_flags are local
2627754SJeff.Bonwick@Sun.COM  * to the zio, not protected by any lock, and not modifiable by children;
2637754SJeff.Bonwick@Sun.COM  * the reexecute flags are protected by io_lock, modifiable by children,
2647754SJeff.Bonwick@Sun.COM  * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set.
2657754SJeff.Bonwick@Sun.COM  */
2667754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_NOW	0x01
2677754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_SUSPEND	0x02
2687754SJeff.Bonwick@Sun.COM 
2698632SBill.Moore@Sun.COM typedef struct zio_link {
2708632SBill.Moore@Sun.COM 	zio_t		*zl_parent;
2718632SBill.Moore@Sun.COM 	zio_t		*zl_child;
2728632SBill.Moore@Sun.COM 	list_node_t	zl_parent_node;
2738632SBill.Moore@Sun.COM 	list_node_t	zl_child_node;
2748632SBill.Moore@Sun.COM } zio_link_t;
2758632SBill.Moore@Sun.COM 
276789Sahrens struct zio {
277789Sahrens 	/* Core information about this I/O */
2787754SJeff.Bonwick@Sun.COM 	zbookmark_t	io_bookmark;
2797754SJeff.Bonwick@Sun.COM 	zio_prop_t	io_prop;
2807754SJeff.Bonwick@Sun.COM 	zio_type_t	io_type;
2817754SJeff.Bonwick@Sun.COM 	enum zio_child	io_child_type;
2827754SJeff.Bonwick@Sun.COM 	int		io_cmd;
2837754SJeff.Bonwick@Sun.COM 	uint8_t		io_priority;
2847754SJeff.Bonwick@Sun.COM 	uint8_t		io_reexecute;
2858632SBill.Moore@Sun.COM 	uint8_t		io_state[ZIO_WAIT_TYPES];
2867754SJeff.Bonwick@Sun.COM 	uint64_t	io_txg;
287789Sahrens 	spa_t		*io_spa;
288789Sahrens 	blkptr_t	*io_bp;
289789Sahrens 	blkptr_t	io_bp_copy;
2908632SBill.Moore@Sun.COM 	list_t		io_parent_list;
2918632SBill.Moore@Sun.COM 	list_t		io_child_list;
2928632SBill.Moore@Sun.COM 	zio_link_t	*io_walk_link;
2937754SJeff.Bonwick@Sun.COM 	zio_t		*io_logical;
294789Sahrens 	zio_transform_t *io_transform_stack;
295789Sahrens 
296789Sahrens 	/* Callback info */
2973547Smaybee 	zio_done_func_t	*io_ready;
298789Sahrens 	zio_done_func_t	*io_done;
299789Sahrens 	void		*io_private;
300789Sahrens 	blkptr_t	io_bp_orig;
301789Sahrens 
302789Sahrens 	/* Data represented by this I/O */
303789Sahrens 	void		*io_data;
304789Sahrens 	uint64_t	io_size;
305789Sahrens 
306789Sahrens 	/* Stuff for the vdev stack */
307789Sahrens 	vdev_t		*io_vd;
308789Sahrens 	void		*io_vsd;
3097754SJeff.Bonwick@Sun.COM 	zio_done_func_t	*io_vsd_free;
310789Sahrens 	uint64_t	io_offset;
311789Sahrens 	uint64_t	io_deadline;
312789Sahrens 	avl_node_t	io_offset_node;
313789Sahrens 	avl_node_t	io_deadline_node;
314789Sahrens 	avl_tree_t	*io_vdev_tree;
315789Sahrens 
316789Sahrens 	/* Internal pipeline state */
317789Sahrens 	int		io_flags;
3187754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_stage;
3197754SJeff.Bonwick@Sun.COM 	uint32_t	io_pipeline;
3205329Sgw25295 	int		io_orig_flags;
3217754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_orig_stage;
3227754SJeff.Bonwick@Sun.COM 	uint32_t	io_orig_pipeline;
323789Sahrens 	int		io_error;
3247754SJeff.Bonwick@Sun.COM 	int		io_child_error[ZIO_CHILD_TYPES];
3257754SJeff.Bonwick@Sun.COM 	uint64_t	io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES];
3267754SJeff.Bonwick@Sun.COM 	uint64_t	*io_stall;
327*9443SBill.Moore@Sun.COM 	zio_t		*io_gang_leader;
3287754SJeff.Bonwick@Sun.COM 	zio_gang_node_t	*io_gang_tree;
3297754SJeff.Bonwick@Sun.COM 	void		*io_executor;
330789Sahrens 	void		*io_waiter;
331789Sahrens 	kmutex_t	io_lock;
332789Sahrens 	kcondvar_t	io_cv;
3331544Seschrock 
3341544Seschrock 	/* FMA state */
3351544Seschrock 	uint64_t	io_ena;
336789Sahrens };
337789Sahrens 
3388632SBill.Moore@Sun.COM extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd,
339789Sahrens     zio_done_func_t *done, void *private, int flags);
340789Sahrens 
341789Sahrens extern zio_t *zio_root(spa_t *spa,
342789Sahrens     zio_done_func_t *done, void *private, int flags);
343789Sahrens 
3447046Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data,
345789Sahrens     uint64_t size, zio_done_func_t *done, void *private,
3467046Sahrens     int priority, int flags, const zbookmark_t *zb);
347789Sahrens 
3487754SJeff.Bonwick@Sun.COM extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3497754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_prop_t *zp,
3507754SJeff.Bonwick@Sun.COM     zio_done_func_t *ready, zio_done_func_t *done, void *private,
3517754SJeff.Bonwick@Sun.COM     int priority, int flags, const zbookmark_t *zb);
352789Sahrens 
3537754SJeff.Bonwick@Sun.COM extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3547754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_done_func_t *done, void *private,
3557754SJeff.Bonwick@Sun.COM     int priority, int flags, zbookmark_t *zb);
356789Sahrens 
3577872STim.Haley@Sun.COM extern void zio_skip_write(zio_t *zio);
3587872STim.Haley@Sun.COM 
359789Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3607754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
361789Sahrens 
362789Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3637754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
364789Sahrens 
365789Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
366789Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
367789Sahrens 
368789Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
369789Sahrens     uint64_t size, void *data, int checksum,
3705450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
3715450Sbrendan     boolean_t labels);
372789Sahrens 
373789Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
374789Sahrens     uint64_t size, void *data, int checksum,
3755450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
3765450Sbrendan     boolean_t labels);
377789Sahrens 
3783063Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp,
3793063Sperrin     blkptr_t *old_bp, uint64_t txg);
380789Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
3815688Sbonwick extern void zio_flush(zio_t *zio, vdev_t *vd);
382789Sahrens 
383789Sahrens extern int zio_wait(zio_t *zio);
384789Sahrens extern void zio_nowait(zio_t *zio);
3855530Sbonwick extern void zio_execute(zio_t *zio);
3865530Sbonwick extern void zio_interrupt(zio_t *zio);
3875530Sbonwick 
3888632SBill.Moore@Sun.COM extern zio_t *zio_walk_parents(zio_t *cio);
3898632SBill.Moore@Sun.COM extern zio_t *zio_walk_children(zio_t *pio);
3908632SBill.Moore@Sun.COM extern zio_t *zio_unique_parent(zio_t *cio);
3918632SBill.Moore@Sun.COM extern void zio_add_child(zio_t *pio, zio_t *cio);
3928632SBill.Moore@Sun.COM 
393789Sahrens extern void *zio_buf_alloc(size_t size);
394789Sahrens extern void zio_buf_free(void *buf, size_t size);
3953290Sjohansen extern void *zio_data_buf_alloc(size_t size);
3963290Sjohansen extern void zio_data_buf_free(void *buf, size_t size);
397789Sahrens 
3985329Sgw25295 extern void zio_resubmit_stage_async(void *);
399789Sahrens 
400789Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
401789Sahrens     uint64_t offset, void *data, uint64_t size, int type, int priority,
402789Sahrens     int flags, zio_done_func_t *done, void *private);
403789Sahrens 
4047754SJeff.Bonwick@Sun.COM extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset,
4057754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, int type, int priority,
4067754SJeff.Bonwick@Sun.COM     int flags, zio_done_func_t *done, void *private);
4077754SJeff.Bonwick@Sun.COM 
408789Sahrens extern void zio_vdev_io_bypass(zio_t *zio);
409789Sahrens extern void zio_vdev_io_reissue(zio_t *zio);
410789Sahrens extern void zio_vdev_io_redone(zio_t *zio);
411789Sahrens 
412789Sahrens extern void zio_checksum_verified(zio_t *zio);
4137754SJeff.Bonwick@Sun.COM extern int zio_worst_error(int e1, int e2);
414789Sahrens 
415789Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
416789Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
417789Sahrens 
4187754SJeff.Bonwick@Sun.COM extern void zio_suspend(spa_t *spa, zio_t *zio);
4199234SGeorge.Wilson@Sun.COM extern int zio_resume(spa_t *spa);
4207754SJeff.Bonwick@Sun.COM extern void zio_resume_wait(spa_t *spa);
4211544Seschrock 
422789Sahrens /*
423789Sahrens  * Initial setup and teardown.
424789Sahrens  */
425789Sahrens extern void zio_init(void);
426789Sahrens extern void zio_fini(void);
427789Sahrens 
4281544Seschrock /*
4291544Seschrock  * Fault injection
4301544Seschrock  */
4311544Seschrock struct zinject_record;
4321544Seschrock extern uint32_t zio_injection_enabled;
4331544Seschrock extern int zio_inject_fault(char *name, int flags, int *id,
4341544Seschrock     struct zinject_record *record);
4351544Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen,
4361544Seschrock     struct zinject_record *record);
4371544Seschrock extern int zio_clear_fault(int id);
4381544Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error);
4391544Seschrock extern int zio_handle_device_injection(vdev_t *vd, int error);
4406615Sgw25295 extern int zio_handle_label_injection(zio_t *zio, int error);
4411544Seschrock 
442789Sahrens #ifdef	__cplusplus
443789Sahrens }
444789Sahrens #endif
445789Sahrens 
446789Sahrens #endif	/* _ZIO_H */
447