xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zio_impl.h (revision 80ab886d233f514d54c2a6bdeb9fdfd951bd6881)
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 2006 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 
42 typedef enum zio_stage {
43 	ZIO_STAGE_OPEN = 0,			/* RWFCI */
44 	ZIO_STAGE_WAIT_CHILDREN_READY,		/* RWFCI */
45 
46 	ZIO_STAGE_WRITE_COMPRESS,		/* -W--- */
47 	ZIO_STAGE_CHECKSUM_GENERATE,		/* -W--- */
48 
49 	ZIO_STAGE_GANG_PIPELINE,		/* -WFC- */
50 
51 	ZIO_STAGE_GET_GANG_HEADER,		/* -WFC- */
52 	ZIO_STAGE_REWRITE_GANG_MEMBERS,		/* -W--- */
53 	ZIO_STAGE_FREE_GANG_MEMBERS,		/* --F-- */
54 	ZIO_STAGE_CLAIM_GANG_MEMBERS,		/* ---C- */
55 
56 	ZIO_STAGE_DVA_ALLOCATE,			/* -W--- */
57 	ZIO_STAGE_DVA_FREE,			/* --F-- */
58 	ZIO_STAGE_DVA_CLAIM,			/* ---C- */
59 
60 	ZIO_STAGE_GANG_CHECKSUM_GENERATE,	/* -W--- */
61 
62 	ZIO_STAGE_READY,			/* RWFCI */
63 
64 	ZIO_STAGE_DVA_TRANSLATE,		/* RW--- */
65 
66 	ZIO_STAGE_VDEV_IO_SETUP,		/* RW--I */
67 	ZIO_STAGE_VDEV_IO_START,		/* RW--I */
68 	ZIO_STAGE_VDEV_IO_DONE,			/* RW--I */
69 	ZIO_STAGE_VDEV_IO_ASSESS,		/* RW--I */
70 
71 	ZIO_STAGE_WAIT_CHILDREN_DONE,		/* RWFCI */
72 
73 	ZIO_STAGE_CHECKSUM_VERIFY,		/* R---- */
74 	ZIO_STAGE_READ_GANG_MEMBERS,		/* R---- */
75 	ZIO_STAGE_READ_DECOMPRESS,		/* R---- */
76 
77 	ZIO_STAGE_DONE				/* RWFCI */
78 } zio_stage_t;
79 
80 /*
81  * The stages for which there's some performance value in going async.
82  * When compression is enabled, ZIO_STAGE_WRITE_COMPRESS is ORed in as well.
83  */
84 #define	ZIO_ASYNC_PIPELINE_STAGES				\
85 	((1U << ZIO_STAGE_CHECKSUM_GENERATE) |			\
86 	(1U << ZIO_STAGE_VDEV_IO_DONE) |			\
87 	(1U << ZIO_STAGE_CHECKSUM_VERIFY) |			\
88 	(1U << ZIO_STAGE_READ_DECOMPRESS))
89 
90 #define	ZIO_VDEV_IO_PIPELINE					\
91 	((1U << ZIO_STAGE_VDEV_IO_SETUP) |			\
92 	(1U << ZIO_STAGE_VDEV_IO_START) |			\
93 	(1U << ZIO_STAGE_VDEV_IO_DONE) |			\
94 	(1U << ZIO_STAGE_VDEV_IO_ASSESS))
95 
96 #define	ZIO_READ_PHYS_PIPELINE					\
97 	((1U << ZIO_STAGE_OPEN) |				\
98 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
99 	(1U << ZIO_STAGE_READY) |				\
100 	ZIO_VDEV_IO_PIPELINE |					\
101 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
102 	(1U << ZIO_STAGE_CHECKSUM_VERIFY) |			\
103 	(1U << ZIO_STAGE_DONE))
104 
105 #define	ZIO_READ_PIPELINE					\
106 	((1U << ZIO_STAGE_DVA_TRANSLATE) |			\
107 	ZIO_READ_PHYS_PIPELINE)
108 
109 #define	ZIO_WRITE_PHYS_PIPELINE					\
110 	((1U << ZIO_STAGE_OPEN) |				\
111 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
112 	(1U << ZIO_STAGE_CHECKSUM_GENERATE) |			\
113 	(1U << ZIO_STAGE_READY) |				\
114 	ZIO_VDEV_IO_PIPELINE |					\
115 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
116 	(1U << ZIO_STAGE_DONE))
117 
118 #define	ZIO_WRITE_COMMON_PIPELINE				\
119 	((1U << ZIO_STAGE_DVA_TRANSLATE) |			\
120 	ZIO_WRITE_PHYS_PIPELINE)
121 
122 #define	ZIO_WRITE_PIPELINE					\
123 	((1U << ZIO_STAGE_WRITE_COMPRESS) |			\
124 	ZIO_WRITE_COMMON_PIPELINE)
125 
126 #define	ZIO_GANG_STAGES						\
127 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
128 	(1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |		\
129 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS) |			\
130 	(1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) |			\
131 	(1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) |		\
132 	(1U << ZIO_STAGE_READ_GANG_MEMBERS))
133 
134 #define	ZIO_REWRITE_PIPELINE					\
135 	((1U << ZIO_STAGE_GANG_PIPELINE) |			\
136 	(1U << ZIO_STAGE_GET_GANG_HEADER) |			\
137 	(1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |		\
138 	(1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) |		\
139 	ZIO_WRITE_COMMON_PIPELINE)
140 
141 #define	ZIO_WRITE_ALLOCATE_PIPELINE				\
142 	((1U << ZIO_STAGE_DVA_ALLOCATE) |			\
143 	ZIO_WRITE_COMMON_PIPELINE)
144 
145 #define	ZIO_GANG_FREE_STAGES					\
146 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
147 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS))
148 
149 #define	ZIO_FREE_PIPELINE					\
150 	((1U << ZIO_STAGE_OPEN) |				\
151 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
152 	(1U << ZIO_STAGE_GANG_PIPELINE) |			\
153 	(1U << ZIO_STAGE_GET_GANG_HEADER) |			\
154 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS) |			\
155 	(1U << ZIO_STAGE_DVA_FREE) |				\
156 	(1U << ZIO_STAGE_READY) |				\
157 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
158 	(1U << ZIO_STAGE_DONE))
159 
160 #define	ZIO_CLAIM_PIPELINE					\
161 	((1U << ZIO_STAGE_OPEN) |				\
162 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
163 	(1U << ZIO_STAGE_GANG_PIPELINE) |			\
164 	(1U << ZIO_STAGE_GET_GANG_HEADER) |			\
165 	(1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) |			\
166 	(1U << ZIO_STAGE_DVA_CLAIM) |				\
167 	(1U << ZIO_STAGE_READY) |				\
168 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
169 	(1U << ZIO_STAGE_DONE))
170 
171 #define	ZIO_IOCTL_PIPELINE					\
172 	((1U << ZIO_STAGE_OPEN) |				\
173 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
174 	(1U << ZIO_STAGE_READY) |				\
175 	ZIO_VDEV_IO_PIPELINE |					\
176 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
177 	(1U << ZIO_STAGE_DONE))
178 
179 #define	ZIO_WAIT_FOR_CHILDREN_PIPELINE				\
180 	((1U << ZIO_STAGE_WAIT_CHILDREN_READY) |		\
181 	(1U << ZIO_STAGE_READY) |				\
182 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
183 	(1U << ZIO_STAGE_DONE))
184 
185 #define	ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE			\
186 	((1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
187 	(1U << ZIO_STAGE_DONE))
188 
189 #define	ZIO_VDEV_CHILD_PIPELINE					\
190 	(ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE |			\
191 	ZIO_VDEV_IO_PIPELINE)
192 
193 #define	ZIO_ERROR_PIPELINE_MASK					\
194 	ZIO_WAIT_FOR_CHILDREN_PIPELINE
195 
196 struct zio_transform {
197 	void		*zt_data;
198 	uint64_t	zt_size;
199 	uint64_t	zt_bufsize;
200 	zio_transform_t	*zt_next;
201 };
202 
203 extern void zio_inject_init(void);
204 extern void zio_inject_fini(void);
205 
206 #ifdef	__cplusplus
207 }
208 #endif
209 
210 #endif	/* _ZIO_IMPL_H */
211