1 /* $OpenBSD: rf_types.h,v 1.6 2002/12/16 07:01:05 tdeval Exp $ */ 2 /* $NetBSD: rf_types.h,v 1.6 1999/09/05 03:05:55 oster Exp $ */ 3 4 /* 5 * rf_types.h 6 */ 7 /* 8 * Copyright (c) 1995 Carnegie-Mellon University. 9 * All rights reserved. 10 * 11 * Author: Jim Zelenka 12 * 13 * Permission to use, copy, modify and distribute this software and 14 * its documentation is hereby granted, provided that both the copyright 15 * notice and this permission notice appear in all copies of the 16 * software, derivative works or modified versions, and any portions 17 * thereof, and that both notices appear in supporting documentation. 18 * 19 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 20 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 21 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 22 * 23 * Carnegie Mellon requests users of this software to return to 24 * 25 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 26 * School of Computer Science 27 * Carnegie Mellon University 28 * Pittsburgh PA 15213-3890 29 * 30 * any improvements or extensions that they make and grant Carnegie the 31 * rights to redistribute these changes. 32 */ 33 /*********************************************************** 34 * 35 * rf_types.h -- Standard types for RAIDframe. 36 * 37 ***********************************************************/ 38 39 #ifndef _RF__RF_TYPES_H_ 40 #define _RF__RF_TYPES_H_ 41 42 43 #include "rf_archs.h" 44 45 #include <sys/errno.h> 46 #include <sys/types.h> 47 48 #include <sys/uio.h> 49 #include <sys/param.h> 50 #include <sys/lock.h> 51 52 /* 53 * First, define system-dependent types and constants. 54 * 55 * If the machine is big-endian, RF_BIG_ENDIAN should be 1. 56 * Otherwise, it should be 0. 57 * 58 * The various integer types should be self-explanatory; we 59 * use these elsewhere to avoid size confusion. 60 * 61 * LONGSHIFT is lg(sizeof(long)) (that is, log base two of sizeof(long)) 62 * 63 */ 64 65 #include <sys/types.h> 66 #include <sys/limits.h> 67 #include <machine/endian.h> 68 69 #if BYTE_ORDER == BIG_ENDIAN 70 #define RF_IS_BIG_ENDIAN 1 71 #elif BYTE_ORDER == LITTLE_ENDIAN 72 #define RF_IS_BIG_ENDIAN 0 73 #else 74 #error byte order not defined 75 #endif 76 typedef int8_t RF_int8; 77 typedef u_int8_t RF_uint8; 78 typedef int16_t RF_int16; 79 typedef u_int16_t RF_uint16; 80 typedef int32_t RF_int32; 81 typedef u_int32_t RF_uint32; 82 typedef int64_t RF_int64; 83 typedef u_int64_t RF_uint64; 84 #if LONG_BIT == 32 85 #define RF_LONGSHIFT 2 86 #elif LONG_BIT == 64 87 #define RF_LONGSHIFT 3 88 #else 89 #error word size not defined 90 #endif 91 92 /* 93 * These are just zero and non-zero. We don't use "TRUE" 94 * and "FALSE" because there's too much nonsense trying 95 * to get them defined exactly once on every platform, given 96 * the different places they may be defined in system header 97 * files. 98 */ 99 #define RF_TRUE 1 100 #define RF_FALSE 0 101 102 /* 103 * Now, some generic types. 104 */ 105 typedef RF_uint64 RF_IoCount_t; 106 typedef RF_uint64 RF_Offset_t; 107 typedef RF_uint32 RF_PSSFlags_t; 108 typedef RF_uint64 RF_SectorCount_t; 109 typedef RF_uint64 RF_StripeCount_t; 110 typedef RF_int64 RF_SectorNum_t; /* 111 * These are unsigned so we can set 112 * them to (-1) for "uninitialized". 113 */ 114 typedef RF_int64 RF_StripeNum_t; 115 typedef RF_int64 RF_RaidAddr_t; 116 typedef int RF_RowCol_t; /* Unsigned so it can be (-1). */ 117 typedef RF_int64 RF_HeadSepLimit_t; 118 typedef RF_int64 RF_ReconUnitCount_t; 119 typedef int RF_ReconUnitNum_t; 120 121 typedef char RF_ParityConfig_t; 122 123 typedef char RF_DiskQueueType_t[1024]; 124 #define RF_DISK_QUEUE_TYPE_NONE "" 125 126 /* Values for the 'type' field in a reconstruction buffer. */ 127 typedef int RF_RbufType_t; 128 #define RF_RBUF_TYPE_EXCLUSIVE 0 /* 129 * This buf assigned exclusively to 130 * one disk. 131 */ 132 #define RF_RBUF_TYPE_FLOATING 1 /* This is a floating recon buf. */ 133 #define RF_RBUF_TYPE_FORCED 2 /* 134 * This rbuf was allocated to complete 135 * a forced recon. 136 */ 137 138 typedef char RF_IoType_t; 139 #define RF_IO_TYPE_READ 'r' 140 #define RF_IO_TYPE_WRITE 'w' 141 #define RF_IO_TYPE_NOP 'n' 142 #define RF_IO_IS_R_OR_W(_type_) \ 143 (((_type_) == RF_IO_TYPE_READ) || ((_type_) == RF_IO_TYPE_WRITE)) 144 145 typedef void (*RF_VoidFuncPtr) (void *,...); 146 147 typedef RF_uint32 RF_AccessStripeMapFlags_t; 148 typedef RF_uint32 RF_DiskQueueDataFlags_t; 149 typedef RF_uint32 RF_DiskQueueFlags_t; 150 typedef RF_uint32 RF_RaidAccessFlags_t; 151 152 #define RF_DISKQUEUE_DATA_FLAGS_NONE ((RF_DiskQueueDataFlags_t)0) 153 154 typedef struct RF_AccessStripeMap_s RF_AccessStripeMap_t; 155 typedef struct RF_AccessStripeMapHeader_s RF_AccessStripeMapHeader_t; 156 typedef struct RF_AllocListElem_s RF_AllocListElem_t; 157 typedef struct RF_CallbackDesc_s RF_CallbackDesc_t; 158 typedef struct RF_ChunkDesc_s RF_ChunkDesc_t; 159 typedef struct RF_CommonLogData_s RF_CommonLogData_t; 160 typedef struct RF_Config_s RF_Config_t; 161 typedef struct RF_CumulativeStats_s RF_CumulativeStats_t; 162 typedef struct RF_DagHeader_s RF_DagHeader_t; 163 typedef struct RF_DagList_s RF_DagList_t; 164 typedef struct RF_DagNode_s RF_DagNode_t; 165 typedef struct RF_DeclusteredConfigInfo_s RF_DeclusteredConfigInfo_t; 166 typedef struct RF_DiskId_s RF_DiskId_t; 167 typedef struct RF_DiskMap_s RF_DiskMap_t; 168 typedef struct RF_DiskQueue_s RF_DiskQueue_t; 169 typedef struct RF_DiskQueueData_s RF_DiskQueueData_t; 170 typedef struct RF_DiskQueueSW_s RF_DiskQueueSW_t; 171 typedef struct RF_Etimer_s RF_Etimer_t; 172 typedef struct RF_EventCreate_s RF_EventCreate_t; 173 typedef struct RF_FreeList_s RF_FreeList_t; 174 typedef struct RF_LockReqDesc_s RF_LockReqDesc_t; 175 typedef struct RF_LockTableEntry_s RF_LockTableEntry_t; 176 typedef struct RF_MCPair_s RF_MCPair_t; 177 typedef struct RF_OwnerInfo_s RF_OwnerInfo_t; 178 typedef struct RF_ParityLog_s RF_ParityLog_t; 179 typedef struct RF_ParityLogAppendQueue_s RF_ParityLogAppendQueue_t; 180 typedef struct RF_ParityLogData_s RF_ParityLogData_t; 181 typedef struct RF_ParityLogDiskQueue_s RF_ParityLogDiskQueue_t; 182 typedef struct RF_ParityLogQueue_s RF_ParityLogQueue_t; 183 typedef struct RF_ParityLogRecord_s RF_ParityLogRecord_t; 184 typedef struct RF_PerDiskReconCtrl_s RF_PerDiskReconCtrl_t; 185 typedef struct RF_PSStatusHeader_s RF_PSStatusHeader_t; 186 typedef struct RF_PhysDiskAddr_s RF_PhysDiskAddr_t; 187 typedef struct RF_PropHeader_s RF_PropHeader_t; 188 typedef struct RF_Raid_s RF_Raid_t; 189 typedef struct RF_RaidAccessDesc_s RF_RaidAccessDesc_t; 190 typedef struct RF_RaidDisk_s RF_RaidDisk_t; 191 typedef struct RF_RaidLayout_s RF_RaidLayout_t; 192 typedef struct RF_RaidReconDesc_s RF_RaidReconDesc_t; 193 typedef struct RF_ReconBuffer_s RF_ReconBuffer_t; 194 typedef struct RF_ReconConfig_s RF_ReconConfig_t; 195 typedef struct RF_ReconCtrl_s RF_ReconCtrl_t; 196 typedef struct RF_ReconDoneProc_s RF_ReconDoneProc_t; 197 typedef struct RF_ReconEvent_s RF_ReconEvent_t; 198 typedef struct RF_ReconMap_s RF_ReconMap_t; 199 typedef struct RF_ReconMapListElem_s RF_ReconMapListElem_t; 200 typedef struct RF_ReconParityStripeStatus_s RF_ReconParityStripeStatus_t; 201 typedef struct RF_RedFuncs_s RF_RedFuncs_t; 202 typedef struct RF_RegionBufferQueue_s RF_RegionBufferQueue_t; 203 typedef struct RF_RegionInfo_s RF_RegionInfo_t; 204 typedef struct RF_ShutdownList_s RF_ShutdownList_t; 205 typedef struct RF_SpareTableEntry_s RF_SpareTableEntry_t; 206 typedef struct RF_SparetWait_s RF_SparetWait_t; 207 typedef struct RF_StripeLockDesc_s RF_StripeLockDesc_t; 208 typedef struct RF_ThreadGroup_s RF_ThreadGroup_t; 209 typedef struct RF_ThroughputStats_s RF_ThroughputStats_t; 210 211 /* 212 * Important assumptions regarding ordering of the states in this list 213 * have been made !!! 214 * Before disturbing this ordering, look at code in rf_states.c 215 */ 216 typedef enum RF_AccessState_e { 217 /* Original states. */ 218 rf_QuiesceState, /* Handles quiescence for reconstruction. */ 219 rf_IncrAccessesCountState, /* Count accesses in flight. */ 220 rf_DecrAccessesCountState, 221 rf_MapState, /* Map access to disk addresses. */ 222 rf_LockState, /* Take stripe locks. */ 223 rf_CreateDAGState, /* Create DAGs. */ 224 rf_ExecuteDAGState, /* Execute DAGs. */ 225 rf_ProcessDAGState, /* 226 * DAGs are completing - check if correct, or 227 * if we need to retry. 228 */ 229 rf_CleanupState, /* Release stripe locks, clean up. */ 230 rf_LastState /* Must be the last state. */ 231 } RF_AccessState_t; 232 #define RF_MAXROW 10 /* 233 * These are arbitrary and can be modified at 234 * will. 235 */ 236 #define RF_MAXCOL 40 237 #define RF_MAXSPARE 10 238 #define RF_MAXDBGV 75 /* Max number of debug variables. */ 239 #define RF_MAXDBGVLEN 50 /* Max length of debug variables. */ 240 241 union RF_GenericParam_u { 242 void *p; 243 RF_uint64 v; 244 }; 245 typedef union RF_GenericParam_u RF_DagParam_t; 246 typedef union RF_GenericParam_u RF_CBParam_t; 247 248 #endif /* _RF__RF_TYPES_H_ */ 249