]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / cddl / contrib / opensolaris / uts / common / fs / zfs / sys / zio_impl.h
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_VDEV_IO_START,                /* RW--I */
65         ZIO_STAGE_VDEV_IO_DONE,                 /* RW--I */
66         ZIO_STAGE_VDEV_IO_ASSESS,               /* RW--I */
67
68         ZIO_STAGE_WAIT_CHILDREN_DONE,           /* RWFCI */
69
70         ZIO_STAGE_CHECKSUM_VERIFY,              /* R---- */
71         ZIO_STAGE_READ_GANG_MEMBERS,            /* R---- */
72         ZIO_STAGE_READ_DECOMPRESS,              /* R---- */
73
74         ZIO_STAGE_DONE                          /* RWFCI */
75 } zio_stage_t;
76
77 /*
78  * The stages for which there's some performance value in going async.
79  * When compression is enabled, ZIO_STAGE_WRITE_COMPRESS is ORed in as well.
80  */
81 #define ZIO_ASYNC_PIPELINE_STAGES                               \
82         ((1U << ZIO_STAGE_CHECKSUM_GENERATE) |                  \
83         (1U << ZIO_STAGE_VDEV_IO_DONE) |                        \
84         (1U << ZIO_STAGE_CHECKSUM_VERIFY) |                     \
85         (1U << ZIO_STAGE_READ_DECOMPRESS))
86
87 #define ZIO_VDEV_IO_PIPELINE                                    \
88         ((1U << ZIO_STAGE_VDEV_IO_START) |                      \
89         (1U << ZIO_STAGE_VDEV_IO_DONE) |                        \
90         (1U << ZIO_STAGE_VDEV_IO_ASSESS))
91
92 #define ZIO_READ_PHYS_PIPELINE                                  \
93         ((1U << ZIO_STAGE_OPEN) |                               \
94         (1U << ZIO_STAGE_WAIT_CHILDREN_READY) |                 \
95         (1U << ZIO_STAGE_READY) |                               \
96         ZIO_VDEV_IO_PIPELINE |                                  \
97         (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                  \
98         (1U << ZIO_STAGE_CHECKSUM_VERIFY) |                     \
99         (1U << ZIO_STAGE_DONE))
100
101 #define ZIO_READ_PIPELINE                                       \
102         ZIO_READ_PHYS_PIPELINE
103
104 #define ZIO_WRITE_PHYS_PIPELINE                                 \
105         ((1U << ZIO_STAGE_OPEN) |                               \
106         (1U << ZIO_STAGE_WAIT_CHILDREN_READY) |                 \
107         (1U << ZIO_STAGE_CHECKSUM_GENERATE) |                   \
108         (1U << ZIO_STAGE_READY) |                               \
109         ZIO_VDEV_IO_PIPELINE |                                  \
110         (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                  \
111         (1U << ZIO_STAGE_DONE))
112
113 #define ZIO_WRITE_COMMON_PIPELINE                               \
114         ZIO_WRITE_PHYS_PIPELINE
115
116 #define ZIO_WRITE_PIPELINE                                      \
117         ((1U << ZIO_STAGE_WRITE_COMPRESS) |                     \
118         ZIO_WRITE_COMMON_PIPELINE)
119
120 #define ZIO_GANG_STAGES                                         \
121         ((1U << ZIO_STAGE_GET_GANG_HEADER) |                    \
122         (1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |                \
123         (1U << ZIO_STAGE_FREE_GANG_MEMBERS) |                   \
124         (1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) |                  \
125         (1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) |              \
126         (1U << ZIO_STAGE_READ_GANG_MEMBERS))
127
128 #define ZIO_REWRITE_PIPELINE                                    \
129         ((1U << ZIO_STAGE_GANG_PIPELINE) |                      \
130         (1U << ZIO_STAGE_GET_GANG_HEADER) |                     \
131         (1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) |                \
132         (1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE) |              \
133         ZIO_WRITE_COMMON_PIPELINE)
134
135 #define ZIO_WRITE_ALLOCATE_PIPELINE                             \
136         ((1U << ZIO_STAGE_DVA_ALLOCATE) |                       \
137         ZIO_WRITE_COMMON_PIPELINE)
138
139 #define ZIO_GANG_FREE_STAGES                                    \
140         ((1U << ZIO_STAGE_GET_GANG_HEADER) |                    \
141         (1U << ZIO_STAGE_FREE_GANG_MEMBERS))
142
143 #define ZIO_FREE_PIPELINE                                       \
144         ((1U << ZIO_STAGE_OPEN) |                               \
145         (1U << ZIO_STAGE_WAIT_CHILDREN_READY) |                 \
146         (1U << ZIO_STAGE_GANG_PIPELINE) |                       \
147         (1U << ZIO_STAGE_GET_GANG_HEADER) |                     \
148         (1U << ZIO_STAGE_FREE_GANG_MEMBERS) |                   \
149         (1U << ZIO_STAGE_DVA_FREE) |                            \
150         (1U << ZIO_STAGE_READY) |                               \
151         (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                  \
152         (1U << ZIO_STAGE_DONE))
153
154 #define ZIO_CLAIM_PIPELINE                                      \
155         ((1U << ZIO_STAGE_OPEN) |                               \
156         (1U << ZIO_STAGE_WAIT_CHILDREN_READY) |                 \
157         (1U << ZIO_STAGE_GANG_PIPELINE) |                       \
158         (1U << ZIO_STAGE_GET_GANG_HEADER) |                     \
159         (1U << ZIO_STAGE_CLAIM_GANG_MEMBERS) |                  \
160         (1U << ZIO_STAGE_DVA_CLAIM) |                           \
161         (1U << ZIO_STAGE_READY) |                               \
162         (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                  \
163         (1U << ZIO_STAGE_DONE))
164
165 #define ZIO_IOCTL_PIPELINE                                      \
166         ((1U << ZIO_STAGE_OPEN) |                               \
167         (1U << ZIO_STAGE_WAIT_CHILDREN_READY) |                 \
168         (1U << ZIO_STAGE_READY) |                               \
169         ZIO_VDEV_IO_PIPELINE |                                  \
170         (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                  \
171         (1U << ZIO_STAGE_DONE))
172
173 #define ZIO_WAIT_FOR_CHILDREN_PIPELINE                          \
174         ((1U << ZIO_STAGE_WAIT_CHILDREN_READY) |                \
175         (1U << ZIO_STAGE_READY) |                               \
176         (1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                  \
177         (1U << ZIO_STAGE_DONE))
178
179 #define ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE                     \
180         ((1U << ZIO_STAGE_WAIT_CHILDREN_DONE) |                 \
181         (1U << ZIO_STAGE_DONE))
182
183 #define ZIO_VDEV_CHILD_PIPELINE                                 \
184         (ZIO_WAIT_FOR_CHILDREN_DONE_PIPELINE |                  \
185         ZIO_VDEV_IO_PIPELINE)
186
187 #define ZIO_ERROR_PIPELINE_MASK                                 \
188         ZIO_WAIT_FOR_CHILDREN_PIPELINE
189
190 typedef struct zio_transform zio_transform_t;
191 struct zio_transform {
192         void            *zt_data;
193         uint64_t        zt_size;
194         uint64_t        zt_bufsize;
195         zio_transform_t *zt_next;
196 };
197
198 extern void zio_inject_init(void);
199 extern void zio_inject_fini(void);
200
201 #ifdef  __cplusplus
202 }
203 #endif
204
205 #endif  /* _ZIO_IMPL_H */