xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/zio.h (revision 10921)
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 
799454SJonathan.Adams@Sun.COM #define	ZIO_CHECKSUM_ON_VALUE	ZIO_CHECKSUM_FLETCHER_4
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 
1199725SEric.Schrock@Sun.COM #define	ZIO_FLAG_MUSTSUCCEED		0x000000
1209725SEric.Schrock@Sun.COM #define	ZIO_FLAG_CANFAIL		0x000001
1219725SEric.Schrock@Sun.COM #define	ZIO_FLAG_SPECULATIVE		0x000002
1229725SEric.Schrock@Sun.COM #define	ZIO_FLAG_CONFIG_WRITER		0x000004
1239725SEric.Schrock@Sun.COM #define	ZIO_FLAG_DONT_RETRY		0x000008
1241544Seschrock 
1259725SEric.Schrock@Sun.COM #define	ZIO_FLAG_DONT_CACHE		0x000010
1269725SEric.Schrock@Sun.COM #define	ZIO_FLAG_DONT_QUEUE		0x000020
1279725SEric.Schrock@Sun.COM #define	ZIO_FLAG_DONT_AGGREGATE		0x000040
1289725SEric.Schrock@Sun.COM #define	ZIO_FLAG_DONT_PROPAGATE		0x000080
129789Sahrens 
1309725SEric.Schrock@Sun.COM #define	ZIO_FLAG_IO_BYPASS		0x000100
1319725SEric.Schrock@Sun.COM #define	ZIO_FLAG_IO_REPAIR		0x000200
1329725SEric.Schrock@Sun.COM #define	ZIO_FLAG_IO_RETRY		0x000400
1339725SEric.Schrock@Sun.COM #define	ZIO_FLAG_IO_REWRITE		0x000800
134789Sahrens 
1359725SEric.Schrock@Sun.COM #define	ZIO_FLAG_SELF_HEAL		0x001000
1369725SEric.Schrock@Sun.COM #define	ZIO_FLAG_RESILVER		0x002000
1379725SEric.Schrock@Sun.COM #define	ZIO_FLAG_SCRUB			0x004000
1389725SEric.Schrock@Sun.COM #define	ZIO_FLAG_SCRUB_THREAD		0x008000
1397754SJeff.Bonwick@Sun.COM 
1409725SEric.Schrock@Sun.COM #define	ZIO_FLAG_PROBE			0x010000
1419725SEric.Schrock@Sun.COM #define	ZIO_FLAG_GANG_CHILD		0x020000
1429725SEric.Schrock@Sun.COM #define	ZIO_FLAG_RAW			0x040000
1439725SEric.Schrock@Sun.COM #define	ZIO_FLAG_GODFATHER		0x080000
1449725SEric.Schrock@Sun.COM 
1459725SEric.Schrock@Sun.COM #define	ZIO_FLAG_TRYHARD		0x100000
14610105Sadam.leventhal@sun.com #define	ZIO_FLAG_NODATA			0x200000
14710105Sadam.leventhal@sun.com #define	ZIO_FLAG_OPTIONAL		0x400000
1483689Sek110237 
149789Sahrens #define	ZIO_FLAG_GANG_INHERIT		\
150789Sahrens 	(ZIO_FLAG_CANFAIL |		\
1517754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SPECULATIVE |		\
1527754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_CONFIG_WRITER |	\
1537754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_RETRY |		\
1545530Sbonwick 	ZIO_FLAG_DONT_CACHE |		\
1557754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_DONT_AGGREGATE |	\
1568241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SELF_HEAL |		\
157789Sahrens 	ZIO_FLAG_RESILVER |		\
1581807Sbonwick 	ZIO_FLAG_SCRUB |		\
1597754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB_THREAD)
160789Sahrens 
161789Sahrens #define	ZIO_FLAG_VDEV_INHERIT		\
162789Sahrens 	(ZIO_FLAG_GANG_INHERIT |	\
1637754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_REPAIR |		\
1647754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_RETRY |		\
1659725SEric.Schrock@Sun.COM 	ZIO_FLAG_PROBE |		\
16610105Sadam.leventhal@sun.com 	ZIO_FLAG_TRYHARD |		\
16710105Sadam.leventhal@sun.com 	ZIO_FLAG_NODATA |		\
16810105Sadam.leventhal@sun.com 	ZIO_FLAG_OPTIONAL)
1695688Sbonwick 
1708241SJeff.Bonwick@Sun.COM #define	ZIO_FLAG_AGG_INHERIT		\
1718241SJeff.Bonwick@Sun.COM 	(ZIO_FLAG_DONT_AGGREGATE |	\
1728241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_IO_REPAIR |		\
1738241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SELF_HEAL |		\
1748241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_RESILVER |		\
1758241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB |		\
1768241SJeff.Bonwick@Sun.COM 	ZIO_FLAG_SCRUB_THREAD)
1778241SJeff.Bonwick@Sun.COM 
1785530Sbonwick #define	ZIO_PIPELINE_CONTINUE		0x100
1795530Sbonwick #define	ZIO_PIPELINE_STOP		0x101
1805530Sbonwick 
1817754SJeff.Bonwick@Sun.COM #define	ZIO_GANG_CHILD_FLAGS(zio)				\
1827754SJeff.Bonwick@Sun.COM 	(((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) |		\
1837754SJeff.Bonwick@Sun.COM 	ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL)
1847754SJeff.Bonwick@Sun.COM 
1857754SJeff.Bonwick@Sun.COM enum zio_child {
1867754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_VDEV = 0,
1877754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_GANG,
1887754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_LOGICAL,
1897754SJeff.Bonwick@Sun.COM 	ZIO_CHILD_TYPES
1907754SJeff.Bonwick@Sun.COM };
1917754SJeff.Bonwick@Sun.COM 
1927754SJeff.Bonwick@Sun.COM enum zio_wait_type {
1937754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_READY = 0,
1947754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_DONE,
1957754SJeff.Bonwick@Sun.COM 	ZIO_WAIT_TYPES
1967754SJeff.Bonwick@Sun.COM };
1977754SJeff.Bonwick@Sun.COM 
198789Sahrens /*
1996423Sgw25295  * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent
2006423Sgw25295  * graveyard) to indicate checksum errors and fragmentation.
201789Sahrens  */
202789Sahrens #define	ECKSUM	EBADE
2036423Sgw25295 #define	EFRAGS	EBADR
204789Sahrens 
205789Sahrens typedef struct zio zio_t;
206789Sahrens typedef void zio_done_func_t(zio_t *zio);
207789Sahrens 
208789Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE];
209789Sahrens extern char *zio_type_name[ZIO_TYPES];
210789Sahrens 
2111544Seschrock /*
2121544Seschrock  * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely
2131544Seschrock  * identifies any block in the pool.  By convention, the meta-objset (MOS)
2141544Seschrock  * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is
2151544Seschrock  * level -1 of the meta-dnode, and intent log blocks (which are chained
2161544Seschrock  * off the root block) have blkid == sequence number.  In summary:
2171544Seschrock  *
2181544Seschrock  *	mos is objset 0
2191544Seschrock  *	meta-dnode is object 0
2201544Seschrock  *	root block is <objset, 0, -1, 0>
2211544Seschrock  *	intent log is <objset, 0, -1, ZIL sequence number>
2221544Seschrock  *
2231544Seschrock  * Note: this structure is called a bookmark because its first purpose was
2241544Seschrock  * to remember where to resume a pool-wide traverse.  The absolute ordering
2251544Seschrock  * for block visitation during traversal is defined in compare_bookmark().
2261544Seschrock  *
2271544Seschrock  * Note: this structure is passed between userland and the kernel.
2281544Seschrock  * Therefore it must not change size or alignment between 32/64 bit
2291544Seschrock  * compilation options.
2301544Seschrock  */
2311544Seschrock typedef struct zbookmark {
2321544Seschrock 	uint64_t	zb_objset;
2331544Seschrock 	uint64_t	zb_object;
2341544Seschrock 	int64_t		zb_level;
2351544Seschrock 	uint64_t	zb_blkid;
2361544Seschrock } zbookmark_t;
2371544Seschrock 
2387754SJeff.Bonwick@Sun.COM typedef struct zio_prop {
2397754SJeff.Bonwick@Sun.COM 	enum zio_checksum	zp_checksum;
2407754SJeff.Bonwick@Sun.COM 	enum zio_compress	zp_compress;
2417754SJeff.Bonwick@Sun.COM 	dmu_object_type_t	zp_type;
2427754SJeff.Bonwick@Sun.COM 	uint8_t			zp_level;
2437754SJeff.Bonwick@Sun.COM 	uint8_t			zp_ndvas;
2447754SJeff.Bonwick@Sun.COM } zio_prop_t;
2457754SJeff.Bonwick@Sun.COM 
24610614SJonathan.Adams@Sun.COM typedef struct zio_cksum_report zio_cksum_report_t;
24710614SJonathan.Adams@Sun.COM 
24810614SJonathan.Adams@Sun.COM typedef void zio_cksum_finish_f(zio_cksum_report_t *rep,
24910614SJonathan.Adams@Sun.COM     const void *good_data);
25010614SJonathan.Adams@Sun.COM typedef void zio_cksum_free_f(void *cbdata, size_t size);
25110614SJonathan.Adams@Sun.COM 
25210614SJonathan.Adams@Sun.COM struct zio_bad_cksum;				/* defined in zio_checksum.h */
25310614SJonathan.Adams@Sun.COM 
25410614SJonathan.Adams@Sun.COM struct zio_cksum_report {
25510614SJonathan.Adams@Sun.COM 	struct zio_cksum_report *zcr_next;
25610614SJonathan.Adams@Sun.COM 	nvlist_t		*zcr_ereport;
25710614SJonathan.Adams@Sun.COM 	nvlist_t		*zcr_detector;
25810614SJonathan.Adams@Sun.COM 
25910614SJonathan.Adams@Sun.COM 	void			*zcr_cbdata;
26010614SJonathan.Adams@Sun.COM 	size_t			zcr_cbinfo;	/* passed to zcr_free() */
26110614SJonathan.Adams@Sun.COM 	uint64_t		zcr_length;
26210614SJonathan.Adams@Sun.COM 	zio_cksum_finish_f	*zcr_finish;
26310614SJonathan.Adams@Sun.COM 	zio_cksum_free_f	*zcr_free;
26410614SJonathan.Adams@Sun.COM 
26510614SJonathan.Adams@Sun.COM 	/* internal use only */
26610614SJonathan.Adams@Sun.COM 	struct zio_bad_cksum	*zcr_ckinfo;	/* information from failure */
26710614SJonathan.Adams@Sun.COM };
26810614SJonathan.Adams@Sun.COM 
26910614SJonathan.Adams@Sun.COM typedef void zio_vsd_cksum_report_f(zio_t *zio, zio_cksum_report_t *zcr,
27010614SJonathan.Adams@Sun.COM     void *arg);
27110614SJonathan.Adams@Sun.COM 
27210614SJonathan.Adams@Sun.COM zio_vsd_cksum_report_f	zio_vsd_default_cksum_report;
27310614SJonathan.Adams@Sun.COM 
27410614SJonathan.Adams@Sun.COM typedef struct zio_vsd_ops {
27510614SJonathan.Adams@Sun.COM 	zio_done_func_t		*vsd_free;
27610614SJonathan.Adams@Sun.COM 	zio_vsd_cksum_report_f	*vsd_cksum_report;
27710614SJonathan.Adams@Sun.COM } zio_vsd_ops_t;
27810614SJonathan.Adams@Sun.COM 
2797754SJeff.Bonwick@Sun.COM typedef struct zio_gang_node {
2807754SJeff.Bonwick@Sun.COM 	zio_gbh_phys_t		*gn_gbh;
2817754SJeff.Bonwick@Sun.COM 	struct zio_gang_node	*gn_child[SPA_GBH_NBLKPTRS];
2827754SJeff.Bonwick@Sun.COM } zio_gang_node_t;
2837754SJeff.Bonwick@Sun.COM 
2847754SJeff.Bonwick@Sun.COM typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp,
2857754SJeff.Bonwick@Sun.COM     zio_gang_node_t *gn, void *data);
2867754SJeff.Bonwick@Sun.COM 
2877754SJeff.Bonwick@Sun.COM typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size);
2887754SJeff.Bonwick@Sun.COM 
2897754SJeff.Bonwick@Sun.COM typedef struct zio_transform {
2907754SJeff.Bonwick@Sun.COM 	void			*zt_orig_data;
2917754SJeff.Bonwick@Sun.COM 	uint64_t		zt_orig_size;
2927754SJeff.Bonwick@Sun.COM 	uint64_t		zt_bufsize;
2937754SJeff.Bonwick@Sun.COM 	zio_transform_func_t	*zt_transform;
2947754SJeff.Bonwick@Sun.COM 	struct zio_transform	*zt_next;
2957754SJeff.Bonwick@Sun.COM } zio_transform_t;
2967754SJeff.Bonwick@Sun.COM 
2977754SJeff.Bonwick@Sun.COM typedef int zio_pipe_stage_t(zio_t *zio);
2987754SJeff.Bonwick@Sun.COM 
2997754SJeff.Bonwick@Sun.COM /*
3007754SJeff.Bonwick@Sun.COM  * The io_reexecute flags are distinct from io_flags because the child must
3017754SJeff.Bonwick@Sun.COM  * be able to propagate them to the parent.  The normal io_flags are local
3027754SJeff.Bonwick@Sun.COM  * to the zio, not protected by any lock, and not modifiable by children;
3037754SJeff.Bonwick@Sun.COM  * the reexecute flags are protected by io_lock, modifiable by children,
3047754SJeff.Bonwick@Sun.COM  * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set.
3057754SJeff.Bonwick@Sun.COM  */
3067754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_NOW	0x01
3077754SJeff.Bonwick@Sun.COM #define	ZIO_REEXECUTE_SUSPEND	0x02
3087754SJeff.Bonwick@Sun.COM 
3098632SBill.Moore@Sun.COM typedef struct zio_link {
3108632SBill.Moore@Sun.COM 	zio_t		*zl_parent;
3118632SBill.Moore@Sun.COM 	zio_t		*zl_child;
3128632SBill.Moore@Sun.COM 	list_node_t	zl_parent_node;
3138632SBill.Moore@Sun.COM 	list_node_t	zl_child_node;
3148632SBill.Moore@Sun.COM } zio_link_t;
3158632SBill.Moore@Sun.COM 
316789Sahrens struct zio {
317789Sahrens 	/* Core information about this I/O */
3187754SJeff.Bonwick@Sun.COM 	zbookmark_t	io_bookmark;
3197754SJeff.Bonwick@Sun.COM 	zio_prop_t	io_prop;
3207754SJeff.Bonwick@Sun.COM 	zio_type_t	io_type;
3217754SJeff.Bonwick@Sun.COM 	enum zio_child	io_child_type;
3227754SJeff.Bonwick@Sun.COM 	int		io_cmd;
3237754SJeff.Bonwick@Sun.COM 	uint8_t		io_priority;
3247754SJeff.Bonwick@Sun.COM 	uint8_t		io_reexecute;
3258632SBill.Moore@Sun.COM 	uint8_t		io_state[ZIO_WAIT_TYPES];
3267754SJeff.Bonwick@Sun.COM 	uint64_t	io_txg;
327789Sahrens 	spa_t		*io_spa;
328789Sahrens 	blkptr_t	*io_bp;
329789Sahrens 	blkptr_t	io_bp_copy;
3308632SBill.Moore@Sun.COM 	list_t		io_parent_list;
3318632SBill.Moore@Sun.COM 	list_t		io_child_list;
3328632SBill.Moore@Sun.COM 	zio_link_t	*io_walk_link;
3337754SJeff.Bonwick@Sun.COM 	zio_t		*io_logical;
334789Sahrens 	zio_transform_t *io_transform_stack;
335789Sahrens 
336789Sahrens 	/* Callback info */
3373547Smaybee 	zio_done_func_t	*io_ready;
338789Sahrens 	zio_done_func_t	*io_done;
339789Sahrens 	void		*io_private;
340789Sahrens 	blkptr_t	io_bp_orig;
341789Sahrens 
342789Sahrens 	/* Data represented by this I/O */
343789Sahrens 	void		*io_data;
344789Sahrens 	uint64_t	io_size;
345789Sahrens 
346789Sahrens 	/* Stuff for the vdev stack */
347789Sahrens 	vdev_t		*io_vd;
348789Sahrens 	void		*io_vsd;
34910614SJonathan.Adams@Sun.COM 	const zio_vsd_ops_t *io_vsd_ops;
35010614SJonathan.Adams@Sun.COM 
351789Sahrens 	uint64_t	io_offset;
352789Sahrens 	uint64_t	io_deadline;
353789Sahrens 	avl_node_t	io_offset_node;
354789Sahrens 	avl_node_t	io_deadline_node;
355789Sahrens 	avl_tree_t	*io_vdev_tree;
356789Sahrens 
357789Sahrens 	/* Internal pipeline state */
358789Sahrens 	int		io_flags;
3597754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_stage;
3607754SJeff.Bonwick@Sun.COM 	uint32_t	io_pipeline;
3615329Sgw25295 	int		io_orig_flags;
3627754SJeff.Bonwick@Sun.COM 	zio_stage_t	io_orig_stage;
3637754SJeff.Bonwick@Sun.COM 	uint32_t	io_orig_pipeline;
364789Sahrens 	int		io_error;
3657754SJeff.Bonwick@Sun.COM 	int		io_child_error[ZIO_CHILD_TYPES];
3667754SJeff.Bonwick@Sun.COM 	uint64_t	io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES];
3677754SJeff.Bonwick@Sun.COM 	uint64_t	*io_stall;
3689443SBill.Moore@Sun.COM 	zio_t		*io_gang_leader;
3697754SJeff.Bonwick@Sun.COM 	zio_gang_node_t	*io_gang_tree;
3707754SJeff.Bonwick@Sun.COM 	void		*io_executor;
371789Sahrens 	void		*io_waiter;
372789Sahrens 	kmutex_t	io_lock;
373789Sahrens 	kcondvar_t	io_cv;
3741544Seschrock 
3751544Seschrock 	/* FMA state */
37610614SJonathan.Adams@Sun.COM 	zio_cksum_report_t *io_cksum_report;
3771544Seschrock 	uint64_t	io_ena;
378789Sahrens };
379789Sahrens 
3808632SBill.Moore@Sun.COM extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd,
381789Sahrens     zio_done_func_t *done, void *private, int flags);
382789Sahrens 
383789Sahrens extern zio_t *zio_root(spa_t *spa,
384789Sahrens     zio_done_func_t *done, void *private, int flags);
385789Sahrens 
3867046Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data,
387789Sahrens     uint64_t size, zio_done_func_t *done, void *private,
3887046Sahrens     int priority, int flags, const zbookmark_t *zb);
389789Sahrens 
3907754SJeff.Bonwick@Sun.COM extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3917754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_prop_t *zp,
3927754SJeff.Bonwick@Sun.COM     zio_done_func_t *ready, zio_done_func_t *done, void *private,
3937754SJeff.Bonwick@Sun.COM     int priority, int flags, const zbookmark_t *zb);
394789Sahrens 
3957754SJeff.Bonwick@Sun.COM extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
3967754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, zio_done_func_t *done, void *private,
3977754SJeff.Bonwick@Sun.COM     int priority, int flags, zbookmark_t *zb);
398789Sahrens 
3997872STim.Haley@Sun.COM extern void zio_skip_write(zio_t *zio);
4007872STim.Haley@Sun.COM 
401789Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
4027754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
403789Sahrens 
404789Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
4057754SJeff.Bonwick@Sun.COM     zio_done_func_t *done, void *private, int flags);
406789Sahrens 
407789Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
408789Sahrens     zio_done_func_t *done, void *private, int priority, int flags);
409789Sahrens 
410789Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
411789Sahrens     uint64_t size, void *data, int checksum,
4125450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
4135450Sbrendan     boolean_t labels);
414789Sahrens 
415789Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
416789Sahrens     uint64_t size, void *data, int checksum,
4175450Sbrendan     zio_done_func_t *done, void *private, int priority, int flags,
4185450Sbrendan     boolean_t labels);
419789Sahrens 
4203063Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp,
42110879SNeil.Perrin@Sun.COM     blkptr_t *old_bp, uint64_t txg, boolean_t use_slog);
422789Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg);
4235688Sbonwick extern void zio_flush(zio_t *zio, vdev_t *vd);
424789Sahrens 
425789Sahrens extern int zio_wait(zio_t *zio);
426789Sahrens extern void zio_nowait(zio_t *zio);
4275530Sbonwick extern void zio_execute(zio_t *zio);
4285530Sbonwick extern void zio_interrupt(zio_t *zio);
4295530Sbonwick 
4308632SBill.Moore@Sun.COM extern zio_t *zio_walk_parents(zio_t *cio);
4318632SBill.Moore@Sun.COM extern zio_t *zio_walk_children(zio_t *pio);
4328632SBill.Moore@Sun.COM extern zio_t *zio_unique_parent(zio_t *cio);
4338632SBill.Moore@Sun.COM extern void zio_add_child(zio_t *pio, zio_t *cio);
4348632SBill.Moore@Sun.COM 
435789Sahrens extern void *zio_buf_alloc(size_t size);
436789Sahrens extern void zio_buf_free(void *buf, size_t size);
4373290Sjohansen extern void *zio_data_buf_alloc(size_t size);
4383290Sjohansen extern void zio_data_buf_free(void *buf, size_t size);
439789Sahrens 
4405329Sgw25295 extern void zio_resubmit_stage_async(void *);
441789Sahrens 
442789Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
443789Sahrens     uint64_t offset, void *data, uint64_t size, int type, int priority,
444789Sahrens     int flags, zio_done_func_t *done, void *private);
445789Sahrens 
4467754SJeff.Bonwick@Sun.COM extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset,
4477754SJeff.Bonwick@Sun.COM     void *data, uint64_t size, int type, int priority,
4487754SJeff.Bonwick@Sun.COM     int flags, zio_done_func_t *done, void *private);
4497754SJeff.Bonwick@Sun.COM 
450789Sahrens extern void zio_vdev_io_bypass(zio_t *zio);
451789Sahrens extern void zio_vdev_io_reissue(zio_t *zio);
452789Sahrens extern void zio_vdev_io_redone(zio_t *zio);
453789Sahrens 
454789Sahrens extern void zio_checksum_verified(zio_t *zio);
4557754SJeff.Bonwick@Sun.COM extern int zio_worst_error(int e1, int e2);
456789Sahrens 
457789Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent);
458789Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent);
459789Sahrens 
4607754SJeff.Bonwick@Sun.COM extern void zio_suspend(spa_t *spa, zio_t *zio);
4619234SGeorge.Wilson@Sun.COM extern int zio_resume(spa_t *spa);
4627754SJeff.Bonwick@Sun.COM extern void zio_resume_wait(spa_t *spa);
4631544Seschrock 
464789Sahrens /*
465789Sahrens  * Initial setup and teardown.
466789Sahrens  */
467789Sahrens extern void zio_init(void);
468789Sahrens extern void zio_fini(void);
469789Sahrens 
4701544Seschrock /*
4711544Seschrock  * Fault injection
4721544Seschrock  */
4731544Seschrock struct zinject_record;
4741544Seschrock extern uint32_t zio_injection_enabled;
4751544Seschrock extern int zio_inject_fault(char *name, int flags, int *id,
4761544Seschrock     struct zinject_record *record);
4771544Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen,
4781544Seschrock     struct zinject_record *record);
4791544Seschrock extern int zio_clear_fault(int id);
48010594SGeorge.Wilson@Sun.COM extern void zio_handle_panic_injection(spa_t *spa, char *tag);
4811544Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error);
4829725SEric.Schrock@Sun.COM extern int zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error);
4836615Sgw25295 extern int zio_handle_label_injection(zio_t *zio, int error);
484*10921STim.Haley@Sun.COM extern void zio_handle_ignored_writes(zio_t *zio);
4851544Seschrock 
48610614SJonathan.Adams@Sun.COM /*
48710614SJonathan.Adams@Sun.COM  * Checksum ereport functions
48810614SJonathan.Adams@Sun.COM  */
48910614SJonathan.Adams@Sun.COM extern void zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd, struct zio *zio,
49010614SJonathan.Adams@Sun.COM     uint64_t offset, uint64_t length, void *arg, struct zio_bad_cksum *info);
49110614SJonathan.Adams@Sun.COM extern void zfs_ereport_finish_checksum(zio_cksum_report_t *report,
49210614SJonathan.Adams@Sun.COM     const void *good_data, const void *bad_data, boolean_t drop_if_identical);
49310614SJonathan.Adams@Sun.COM 
49410614SJonathan.Adams@Sun.COM extern void zfs_ereport_send_interim_checksum(zio_cksum_report_t *report);
49510614SJonathan.Adams@Sun.COM extern void zfs_ereport_free_checksum(zio_cksum_report_t *report);
49610614SJonathan.Adams@Sun.COM 
49710614SJonathan.Adams@Sun.COM /* If we have the good data in hand, this function can be used */
49810614SJonathan.Adams@Sun.COM extern void zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd,
49910614SJonathan.Adams@Sun.COM     struct zio *zio, uint64_t offset, uint64_t length,
50010614SJonathan.Adams@Sun.COM     const void *good_data, const void *bad_data, struct zio_bad_cksum *info);
50110614SJonathan.Adams@Sun.COM 
502*10921STim.Haley@Sun.COM /* Called from spa_sync(), but primarily an injection handler */
503*10921STim.Haley@Sun.COM extern void spa_handle_ignored_writes(spa_t *spa);
504*10921STim.Haley@Sun.COM 
505789Sahrens #ifdef	__cplusplus
506789Sahrens }
507789Sahrens #endif
508789Sahrens 
509789Sahrens #endif	/* _ZIO_H */
510