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) 2013 by Delphix. All rights reserved.
33 #include <sys/zfs_context.h>
41 * XXX -- Describe ZFS I/O pipeline here. Fill in as needed.
43 * The ZFS I/O pipeline is comprised of various stages which are defined
44 * in the zio_stage enum below. The individual stages are used to construct
45 * these basic I/O operations: Read, Write, Free, Claim, and Ioctl.
47 * I/O operations: (XXX - provide detail for each of the operations)
55 * Although the most common pipeline are used by the basic I/O operations
56 * above, there are some helper pipelines (one could consider them
57 * sub-pipelines) which are used internally by the ZIO module and are
61 * The interlock pipeline is the most basic pipeline and is used by all
62 * of the I/O operations. The interlock pipeline does not perform any I/O
63 * and is used to coordinate the dependencies between I/Os that are being
64 * issued (i.e. the parent/child relationship).
66 * Vdev child Pipeline:
67 * The vdev child pipeline is responsible for performing the physical I/O.
68 * It is in this pipeline where the I/O are queued and possibly cached.
70 * In addition to performing I/O, the pipeline is also responsible for
71 * data transformations. The transformations performed are based on the
72 * specific properties that user may have selected and modify the
73 * behavior of the pipeline. Examples of supported transformations are
74 * compression, dedup, and nop writes. Transformations will either modify
75 * the data or the pipeline. This list below further describes each of
76 * the supported transformations:
79 * ZFS supports three different flavors of compression -- gzip, lzjb, and
80 * zle. Compression occurs as part of the write pipeline and is performed
81 * in the ZIO_STAGE_WRITE_BP_INIT stage.
84 * Dedup reads are handled by the ZIO_STAGE_DDT_READ_START and
85 * ZIO_STAGE_DDT_READ_DONE stages. These stages are added to an existing
86 * read pipeline if the dedup bit is set on the block pointer.
87 * Writing a dedup block is performed by the ZIO_STAGE_DDT_WRITE stage
88 * and added to a write pipeline if a user has enabled dedup on that
92 * The NOP write feature is performed by the ZIO_STAGE_NOP_WRITE stage
93 * and is added to an existing write pipeline if a crypographically
94 * secure checksum (i.e. SHA256) is enabled and compression is turned on.
95 * The NOP write stage will compare the checksums of the current data
96 * on-disk (level-0 blocks only) and the data that is currently being written.
97 * If the checksum values are identical then the pipeline is converted to
98 * an interlock pipeline skipping block allocation and bypassing the
99 * physical I/O. The nop write feature can handle writes in either
100 * syncing or open context (i.e. zil writes) and as a result is mutually
101 * exclusive with dedup.
105 * zio pipeline stage definitions
108 ZIO_STAGE_OPEN
= 1 << 0, /* RWFCI */
110 ZIO_STAGE_READ_BP_INIT
= 1 << 1, /* R---- */
111 ZIO_STAGE_FREE_BP_INIT
= 1 << 2, /* --F-- */
112 ZIO_STAGE_ISSUE_ASYNC
= 1 << 3, /* RWF-- */
113 ZIO_STAGE_WRITE_BP_INIT
= 1 << 4, /* -W--- */
115 ZIO_STAGE_CHECKSUM_GENERATE
= 1 << 5, /* -W--- */
117 ZIO_STAGE_NOP_WRITE
= 1 << 6, /* -W--- */
119 ZIO_STAGE_DDT_READ_START
= 1 << 7, /* R---- */
120 ZIO_STAGE_DDT_READ_DONE
= 1 << 8, /* R---- */
121 ZIO_STAGE_DDT_WRITE
= 1 << 9, /* -W--- */
122 ZIO_STAGE_DDT_FREE
= 1 << 10, /* --F-- */
124 ZIO_STAGE_GANG_ASSEMBLE
= 1 << 11, /* RWFC- */
125 ZIO_STAGE_GANG_ISSUE
= 1 << 12, /* RWFC- */
127 ZIO_STAGE_DVA_ALLOCATE
= 1 << 13, /* -W--- */
128 ZIO_STAGE_DVA_FREE
= 1 << 14, /* --F-- */
129 ZIO_STAGE_DVA_CLAIM
= 1 << 15, /* ---C- */
131 ZIO_STAGE_READY
= 1 << 16, /* RWFCI */
133 ZIO_STAGE_VDEV_IO_START
= 1 << 17, /* RW--I */
134 ZIO_STAGE_VDEV_IO_DONE
= 1 << 18, /* RW--I */
135 ZIO_STAGE_VDEV_IO_ASSESS
= 1 << 19, /* RW--I */
137 ZIO_STAGE_CHECKSUM_VERIFY
= 1 << 20, /* R---- */
139 ZIO_STAGE_DONE
= 1 << 21 /* RWFCI */
142 #define ZIO_INTERLOCK_STAGES \
146 #define ZIO_INTERLOCK_PIPELINE \
149 #define ZIO_VDEV_IO_STAGES \
150 (ZIO_STAGE_VDEV_IO_START | \
151 ZIO_STAGE_VDEV_IO_DONE | \
152 ZIO_STAGE_VDEV_IO_ASSESS)
154 #define ZIO_VDEV_CHILD_PIPELINE \
155 (ZIO_VDEV_IO_STAGES | \
158 #define ZIO_READ_COMMON_STAGES \
159 (ZIO_INTERLOCK_STAGES | \
160 ZIO_VDEV_IO_STAGES | \
161 ZIO_STAGE_CHECKSUM_VERIFY)
163 #define ZIO_READ_PHYS_PIPELINE \
164 ZIO_READ_COMMON_STAGES
166 #define ZIO_READ_PIPELINE \
167 (ZIO_READ_COMMON_STAGES | \
168 ZIO_STAGE_READ_BP_INIT)
170 #define ZIO_DDT_CHILD_READ_PIPELINE \
171 ZIO_READ_COMMON_STAGES
173 #define ZIO_DDT_READ_PIPELINE \
174 (ZIO_INTERLOCK_STAGES | \
175 ZIO_STAGE_READ_BP_INIT | \
176 ZIO_STAGE_DDT_READ_START | \
177 ZIO_STAGE_DDT_READ_DONE)
179 #define ZIO_WRITE_COMMON_STAGES \
180 (ZIO_INTERLOCK_STAGES | \
181 ZIO_VDEV_IO_STAGES | \
182 ZIO_STAGE_ISSUE_ASYNC | \
183 ZIO_STAGE_CHECKSUM_GENERATE)
185 #define ZIO_WRITE_PHYS_PIPELINE \
186 ZIO_WRITE_COMMON_STAGES
188 #define ZIO_REWRITE_PIPELINE \
189 (ZIO_WRITE_COMMON_STAGES | \
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_DVA_ALLOCATE)
197 #define ZIO_DDT_CHILD_WRITE_PIPELINE \
198 (ZIO_INTERLOCK_STAGES | \
199 ZIO_VDEV_IO_STAGES | \
200 ZIO_STAGE_DVA_ALLOCATE)
202 #define ZIO_DDT_WRITE_PIPELINE \
203 (ZIO_INTERLOCK_STAGES | \
204 ZIO_STAGE_ISSUE_ASYNC | \
205 ZIO_STAGE_WRITE_BP_INIT | \
206 ZIO_STAGE_CHECKSUM_GENERATE | \
209 #define ZIO_GANG_STAGES \
210 (ZIO_STAGE_GANG_ASSEMBLE | \
211 ZIO_STAGE_GANG_ISSUE)
213 #define ZIO_FREE_PIPELINE \
214 (ZIO_INTERLOCK_STAGES | \
215 ZIO_STAGE_FREE_BP_INIT | \
218 #define ZIO_DDT_FREE_PIPELINE \
219 (ZIO_INTERLOCK_STAGES | \
220 ZIO_STAGE_FREE_BP_INIT | \
221 ZIO_STAGE_ISSUE_ASYNC | \
224 #define ZIO_CLAIM_PIPELINE \
225 (ZIO_INTERLOCK_STAGES | \
228 #define ZIO_IOCTL_PIPELINE \
229 (ZIO_INTERLOCK_STAGES | \
230 ZIO_STAGE_VDEV_IO_START | \
231 ZIO_STAGE_VDEV_IO_ASSESS)
233 #define ZIO_BLOCKING_STAGES \
234 (ZIO_STAGE_DVA_ALLOCATE | \
235 ZIO_STAGE_DVA_CLAIM | \
236 ZIO_STAGE_VDEV_IO_START)
238 extern void zio_inject_init(void);
239 extern void zio_inject_fini(void);
245 #endif /* _ZIO_IMPL_H */