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.
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.
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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "@(#)zio_impl.h 1.6 07/12/12 SMI"
31 #include <sys/zfs_context.h>
39 * I/O Groups: pipeline stage definitions.
41 typedef enum zio_stage
{
42 ZIO_STAGE_OPEN
= 0, /* RWFCI */
43 ZIO_STAGE_WAIT_FOR_CHILDREN_READY
, /* RWFCI */
45 ZIO_STAGE_READ_INIT
, /* R---- */
46 ZIO_STAGE_ISSUE_ASYNC
, /* -W--- */
47 ZIO_STAGE_WRITE_COMPRESS
, /* -W--- */
48 ZIO_STAGE_CHECKSUM_GENERATE
, /* -W--- */
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- */
55 ZIO_STAGE_DVA_ALLOCATE
, /* -W--- */
56 ZIO_STAGE_DVA_FREE
, /* --F-- */
57 ZIO_STAGE_DVA_CLAIM
, /* ---C- */
59 ZIO_STAGE_GANG_CHECKSUM_GENERATE
, /* -W--- */
61 ZIO_STAGE_READY
, /* RWFCI */
63 ZIO_STAGE_VDEV_IO_START
, /* RW--I */
64 ZIO_STAGE_VDEV_IO_DONE
, /* RW--I */
65 ZIO_STAGE_VDEV_IO_ASSESS
, /* RW--I */
67 ZIO_STAGE_WAIT_FOR_CHILDREN_DONE
, /* RWFCI */
69 ZIO_STAGE_CHECKSUM_VERIFY
, /* R---- */
70 ZIO_STAGE_READ_GANG_MEMBERS
, /* R---- */
71 ZIO_STAGE_READ_DECOMPRESS
, /* R---- */
73 ZIO_STAGE_ASSESS
, /* RWFCI */
74 ZIO_STAGE_DONE
/* RWFCI */
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))
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))
89 #define ZIO_READ_PHYS_PIPELINE \
90 (ZIO_INTERLOCK_STAGES | \
91 ZIO_VDEV_IO_STAGES | \
92 (1U << ZIO_STAGE_CHECKSUM_VERIFY))
94 #define ZIO_READ_GANG_PIPELINE \
95 ZIO_READ_PHYS_PIPELINE
97 #define ZIO_READ_PIPELINE \
98 (1U << ZIO_STAGE_READ_INIT) | \
99 ZIO_READ_PHYS_PIPELINE
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))
107 #define ZIO_WRITE_PHYS_PIPELINE \
108 ZIO_WRITE_COMMON_STAGES
110 #define ZIO_WRITE_PIPELINE \
111 (ZIO_WRITE_COMMON_STAGES | \
112 (1U << ZIO_STAGE_WRITE_COMPRESS) | \
113 (1U << ZIO_STAGE_DVA_ALLOCATE))
115 #define ZIO_GANG_REWRITE_STAGES \
116 ((1U << ZIO_STAGE_GET_GANG_HEADER) | \
117 (1U << ZIO_STAGE_REWRITE_GANG_MEMBERS) | \
118 (1U << ZIO_STAGE_GANG_CHECKSUM_GENERATE))
120 #define ZIO_GANG_FREE_STAGES \
121 ((1U << ZIO_STAGE_GET_GANG_HEADER) | \
122 (1U << ZIO_STAGE_FREE_GANG_MEMBERS))
124 #define ZIO_GANG_CLAIM_STAGES \
125 ((1U << ZIO_STAGE_GET_GANG_HEADER) | \
126 (1U << ZIO_STAGE_CLAIM_GANG_MEMBERS))
128 #define ZIO_REWRITE_PIPELINE(bp) \
129 (ZIO_WRITE_COMMON_STAGES | \
130 (BP_IS_GANG(bp) ? ZIO_GANG_REWRITE_STAGES : 0))
132 #define ZIO_WRITE_ALLOCATE_PIPELINE \
133 (ZIO_WRITE_COMMON_STAGES | \
134 (1U << ZIO_STAGE_DVA_ALLOCATE))
136 #define ZIO_FREE_PIPELINE(bp) \
137 (ZIO_INTERLOCK_STAGES | \
138 (1U << ZIO_STAGE_DVA_FREE) | \
139 (BP_IS_GANG(bp) ? ZIO_GANG_FREE_STAGES : 0))
141 #define ZIO_CLAIM_PIPELINE(bp) \
142 (ZIO_INTERLOCK_STAGES | \
143 (1U << ZIO_STAGE_DVA_CLAIM) | \
144 (BP_IS_GANG(bp) ? ZIO_GANG_CLAIM_STAGES : 0))
146 #define ZIO_IOCTL_PIPELINE \
147 (ZIO_INTERLOCK_STAGES | \
151 #define ZIO_WAIT_FOR_CHILDREN_PIPELINE \
154 #define ZIO_VDEV_CHILD_PIPELINE \
155 (ZIO_VDEV_IO_STAGES | \
156 (1U << ZIO_STAGE_ASSESS) | \
157 (1U << ZIO_STAGE_WAIT_FOR_CHILDREN_DONE) | \
158 (1U << ZIO_STAGE_DONE))
160 #define ZIO_ERROR_PIPELINE_MASK \
163 typedef struct zio_transform zio_transform_t
;
164 struct zio_transform
{
168 zio_transform_t
*zt_next
;
171 extern void zio_inject_init(void);
172 extern void zio_inject_fini(void);
178 #endif /* _ZIO_IMPL_H */