xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zio_impl.h (revision a194faf8907a6722dcf10ad16c6ca72c9b7bd0ba)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _ZIO_IMPL_H
27 #define	_ZIO_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/zfs_context.h>
32 #include <sys/zio.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * I/O Groups: pipeline stage definitions.
40  */
41 typedef enum zio_stage {
42 	ZIO_STAGE_OPEN = 0,			/* RWFCI */
43 	ZIO_STAGE_WAIT_FOR_CHILDREN_READY,	/* RWFCI */
44 
45 	ZIO_STAGE_READ_INIT,			/* R---- */
46 	ZIO_STAGE_ISSUE_ASYNC,			/* -W--- */
47 	ZIO_STAGE_WRITE_COMPRESS,		/* -W--- */
48 	ZIO_STAGE_CHECKSUM_GENERATE,		/* -W--- */
49 
50 	ZIO_STAGE_GET_GANG_HEADER,		/* -WFC- */
51 	ZIO_STAGE_REWRITE_GANG_MEMBERS,		/* -W--- */
52 	ZIO_STAGE_FREE_GANG_MEMBERS,		/* --F-- */
53 	ZIO_STAGE_CLAIM_GANG_MEMBERS,		/* ---C- */
54 
55 	ZIO_STAGE_DVA_ALLOCATE,			/* -W--- */
56 	ZIO_STAGE_DVA_FREE,			/* --F-- */
57 	ZIO_STAGE_DVA_CLAIM,			/* ---C- */
58 
59 	ZIO_STAGE_GANG_CHECKSUM_GENERATE,	/* -W--- */
60 
61 	ZIO_STAGE_READY,			/* RWFCI */
62 
63 	ZIO_STAGE_VDEV_IO_START,		/* RW--I */
64 	ZIO_STAGE_VDEV_IO_DONE,			/* RW--I */
65 	ZIO_STAGE_VDEV_IO_ASSESS,		/* RW--I */
66 
67 	ZIO_STAGE_WAIT_FOR_CHILDREN_DONE,	/* RWFCI */
68 
69 	ZIO_STAGE_CHECKSUM_VERIFY,		/* R---- */
70 	ZIO_STAGE_READ_GANG_MEMBERS,		/* R---- */
71 	ZIO_STAGE_READ_DECOMPRESS,		/* R---- */
72 
73 	ZIO_STAGE_ASSESS,			/* RWFCI */
74 	ZIO_STAGE_DONE				/* RWFCI */
75 } zio_stage_t;
76 
77 #define	ZIO_INTERLOCK_STAGES					\
78 	((1U << ZIO_STAGE_WAIT_FOR_CHILDREN_READY) |		\
79 	(1U << ZIO_STAGE_READY) |				\
80 	(1U << ZIO_STAGE_WAIT_FOR_CHILDREN_DONE) |		\
81 	(1U << ZIO_STAGE_ASSESS) |				\
82 	(1U << ZIO_STAGE_DONE))
83 
84 #define	ZIO_VDEV_IO_STAGES					\
85 	((1U << ZIO_STAGE_VDEV_IO_START) |			\
86 	(1U << ZIO_STAGE_VDEV_IO_DONE) |			\
87 	(1U << ZIO_STAGE_VDEV_IO_ASSESS))
88 
89 #define	ZIO_READ_PHYS_PIPELINE					\
90 	(ZIO_INTERLOCK_STAGES |					\
91 	ZIO_VDEV_IO_STAGES |					\
92 	(1U << ZIO_STAGE_CHECKSUM_VERIFY))
93 
94 #define	ZIO_READ_GANG_PIPELINE					\
95 	ZIO_READ_PHYS_PIPELINE
96 
97 #define	ZIO_READ_PIPELINE					\
98 	(1U << ZIO_STAGE_READ_INIT) |				\
99 	ZIO_READ_PHYS_PIPELINE
100 
101 #define	ZIO_WRITE_COMMON_STAGES					\
102 	(ZIO_INTERLOCK_STAGES |					\
103 	ZIO_VDEV_IO_STAGES |					\
104 	(1U << ZIO_STAGE_ISSUE_ASYNC) |				\
105 	(1U << ZIO_STAGE_CHECKSUM_GENERATE))
106 
107 #define	ZIO_WRITE_PHYS_PIPELINE					\
108 	ZIO_WRITE_COMMON_STAGES
109 
110 #define	ZIO_WRITE_PIPELINE					\
111 	(ZIO_WRITE_COMMON_STAGES |				\
112 	(1U << ZIO_STAGE_WRITE_COMPRESS))
113 
114 #define	ZIO_GANG_REWRITE_STAGES					\
115 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
116 	(1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |		\
117 	(1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE))
118 
119 #define	ZIO_GANG_FREE_STAGES					\
120 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
121 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS))
122 
123 #define	ZIO_GANG_CLAIM_STAGES					\
124 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
125 	(1U << ZIO_STAGE_CLAIM_GANG_MEMBERS))
126 
127 #define	ZIO_REWRITE_PIPELINE(bp)				\
128 	(ZIO_WRITE_COMMON_STAGES |				\
129 	(BP_IS_GANG(bp) ? ZIO_GANG_REWRITE_STAGES : 0))
130 
131 #define	ZIO_WRITE_ALLOCATE_PIPELINE				\
132 	(ZIO_WRITE_COMMON_STAGES |				\
133 	(1U << ZIO_STAGE_DVA_ALLOCATE))
134 
135 #define	ZIO_FREE_PIPELINE(bp)					\
136 	(ZIO_INTERLOCK_STAGES |					\
137 	(1U << ZIO_STAGE_DVA_FREE) |				\
138 	(BP_IS_GANG(bp) ? ZIO_GANG_FREE_STAGES : 0))
139 
140 #define	ZIO_CLAIM_PIPELINE(bp)					\
141 	(ZIO_INTERLOCK_STAGES |					\
142 	(1U << ZIO_STAGE_DVA_CLAIM) |				\
143 	(BP_IS_GANG(bp) ? ZIO_GANG_CLAIM_STAGES : 0))
144 
145 #define	ZIO_IOCTL_PIPELINE					\
146 	(ZIO_INTERLOCK_STAGES |					\
147 	ZIO_VDEV_IO_STAGES)
148 
149 
150 #define	ZIO_WAIT_FOR_CHILDREN_PIPELINE				\
151 	ZIO_INTERLOCK_STAGES
152 
153 #define	ZIO_VDEV_CHILD_PIPELINE					\
154 	(ZIO_VDEV_IO_STAGES |					\
155 	(1U << ZIO_STAGE_ASSESS) |				\
156 	(1U << ZIO_STAGE_WAIT_FOR_CHILDREN_DONE) |		\
157 	(1U << ZIO_STAGE_DONE))
158 
159 #define	ZIO_ERROR_PIPELINE_MASK					\
160 	ZIO_INTERLOCK_STAGES
161 
162 typedef struct zio_transform zio_transform_t;
163 struct zio_transform {
164 	void		*zt_data;
165 	uint64_t	zt_size;
166 	uint64_t	zt_bufsize;
167 	zio_transform_t	*zt_next;
168 };
169 
170 extern void zio_inject_init(void);
171 extern void zio_inject_fini(void);
172 
173 #ifdef	__cplusplus
174 }
175 #endif
176 
177 #endif	/* _ZIO_IMPL_H */
178