xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zio_impl.h (revision db874c57ae335a07060499f1492b0d0e2593e26c)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _ZIO_IMPL_H
28 #define	_ZIO_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/zfs_context.h>
33 #include <sys/zio.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * I/O Groups: pipeline stage definitions.
41  */
42 
43 typedef enum zio_stage {
44 	ZIO_STAGE_OPEN = 0,			/* RWFCI */
45 	ZIO_STAGE_WAIT_CHILDREN_READY,		/* RWFCI */
46 
47 	ZIO_STAGE_WRITE_COMPRESS,		/* -W--- */
48 	ZIO_STAGE_CHECKSUM_GENERATE,		/* -W--- */
49 
50 	ZIO_STAGE_GANG_PIPELINE,		/* -WFC- */
51 
52 	ZIO_STAGE_GET_GANG_HEADER,		/* -WFC- */
53 	ZIO_STAGE_REWRITE_GANG_MEMBERS,		/* -W--- */
54 	ZIO_STAGE_FREE_GANG_MEMBERS,		/* --F-- */
55 	ZIO_STAGE_CLAIM_GANG_MEMBERS,		/* ---C- */
56 
57 	ZIO_STAGE_DVA_ALLOCATE,			/* -W--- */
58 	ZIO_STAGE_DVA_FREE,			/* --F-- */
59 	ZIO_STAGE_DVA_CLAIM,			/* ---C- */
60 
61 	ZIO_STAGE_GANG_CHECKSUM_GENERATE,	/* -W--- */
62 
63 	ZIO_STAGE_READY,			/* RWFCI */
64 
65 	ZIO_STAGE_DVA_TRANSLATE,		/* RW--- */
66 
67 	ZIO_STAGE_VDEV_IO_SETUP,		/* RW--I */
68 	ZIO_STAGE_VDEV_IO_START,		/* RW--I */
69 	ZIO_STAGE_VDEV_IO_DONE,			/* RW--I */
70 	ZIO_STAGE_VDEV_IO_ASSESS,		/* RW--I */
71 
72 	ZIO_STAGE_WAIT_CHILDREN_DONE,		/* RWFCI */
73 
74 	ZIO_STAGE_CHECKSUM_VERIFY,		/* R---- */
75 	ZIO_STAGE_READ_GANG_MEMBERS,		/* R---- */
76 	ZIO_STAGE_READ_DECOMPRESS,		/* R---- */
77 
78 	ZIO_STAGE_DONE				/* RWFCI */
79 } zio_stage_t;
80 
81 /*
82  * The stages for which there's some performance value in going async.
83  * When compression is enabled, ZIO_STAGE_WRITE_COMPRESS is ORed in as well.
84  */
85 #define	ZIO_ASYNC_PIPELINE_STAGES				\
86 	((1U << ZIO_STAGE_CHECKSUM_GENERATE) |			\
87 	(1U << ZIO_STAGE_VDEV_IO_DONE) |			\
88 	(1U << ZIO_STAGE_CHECKSUM_VERIFY) |			\
89 	(1U << ZIO_STAGE_READ_DECOMPRESS))
90 
91 #define	ZIO_VDEV_IO_PIPELINE					\
92 	((1U << ZIO_STAGE_VDEV_IO_SETUP) |			\
93 	(1U << ZIO_STAGE_VDEV_IO_START) |			\
94 	(1U << ZIO_STAGE_VDEV_IO_DONE) |			\
95 	(1U << ZIO_STAGE_VDEV_IO_ASSESS))
96 
97 #define	ZIO_READ_PHYS_PIPELINE					\
98 	((1U << ZIO_STAGE_OPEN) |				\
99 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
100 	(1U << ZIO_STAGE_READY) |				\
101 	ZIO_VDEV_IO_PIPELINE |					\
102 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
103 	(1U << ZIO_STAGE_CHECKSUM_VERIFY) |			\
104 	(1U << ZIO_STAGE_DONE))
105 
106 #define	ZIO_READ_PIPELINE					\
107 	((1U << ZIO_STAGE_DVA_TRANSLATE) |			\
108 	ZIO_READ_PHYS_PIPELINE)
109 
110 #define	ZIO_WRITE_PHYS_PIPELINE					\
111 	((1U << ZIO_STAGE_OPEN) |				\
112 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
113 	(1U << ZIO_STAGE_CHECKSUM_GENERATE) |			\
114 	(1U << ZIO_STAGE_READY) |				\
115 	ZIO_VDEV_IO_PIPELINE |					\
116 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
117 	(1U << ZIO_STAGE_DONE))
118 
119 #define	ZIO_WRITE_COMMON_PIPELINE				\
120 	((1U << ZIO_STAGE_DVA_TRANSLATE) |			\
121 	ZIO_WRITE_PHYS_PIPELINE)
122 
123 #define	ZIO_WRITE_PIPELINE					\
124 	((1U << ZIO_STAGE_WRITE_COMPRESS) |			\
125 	ZIO_WRITE_COMMON_PIPELINE)
126 
127 #define	ZIO_GANG_STAGES						\
128 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
129 	(1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |		\
130 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS) |			\
131 	(1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) |			\
132 	(1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) |		\
133 	(1U << ZIO_STAGE_READ_GANG_MEMBERS))
134 
135 #define	ZIO_REWRITE_PIPELINE					\
136 	((1U << ZIO_STAGE_GANG_PIPELINE) |			\
137 	(1U << ZIO_STAGE_GET_GANG_HEADER) |			\
138 	(1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |		\
139 	(1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) |		\
140 	ZIO_WRITE_COMMON_PIPELINE)
141 
142 #define	ZIO_WRITE_ALLOCATE_PIPELINE				\
143 	((1U << ZIO_STAGE_DVA_ALLOCATE) |			\
144 	ZIO_WRITE_COMMON_PIPELINE)
145 
146 #define	ZIO_GANG_FREE_STAGES					\
147 	((1U << ZIO_STAGE_GET_GANG_HEADER) |			\
148 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS))
149 
150 #define	ZIO_FREE_PIPELINE					\
151 	((1U << ZIO_STAGE_OPEN) |				\
152 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
153 	(1U << ZIO_STAGE_GANG_PIPELINE) |			\
154 	(1U << ZIO_STAGE_GET_GANG_HEADER) |			\
155 	(1U << ZIO_STAGE_FREE_GANG_MEMBERS) |			\
156 	(1U << ZIO_STAGE_DVA_FREE) |				\
157 	(1U << ZIO_STAGE_READY) |				\
158 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
159 	(1U << ZIO_STAGE_DONE))
160 
161 #define	ZIO_CLAIM_PIPELINE					\
162 	((1U << ZIO_STAGE_OPEN) |				\
163 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
164 	(1U << ZIO_STAGE_GANG_PIPELINE) |			\
165 	(1U << ZIO_STAGE_GET_GANG_HEADER) |			\
166 	(1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) |			\
167 	(1U << ZIO_STAGE_DVA_CLAIM) |				\
168 	(1U << ZIO_STAGE_READY) |				\
169 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
170 	(1U << ZIO_STAGE_DONE))
171 
172 #define	ZIO_IOCTL_PIPELINE					\
173 	((1U << ZIO_STAGE_OPEN) |				\
174 	(1U << ZIO_STAGE_WAIT_CHILDREN_READY) |			\
175 	(1U << ZIO_STAGE_READY) |				\
176 	ZIO_VDEV_IO_PIPELINE |					\
177 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
178 	(1U << ZIO_STAGE_DONE))
179 
180 #define	ZIO_WAIT_FOR_CHILDREN_PIPELINE				\
181 	((1U << ZIO_STAGE_WAIT_CHILDREN_READY) |		\
182 	(1U << ZIO_STAGE_READY) |				\
183 	(1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
184 	(1U << ZIO_STAGE_DONE))
185 
186 #define	ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE			\
187 	((1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |			\
188 	(1U << ZIO_STAGE_DONE))
189 
190 #define	ZIO_VDEV_CHILD_PIPELINE					\
191 	(ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE |			\
192 	ZIO_VDEV_IO_PIPELINE)
193 
194 #define	ZIO_ERROR_PIPELINE_MASK					\
195 	ZIO_WAIT_FOR_CHILDREN_PIPELINE
196 
197 struct zio_transform {
198 	void		*zt_data;
199 	uint64_t	zt_size;
200 	uint64_t	zt_bufsize;
201 	zio_transform_t	*zt_next;
202 };
203 
204 #ifdef	__cplusplus
205 }
206 #endif
207 
208 #endif	/* _ZIO_IMPL_H */
209