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 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
38 * XXX -- Describe ZFS I/O pipeline here. Fill in as needed.
40 * The ZFS I/O pipeline is comprised of various stages which are defined
41 * in the zio_stage enum below. The individual stages are used to construct
42 * these basic I/O operations: Read, Write, Free, Claim, and Ioctl.
44 * I/O operations: (XXX - provide detail for each of the operations)
52 * Although the most common pipeline are used by the basic I/O operations
53 * above, there are some helper pipelines (one could consider them
54 * sub-pipelines) which are used internally by the ZIO module and are
58 * The interlock pipeline is the most basic pipeline and is used by all
59 * of the I/O operations. The interlock pipeline does not perform any I/O
60 * and is used to coordinate the dependencies between I/Os that are being
61 * issued (i.e. the parent/child relationship).
63 * Vdev child Pipeline:
64 * The vdev child pipeline is responsible for performing the physical I/O.
65 * It is in this pipeline where the I/O are queued and possibly cached.
67 * In addition to performing I/O, the pipeline is also responsible for
68 * data transformations. The transformations performed are based on the
69 * specific properties that user may have selected and modify the
70 * behavior of the pipeline. Examples of supported transformations are
71 * compression, dedup, and nop writes. Transformations will either modify
72 * the data or the pipeline. This list below further describes each of
73 * the supported transformations:
76 * ZFS supports three different flavors of compression -- gzip, lzjb, and
77 * zle. Compression occurs as part of the write pipeline and is performed
78 * in the ZIO_STAGE_WRITE_BP_INIT stage.
81 * Dedup reads are handled by the ZIO_STAGE_DDT_READ_START and
82 * ZIO_STAGE_DDT_READ_DONE stages. These stages are added to an existing
83 * read pipeline if the dedup bit is set on the block pointer.
84 * Writing a dedup block is performed by the ZIO_STAGE_DDT_WRITE stage
85 * and added to a write pipeline if a user has enabled dedup on that
89 * The NOP write feature is performed by the ZIO_STAGE_NOP_WRITE stage
90 * and is added to an existing write pipeline if a crypographically
91 * secure checksum (i.e. SHA256) is enabled and compression is turned on.
92 * The NOP write stage will compare the checksums of the current data
93 * on-disk (level-0 blocks only) and the data that is currently being written.
94 * If the checksum values are identical then the pipeline is converted to
95 * an interlock pipeline skipping block allocation and bypassing the
96 * physical I/O. The nop write feature can handle writes in either
97 * syncing or open context (i.e. zil writes) and as a result is mutually
98 * exclusive with dedup.
102 * zio pipeline stage definitions
105 ZIO_STAGE_OPEN
= 1 << 0, /* RWFCI */
107 ZIO_STAGE_READ_BP_INIT
= 1 << 1, /* R---- */
108 ZIO_STAGE_WRITE_BP_INIT
= 1 << 2, /* -W--- */
109 ZIO_STAGE_FREE_BP_INIT
= 1 << 3, /* --F-- */
110 ZIO_STAGE_ISSUE_ASYNC
= 1 << 4, /* RWF-- */
111 ZIO_STAGE_WRITE_COMPRESS
= 1 << 5, /* -W--- */
113 ZIO_STAGE_CHECKSUM_GENERATE
= 1 << 6, /* -W--- */
115 ZIO_STAGE_NOP_WRITE
= 1 << 7, /* -W--- */
117 ZIO_STAGE_DDT_READ_START
= 1 << 8, /* R---- */
118 ZIO_STAGE_DDT_READ_DONE
= 1 << 9, /* R---- */
119 ZIO_STAGE_DDT_WRITE
= 1 << 10, /* -W--- */
120 ZIO_STAGE_DDT_FREE
= 1 << 11, /* --F-- */
122 ZIO_STAGE_GANG_ASSEMBLE
= 1 << 12, /* RWFC- */
123 ZIO_STAGE_GANG_ISSUE
= 1 << 13, /* RWFC- */
125 ZIO_STAGE_DVA_THROTTLE
= 1 << 14, /* -W--- */
126 ZIO_STAGE_DVA_ALLOCATE
= 1 << 15, /* -W--- */
127 ZIO_STAGE_DVA_FREE
= 1 << 16, /* --F-- */
128 ZIO_STAGE_DVA_CLAIM
= 1 << 17, /* ---C- */
130 ZIO_STAGE_READY
= 1 << 18, /* RWFCI */
132 ZIO_STAGE_VDEV_IO_START
= 1 << 19, /* RW--I */
133 ZIO_STAGE_VDEV_IO_DONE
= 1 << 20, /* RW--I */
134 ZIO_STAGE_VDEV_IO_ASSESS
= 1 << 21, /* RW--I */
136 ZIO_STAGE_CHECKSUM_VERIFY
= 1 << 22, /* R---- */
138 ZIO_STAGE_DONE
= 1 << 23 /* RWFCI */
141 #define ZIO_INTERLOCK_STAGES \
145 #define ZIO_INTERLOCK_PIPELINE \
148 #define ZIO_VDEV_IO_STAGES \
149 (ZIO_STAGE_VDEV_IO_START | \
150 ZIO_STAGE_VDEV_IO_DONE | \
151 ZIO_STAGE_VDEV_IO_ASSESS)
153 #define ZIO_VDEV_CHILD_PIPELINE \
154 (ZIO_VDEV_IO_STAGES | \
157 #define ZIO_READ_COMMON_STAGES \
158 (ZIO_INTERLOCK_STAGES | \
159 ZIO_VDEV_IO_STAGES | \
160 ZIO_STAGE_CHECKSUM_VERIFY)
162 #define ZIO_READ_PHYS_PIPELINE \
163 ZIO_READ_COMMON_STAGES
165 #define ZIO_READ_PIPELINE \
166 (ZIO_READ_COMMON_STAGES | \
167 ZIO_STAGE_READ_BP_INIT)
169 #define ZIO_DDT_CHILD_READ_PIPELINE \
170 ZIO_READ_COMMON_STAGES
172 #define ZIO_DDT_READ_PIPELINE \
173 (ZIO_INTERLOCK_STAGES | \
174 ZIO_STAGE_READ_BP_INIT | \
175 ZIO_STAGE_DDT_READ_START | \
176 ZIO_STAGE_DDT_READ_DONE)
178 #define ZIO_WRITE_COMMON_STAGES \
179 (ZIO_INTERLOCK_STAGES | \
180 ZIO_VDEV_IO_STAGES | \
181 ZIO_STAGE_ISSUE_ASYNC | \
182 ZIO_STAGE_CHECKSUM_GENERATE)
184 #define ZIO_WRITE_PHYS_PIPELINE \
185 ZIO_WRITE_COMMON_STAGES
187 #define ZIO_REWRITE_PIPELINE \
188 (ZIO_WRITE_COMMON_STAGES | \
189 ZIO_STAGE_WRITE_COMPRESS | \
190 ZIO_STAGE_WRITE_BP_INIT)
192 #define ZIO_WRITE_PIPELINE \
193 (ZIO_WRITE_COMMON_STAGES | \
194 ZIO_STAGE_WRITE_BP_INIT | \
195 ZIO_STAGE_WRITE_COMPRESS | \
196 ZIO_STAGE_DVA_THROTTLE | \
197 ZIO_STAGE_DVA_ALLOCATE)
199 #define ZIO_DDT_CHILD_WRITE_PIPELINE \
200 (ZIO_INTERLOCK_STAGES | \
201 ZIO_VDEV_IO_STAGES | \
202 ZIO_STAGE_DVA_THROTTLE | \
203 ZIO_STAGE_DVA_ALLOCATE)
205 #define ZIO_DDT_WRITE_PIPELINE \
206 (ZIO_INTERLOCK_STAGES | \
207 ZIO_STAGE_WRITE_BP_INIT | \
208 ZIO_STAGE_ISSUE_ASYNC | \
209 ZIO_STAGE_WRITE_COMPRESS | \
210 ZIO_STAGE_CHECKSUM_GENERATE | \
213 #define ZIO_GANG_STAGES \
214 (ZIO_STAGE_GANG_ASSEMBLE | \
215 ZIO_STAGE_GANG_ISSUE)
217 #define ZIO_FREE_PIPELINE \
218 (ZIO_INTERLOCK_STAGES | \
219 ZIO_STAGE_FREE_BP_INIT | \
222 #define ZIO_DDT_FREE_PIPELINE \
223 (ZIO_INTERLOCK_STAGES | \
224 ZIO_STAGE_FREE_BP_INIT | \
225 ZIO_STAGE_ISSUE_ASYNC | \
228 #define ZIO_CLAIM_PIPELINE \
229 (ZIO_INTERLOCK_STAGES | \
232 #define ZIO_IOCTL_PIPELINE \
233 (ZIO_INTERLOCK_STAGES | \
234 ZIO_STAGE_VDEV_IO_START | \
235 ZIO_STAGE_VDEV_IO_ASSESS)
237 #define ZIO_BLOCKING_STAGES \
238 (ZIO_STAGE_DVA_ALLOCATE | \
239 ZIO_STAGE_DVA_CLAIM | \
240 ZIO_STAGE_VDEV_IO_START)
242 extern void zio_inject_init(void);
243 extern void zio_inject_fini(void);
249 #endif /* _ZIO_IMPL_H */