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 typedef enum zio_stage { 42 ZIO_STAGE_OPEN = 0, /* RWFCI */ 43 ZIO_STAGE_WAIT_FOR_CHILDREN_READY, /* RWFCI */ 44 45 ZIO_STAGE_READ_INIT, /* R---- */ 46 ZIO_STAGE_ISSUE_ASYNC, /* -W--- */ 47 ZIO_STAGE_WRITE_COMPRESS, /* -W--- */ 48 ZIO_STAGE_CHECKSUM_GENERATE, /* -W--- */ 49 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- */ 54 55 ZIO_STAGE_DVA_ALLOCATE, /* -W--- */ 56 ZIO_STAGE_DVA_FREE, /* --F-- */ 57 ZIO_STAGE_DVA_CLAIM, /* ---C- */ 58 59 ZIO_STAGE_GANG_CHECKSUM_GENERATE, /* -W--- */ 60 61 ZIO_STAGE_READY, /* RWFCI */ 62 63 ZIO_STAGE_VDEV_IO_START, /* RW--I */ 64 ZIO_STAGE_VDEV_IO_DONE, /* RW--I */ 65 ZIO_STAGE_VDEV_IO_ASSESS, /* RW--I */ 66 67 ZIO_STAGE_WAIT_FOR_CHILDREN_DONE, /* RWFCI */ 68 69 ZIO_STAGE_CHECKSUM_VERIFY, /* R---- */ 70 ZIO_STAGE_READ_GANG_MEMBERS, /* R---- */ 71 ZIO_STAGE_READ_DECOMPRESS, /* R---- */ 72 73 ZIO_STAGE_ASSESS, /* RWFCI */ 74 ZIO_STAGE_DONE /* RWFCI */ 75 } zio_stage_t; 76 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)) 83 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)) 88 89 #define ZIO_READ_PHYS_PIPELINE \ 90 (ZIO_INTERLOCK_STAGES | \ 91 ZIO_VDEV_IO_STAGES | \ 92 (1U << ZIO_STAGE_CHECKSUM_VERIFY)) 93 94 #define ZIO_READ_GANG_PIPELINE \ 95 ZIO_READ_PHYS_PIPELINE 96 97 #define ZIO_READ_PIPELINE \ 98 (1U << ZIO_STAGE_READ_INIT) | \ 99 ZIO_READ_PHYS_PIPELINE 100 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)) 106 107 #define ZIO_WRITE_PHYS_PIPELINE \ 108 ZIO_WRITE_COMMON_STAGES 109 110 #define ZIO_WRITE_PIPELINE \ 111 (ZIO_WRITE_COMMON_STAGES | \ 112 (1U << ZIO_STAGE_WRITE_COMPRESS) | \ 113 (1U << ZIO_STAGE_DVA_ALLOCATE)) 114 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)) 119 120 #define ZIO_GANG_FREE_STAGES \ 121 ((1U << ZIO_STAGE_GET_GANG_HEADER) | \ 122 (1U << ZIO_STAGE_FREE_GANG_MEMBERS)) 123 124 #define ZIO_GANG_CLAIM_STAGES \ 125 ((1U << ZIO_STAGE_GET_GANG_HEADER) | \ 126 (1U << ZIO_STAGE_CLAIM_GANG_MEMBERS)) 127 128 #define ZIO_REWRITE_PIPELINE(bp) \ 129 (ZIO_WRITE_COMMON_STAGES | \ 130 (BP_IS_GANG(bp) ? ZIO_GANG_REWRITE_STAGES : 0)) 131 132 #define ZIO_WRITE_ALLOCATE_PIPELINE \ 133 (ZIO_WRITE_COMMON_STAGES | \ 134 (1U << ZIO_STAGE_DVA_ALLOCATE)) 135 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)) 140 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)) 145 146 #define ZIO_IOCTL_PIPELINE \ 147 (ZIO_INTERLOCK_STAGES | \ 148 ZIO_VDEV_IO_STAGES) 149 150 151 #define ZIO_WAIT_FOR_CHILDREN_PIPELINE \ 152 ZIO_INTERLOCK_STAGES 153 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)) 159 160 #define ZIO_ERROR_PIPELINE_MASK \ 161 ZIO_INTERLOCK_STAGES 162 163 typedef struct zio_transform zio_transform_t; 164 struct zio_transform { 165 void *zt_data; 166 uint64_t zt_size; 167 uint64_t zt_bufsize; 168 zio_transform_t *zt_next; 169 }; 170 171 extern void zio_inject_init(void); 172 extern void zio_inject_fini(void); 173 174 #ifdef __cplusplus 175 } 176 #endif 177 178 #endif /* _ZIO_IMPL_H */ 179