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