| 1 | /*	$NetBSD: raidframevar.h,v 1.19 2018/04/19 21:50:09 christos Exp $ */ | 
| 2 | /*- | 
| 3 |  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. | 
| 4 |  * All rights reserved. | 
| 5 |  * | 
| 6 |  * This code is derived from software contributed to The NetBSD Foundation | 
| 7 |  * by Greg Oster | 
| 8 |  * | 
| 9 |  * Redistribution and use in source and binary forms, with or without | 
| 10 |  * modification, are permitted provided that the following conditions | 
| 11 |  * are met: | 
| 12 |  * 1. Redistributions of source code must retain the above copyright | 
| 13 |  *    notice, this list of conditions and the following disclaimer. | 
| 14 |  * 2. Redistributions in binary form must reproduce the above copyright | 
| 15 |  *    notice, this list of conditions and the following disclaimer in the | 
| 16 |  *    documentation and/or other materials provided with the distribution. | 
| 17 |  * | 
| 18 |  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 
| 19 |  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 
| 20 |  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
| 21 |  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 
| 22 |  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
| 23 |  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
| 24 |  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
| 25 |  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
| 26 |  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
| 27 |  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
| 28 |  * POSSIBILITY OF SUCH DAMAGE. | 
| 29 |  */ | 
| 30 | /* | 
| 31 |  * Copyright (c) 1995 Carnegie-Mellon University. | 
| 32 |  * All rights reserved. | 
| 33 |  * | 
| 34 |  * Author: Mark Holland | 
| 35 |  * | 
| 36 |  * Permission to use, copy, modify and distribute this software and | 
| 37 |  * its documentation is hereby granted, provided that both the copyright | 
| 38 |  * notice and this permission notice appear in all copies of the | 
| 39 |  * software, derivative works or modified versions, and any portions | 
| 40 |  * thereof, and that both notices appear in supporting documentation. | 
| 41 |  * | 
| 42 |  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 
| 43 |  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | 
| 44 |  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | 
| 45 |  * | 
| 46 |  * Carnegie Mellon requests users of this software to return to | 
| 47 |  * | 
| 48 |  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU | 
| 49 |  *  School of Computer Science | 
| 50 |  *  Carnegie Mellon University | 
| 51 |  *  Pittsburgh PA 15213-3890 | 
| 52 |  * | 
| 53 |  * any improvements or extensions that they make and grant Carnegie the | 
| 54 |  * rights to redistribute these changes. | 
| 55 |  */ | 
| 56 |  | 
| 57 | /* | 
| 58 |  * Copyright (c) 1995 Carnegie-Mellon University. | 
| 59 |  * All rights reserved. | 
| 60 |  * | 
| 61 |  * Author: Jim Zelenka | 
| 62 |  * | 
| 63 |  * Permission to use, copy, modify and distribute this software and | 
| 64 |  * its documentation is hereby granted, provided that both the copyright | 
| 65 |  * notice and this permission notice appear in all copies of the | 
| 66 |  * software, derivative works or modified versions, and any portions | 
| 67 |  * thereof, and that both notices appear in supporting documentation. | 
| 68 |  * | 
| 69 |  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | 
| 70 |  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND | 
| 71 |  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | 
| 72 |  * | 
| 73 |  * Carnegie Mellon requests users of this software to return to | 
| 74 |  * | 
| 75 |  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU | 
| 76 |  *  School of Computer Science | 
| 77 |  *  Carnegie Mellon University | 
| 78 |  *  Pittsburgh PA 15213-3890 | 
| 79 |  * | 
| 80 |  * any improvements or extensions that they make and grant Carnegie the | 
| 81 |  * rights to redistribute these changes. | 
| 82 |  */ | 
| 83 |  | 
| 84 | /***************************************************** | 
| 85 |  * | 
| 86 |  * raidframevar.h | 
| 87 |  * | 
| 88 |  * main header file for using raidframe in the kernel. | 
| 89 |  * | 
| 90 |  *****************************************************/ | 
| 91 |  | 
| 92 |  | 
| 93 | #ifndef _RF_RAIDFRAMEVAR_H_ | 
| 94 | #define _RF_RAIDFRAMEVAR_H_ | 
| 95 |  | 
| 96 | #ifndef _STANDALONE | 
| 97 | #include <sys/ioctl.h> | 
| 98 |  | 
| 99 | #include <sys/errno.h> | 
| 100 | #include <sys/types.h> | 
| 101 |  | 
| 102 | #include <sys/uio.h> | 
| 103 | #include <sys/param.h> | 
| 104 | #include <sys/proc.h> | 
| 105 |  | 
| 106 | #include <sys/mallocvar.h> | 
| 107 | #endif | 
| 108 |  | 
| 109 | /* | 
| 110 |  * First, define system-dependent types and constants. | 
| 111 |  * | 
| 112 |  * If the machine is big-endian, RF_BIG_ENDIAN should be 1. | 
| 113 |  * Otherwise, it should be 0. | 
| 114 |  * | 
| 115 |  * The various integer types should be self-explanatory; we | 
| 116 |  * use these elsewhere to avoid size confusion. | 
| 117 |  * | 
| 118 |  * LONGSHIFT is lg(sizeof(long)) (that is, log base two of sizeof(long) | 
| 119 |  * | 
| 120 |  */ | 
| 121 |  | 
| 122 | #include <sys/types.h> | 
| 123 | #include <machine/endian.h> | 
| 124 | #include <machine/limits.h> | 
| 125 |  | 
| 126 | #if BYTE_ORDER == BIG_ENDIAN | 
| 127 | #define RF_IS_BIG_ENDIAN    1 | 
| 128 | #elif BYTE_ORDER == LITTLE_ENDIAN | 
| 129 | #define RF_IS_BIG_ENDIAN    0 | 
| 130 | #else | 
| 131 | #error byte order not defined | 
| 132 | #endif | 
| 133 | typedef int8_t RF_int8; | 
| 134 | typedef u_int8_t RF_uint8; | 
| 135 | typedef int16_t RF_int16; | 
| 136 | typedef u_int16_t RF_uint16; | 
| 137 | typedef int32_t RF_int32; | 
| 138 | typedef u_int32_t RF_uint32; | 
| 139 | typedef int64_t RF_int64; | 
| 140 | typedef u_int64_t RF_uint64; | 
| 141 | #if LONG_BIT == 32 | 
| 142 | #define RF_LONGSHIFT        2 | 
| 143 | #elif LONG_BIT == 64 | 
| 144 | #define RF_LONGSHIFT        3 | 
| 145 | #else | 
| 146 | #error word size not defined | 
| 147 | #endif | 
| 148 |  | 
| 149 | /* | 
| 150 |  * These are just zero and non-zero. We don't use "TRUE" | 
| 151 |  * and "FALSE" because there's too much nonsense trying | 
| 152 |  * to get them defined exactly once on every platform, given | 
| 153 |  * the different places they may be defined in system header | 
| 154 |  * files. | 
| 155 |  */ | 
| 156 | #define RF_TRUE  1 | 
| 157 | #define RF_FALSE 0 | 
| 158 |  | 
| 159 | /* Malloc types. */ | 
| 160 | #ifdef _KERNEL | 
| 161 | MALLOC_DECLARE(M_RAIDFRAME); | 
| 162 | #endif | 
| 163 |  | 
| 164 | /* | 
| 165 |  * Now, some generic types | 
| 166 |  */ | 
| 167 | typedef RF_uint64 RF_IoCount_t; | 
| 168 | typedef RF_uint64 RF_Offset_t; | 
| 169 | typedef RF_uint32 RF_PSSFlags_t; | 
| 170 | typedef RF_uint64 RF_SectorCount_t; | 
| 171 | typedef RF_uint64 RF_StripeCount_t; | 
| 172 | typedef RF_int64 RF_SectorNum_t;/* these are unsigned so we can set them to | 
| 173 | 				 * (-1) for "uninitialized" */ | 
| 174 | typedef RF_int64 RF_StripeNum_t; | 
| 175 | typedef RF_int64 RF_RaidAddr_t; | 
| 176 | typedef int RF_RowCol_t;	/* unsigned so it can be (-1) */ | 
| 177 | typedef RF_int64 RF_HeadSepLimit_t; | 
| 178 | typedef RF_int64 RF_ReconUnitCount_t; | 
| 179 | typedef int RF_ReconUnitNum_t; | 
| 180 |  | 
| 181 | typedef char RF_ParityConfig_t; | 
| 182 |  | 
| 183 | typedef char RF_DiskQueueType_t[1024]; | 
| 184 | #define RF_DISK_QUEUE_TYPE_NONE "" | 
| 185 |  | 
| 186 | /* values for the 'type' field in a reconstruction buffer */ | 
| 187 | typedef int RF_RbufType_t; | 
| 188 | #define RF_RBUF_TYPE_EXCLUSIVE   0	/* this buf assigned exclusively to | 
| 189 | 					 * one disk */ | 
| 190 | #define RF_RBUF_TYPE_FLOATING    1	/* this is a floating recon buf */ | 
| 191 | #define RF_RBUF_TYPE_FORCED      2	/* this rbuf was allocated to complete | 
| 192 | 					 * a forced recon */ | 
| 193 |  | 
| 194 | typedef char RF_IoType_t; | 
| 195 | #define RF_IO_TYPE_READ          'r' | 
| 196 | #define RF_IO_TYPE_WRITE         'w' | 
| 197 | #define RF_IO_TYPE_NOP           'n' | 
| 198 | #define RF_IO_IS_R_OR_W(_type_) (((_type_) == RF_IO_TYPE_READ) \ | 
| 199 |                                 || ((_type_) == RF_IO_TYPE_WRITE)) | 
| 200 |  | 
| 201 | typedef void (*RF_VoidFuncPtr) (void *,...); | 
| 202 |  | 
| 203 | typedef RF_uint32 RF_AccessStripeMapFlags_t; | 
| 204 | typedef RF_uint32 RF_DiskQueueDataFlags_t; | 
| 205 | typedef RF_uint32 RF_DiskQueueFlags_t; | 
| 206 | typedef RF_uint32 RF_RaidAccessFlags_t; | 
| 207 |  | 
| 208 | #define RF_DISKQUEUE_DATA_FLAGS_NONE ((RF_DiskQueueDataFlags_t)0) | 
| 209 |  | 
| 210 | typedef struct RF_AccessStripeMap_s RF_AccessStripeMap_t; | 
| 211 | typedef struct  ; | 
| 212 | typedef struct RF_AllocListElem_s RF_AllocListElem_t; | 
| 213 | typedef struct RF_CallbackDesc_s RF_CallbackDesc_t; | 
| 214 | typedef struct RF_ChunkDesc_s RF_ChunkDesc_t; | 
| 215 | typedef struct RF_CommonLogData_s RF_CommonLogData_t; | 
| 216 | typedef struct RF_Config_s RF_Config_t; | 
| 217 | typedef struct RF_CumulativeStats_s RF_CumulativeStats_t; | 
| 218 | typedef struct  ; | 
| 219 | typedef struct RF_DagList_s RF_DagList_t; | 
| 220 | typedef struct RF_DagNode_s RF_DagNode_t; | 
| 221 | typedef struct RF_DeclusteredConfigInfo_s RF_DeclusteredConfigInfo_t; | 
| 222 | typedef struct RF_DiskId_s RF_DiskId_t; | 
| 223 | typedef struct RF_DiskMap_s RF_DiskMap_t; | 
| 224 | typedef struct RF_DiskQueue_s RF_DiskQueue_t; | 
| 225 | typedef struct RF_DiskQueueData_s RF_DiskQueueData_t; | 
| 226 | typedef struct RF_DiskQueueSW_s RF_DiskQueueSW_t; | 
| 227 | typedef struct RF_Etimer_s RF_Etimer_t; | 
| 228 | typedef struct RF_EventCreate_s RF_EventCreate_t; | 
| 229 | typedef struct RF_FreeList_s RF_FreeList_t; | 
| 230 | typedef struct RF_LockReqDesc_s RF_LockReqDesc_t; | 
| 231 | typedef struct RF_LockTableEntry_s RF_LockTableEntry_t; | 
| 232 | typedef struct RF_MCPair_s RF_MCPair_t; | 
| 233 | typedef struct RF_OwnerInfo_s RF_OwnerInfo_t; | 
| 234 | typedef struct RF_ParityLog_s RF_ParityLog_t; | 
| 235 | typedef struct RF_ParityLogAppendQueue_s RF_ParityLogAppendQueue_t; | 
| 236 | typedef struct RF_ParityLogData_s RF_ParityLogData_t; | 
| 237 | typedef struct RF_ParityLogDiskQueue_s RF_ParityLogDiskQueue_t; | 
| 238 | typedef struct RF_ParityLogQueue_s RF_ParityLogQueue_t; | 
| 239 | typedef struct RF_ParityLogRecord_s RF_ParityLogRecord_t; | 
| 240 | typedef struct RF_PerDiskReconCtrl_s RF_PerDiskReconCtrl_t; | 
| 241 | typedef struct  ; | 
| 242 | typedef struct RF_PhysDiskAddr_s RF_PhysDiskAddr_t; | 
| 243 | typedef struct  ; | 
| 244 | typedef struct RF_Raid_s RF_Raid_t; | 
| 245 | typedef struct RF_RaidAccessDesc_s RF_RaidAccessDesc_t; | 
| 246 | typedef struct RF_RaidDisk_s RF_RaidDisk_t; | 
| 247 | typedef struct RF_RaidLayout_s RF_RaidLayout_t; | 
| 248 | typedef struct RF_RaidReconDesc_s RF_RaidReconDesc_t; | 
| 249 | typedef struct RF_ReconBuffer_s RF_ReconBuffer_t; | 
| 250 | typedef struct RF_ReconConfig_s RF_ReconConfig_t; | 
| 251 | typedef struct RF_ReconCtrl_s RF_ReconCtrl_t; | 
| 252 | typedef struct RF_ReconDoneProc_s RF_ReconDoneProc_t; | 
| 253 | typedef struct RF_ReconEvent_s RF_ReconEvent_t; | 
| 254 | typedef struct RF_ReconMap_s RF_ReconMap_t; | 
| 255 | typedef struct RF_ReconMapListElem_s RF_ReconMapListElem_t; | 
| 256 | typedef struct RF_ReconParityStripeStatus_s RF_ReconParityStripeStatus_t; | 
| 257 | typedef struct RF_RedFuncs_s RF_RedFuncs_t; | 
| 258 | typedef struct RF_RegionBufferQueue_s RF_RegionBufferQueue_t; | 
| 259 | typedef struct RF_RegionInfo_s RF_RegionInfo_t; | 
| 260 | typedef struct RF_ShutdownList_s RF_ShutdownList_t; | 
| 261 | typedef struct RF_SpareTableEntry_s RF_SpareTableEntry_t; | 
| 262 | typedef struct RF_SparetWait_s RF_SparetWait_t; | 
| 263 | typedef struct RF_StripeLockDesc_s RF_StripeLockDesc_t; | 
| 264 | typedef struct RF_ThreadGroup_s RF_ThreadGroup_t; | 
| 265 | typedef struct RF_ThroughputStats_s RF_ThroughputStats_t; | 
| 266 |  | 
| 267 | struct rf_paritymap; | 
| 268 | struct rf_paritymap_ondisk; | 
| 269 |  | 
| 270 | /* | 
| 271 |  * Important assumptions regarding ordering of the states in this list | 
| 272 |  * have been made!!!  Before disturbing this ordering, look at code in | 
| 273 |  * sys/dev/raidframe/rf_states.c | 
| 274 |  */ | 
| 275 | typedef enum RF_AccessState_e { | 
| 276 | 	/* original states */ | 
| 277 | 	rf_QuiesceState,	    /* handles queisence for reconstruction */ | 
| 278 | 	rf_IncrAccessesCountState,  /* count accesses in flight */ | 
| 279 | 	rf_MapState,		    /* map access to disk addresses */ | 
| 280 | 	rf_LockState,		    /* take stripe locks */ | 
| 281 | 	rf_CreateDAGState,	    /* create DAGs */ | 
| 282 | 	rf_ExecuteDAGState,	    /* execute DAGs */ | 
| 283 | 	rf_ProcessDAGState,	    /* DAGs are completing- check if correct, | 
| 284 | 				     * or if we need to retry */ | 
| 285 | 	rf_CleanupState,	    /* release stripe locks, clean up */ | 
| 286 | 	rf_DecrAccessesCountState, | 
| 287 | 	rf_LastState		    /* must be the last state */ | 
| 288 | }       RF_AccessState_t; | 
| 289 |  | 
| 290 |  | 
| 291 | /* Some constants related to RAIDframe.  These are arbitrary and | 
| 292 |    can be modified at will. */ | 
| 293 |  | 
| 294 | #define RF_MAXROW    10 | 
| 295 | #define RF_MAXCOL    40 | 
| 296 | #define RF_MAXSPARE  10 | 
| 297 | #define RF_MAXDBGV   75		    /* max number of debug variables */ | 
| 298 | #define RF_MAX_DISKS 128	    /* max disks per array */ | 
| 299 | #define RF_SPAREMAP_NAME_LEN 128 | 
| 300 | #define RF_PROTECTED_SECTORS 64L    /* # of sectors at start of disk to | 
| 301 | 				       exclude from RAID address space */ | 
| 302 |  | 
| 303 | struct RF_SpareTableEntry_s { | 
| 304 |         u_int   spareDisk;          /* disk to which this block is spared */ | 
| 305 |         u_int   spareBlockOffsetInSUs;  /* offset into spare table for that | 
| 306 |                                          * disk */ | 
| 307 | }; | 
| 308 |  | 
| 309 | union RF_GenericParam_u { | 
| 310 | 	void   *p; | 
| 311 | 	RF_uint64 v; | 
| 312 | }; | 
| 313 | typedef union RF_GenericParam_u RF_DagParam_t; | 
| 314 | typedef union RF_GenericParam_u RF_CBParam_t; | 
| 315 |  | 
| 316 | /* the raidframe configuration, passed down through an ioctl. | 
| 317 |  * the driver can be reconfigured (with total loss of data) at any time, | 
| 318 |  * but it must be shut down first. | 
| 319 |  */ | 
| 320 | struct RF_Config_s { | 
| 321 | 	RF_RowCol_t numCol, numSpare;		/* number of columns, | 
| 322 | 						 * and spare disks */ | 
| 323 | 	dev_t   devs[RF_MAXROW][RF_MAXCOL];	/* device numbers for disks | 
| 324 | 						 * comprising array */ | 
| 325 | 	char    devnames[RF_MAXROW][RF_MAXCOL][50];	/* device names */ | 
| 326 | 	dev_t   spare_devs[RF_MAXSPARE];	/* device numbers for spare | 
| 327 | 						 * disks */ | 
| 328 | 	char    spare_names[RF_MAXSPARE][50];	/* device names */ | 
| 329 | 	RF_SectorNum_t sectPerSU;	/* sectors per stripe unit */ | 
| 330 | 	RF_StripeNum_t SUsPerPU;/* stripe units per parity unit */ | 
| 331 | 	RF_StripeNum_t SUsPerRU;/* stripe units per reconstruction unit */ | 
| 332 | 	RF_ParityConfig_t parityConfig;	/* identifies the RAID architecture to | 
| 333 | 					 * be used */ | 
| 334 | 	RF_DiskQueueType_t diskQueueType;	/* 'f' = fifo, 'c' = cvscan, | 
| 335 | 						 * not used in kernel */ | 
| 336 | 	char    maxOutstandingDiskReqs;	/* # concurrent reqs to be sent to a | 
| 337 | 					 * disk.  not used in kernel. */ | 
| 338 | 	char    debugVars[RF_MAXDBGV][50];	/* space for specifying debug | 
| 339 | 						 * variables & their values */ | 
| 340 | 	unsigned int layoutSpecificSize;	/* size in bytes of | 
| 341 | 						 * layout-specific info */ | 
| 342 | 	void   *layoutSpecific;	/* a pointer to a layout-specific structure to | 
| 343 | 				 * be copied in */ | 
| 344 | 	int     force;                          /* if !0, ignore many fatal | 
| 345 | 						   configuration conditions */ | 
| 346 | 	/* | 
| 347 | 	   "force" is used to override cases where the component labels would | 
| 348 | 	   indicate that configuration should not proceed without user | 
| 349 | 	   intervention | 
| 350 | 	 */ | 
| 351 | }; | 
| 352 |  | 
| 353 | typedef RF_uint32 RF_ReconReqFlags_t; | 
| 354 | /* flags that can be put in the rf_recon_req structure */ | 
| 355 | #define RF_FDFLAGS_NONE   0x0	/* just fail the disk */ | 
| 356 | #define RF_FDFLAGS_RECON  0x1	/* fail and initiate recon */ | 
| 357 |  | 
| 358 | struct rf_recon_req {		/* used to tell the kernel to fail a disk */ | 
| 359 | 	RF_RowCol_t col; | 
| 360 | 	RF_ReconReqFlags_t flags; | 
| 361 | }; | 
| 362 |  | 
| 363 | struct RF_SparetWait_s { | 
| 364 | 	int     C, G, fcol;	/* C = # disks in row, G = # units in stripe, | 
| 365 | 				 * fcol = which disk has failed */ | 
| 366 |  | 
| 367 | 	RF_StripeCount_t SUsPerPU;	/* this stuff is the info required to | 
| 368 | 					 * create a spare table */ | 
| 369 | 	int     TablesPerSpareRegion; | 
| 370 | 	int     BlocksPerTable; | 
| 371 | 	RF_StripeCount_t TableDepthInPUs; | 
| 372 | 	RF_StripeCount_t SpareSpaceDepthPerRegionInSUs; | 
| 373 |  | 
| 374 | 	RF_SparetWait_t *next;	/* used internally; need not be set at ioctl | 
| 375 | 				 * time */ | 
| 376 | }; | 
| 377 | /* | 
| 378 |  * A physical disk can be in one of several states: | 
| 379 |  * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK(). | 
| 380 |  */ | 
| 381 | enum RF_DiskStatus_e { | 
| 382 | 	rf_ds_optimal,          /* no problems */ | 
| 383 | 	rf_ds_failed,           /* disk has failed */ | 
| 384 | 	rf_ds_reconstructing,   /* reconstruction ongoing */ | 
| 385 | 	rf_ds_dist_spared,      /* reconstruction complete to distributed | 
| 386 |                                  * spare space, dead disk not yet replaced */ | 
| 387 | 	rf_ds_spared,           /* reconstruction complete, dead disk not  | 
| 388 | 				   yet replaced */ | 
| 389 | 	rf_ds_spare,            /* an available spare disk */ | 
| 390 | 	rf_ds_used_spare,       /* a spare which has been used, and hence is | 
| 391 |                                  * not available */ | 
| 392 | 	rf_ds_rebuilding_spare	/* a spare which is being rebuilt to */ | 
| 393 | }; | 
| 394 | typedef enum RF_DiskStatus_e RF_DiskStatus_t; | 
| 395 |  | 
| 396 | struct RF_RaidDisk_s { | 
| 397 |         char    devname[56];    /* name of device file */ | 
| 398 |         RF_DiskStatus_t status; /* whether it is up or down */ | 
| 399 |         RF_RowCol_t spareCol;   /* if in status "spared", this identifies the | 
| 400 |                                  * spare disk */ | 
| 401 |         int     blockSize; | 
| 402 |         int     auto_configured;/* 1 if this component was autoconfigured. | 
| 403 |                                    0 otherwise. */ | 
| 404 |         RF_SectorCount_t numBlocks;     /* number of blocks, obtained via READ | 
| 405 |                                          * CAPACITY */ | 
| 406 |         RF_SectorCount_t partitionSize; /* The *actual* and *full* size of | 
| 407 |                                            the partition, from the disklabel */ | 
| 408 |         dev_t   dev; | 
| 409 | }; | 
| 410 | #if 0 | 
| 411 | /* The per-component label information that the user can set */ | 
| 412 | typedef struct RF_ComponentInfo_s { | 
| 413 | 	int row;              /* the row number of this component */ | 
| 414 | 	int column;           /* the column number of this component */ | 
| 415 | 	int serial_number;    /* a user-specified serial number for this | 
| 416 | 				 RAID set */ | 
| 417 | } RF_ComponentInfo_t; | 
| 418 | #endif | 
| 419 |  | 
| 420 | /* The per-component label information */ | 
| 421 | typedef struct RF_ComponentLabel_s { | 
| 422 | 	int version;          /* The version of this label. */ | 
| 423 | 	int serial_number;    /* a user-specified serial number for this | 
| 424 | 				 RAID set */ | 
| 425 | 	int mod_counter;      /* modification counter.  Changed (usually | 
| 426 | 				 by incrementing) every time the label | 
| 427 | 				 is changed */ | 
| 428 | 	int row;              /* the row number of this component */ | 
| 429 | 	int column;           /* the column number of this component */ | 
| 430 | 	int num_rows;         /* number of rows in this RAID set */ | 
| 431 | 	int num_columns;      /* number of columns in this RAID set */ | 
| 432 | 	int clean;            /* 1 when clean, 0 when dirty */ | 
| 433 | 	int status;           /* rf_ds_optimal, rf_ds_dist_spared, whatever. */ | 
| 434 | 	/* stuff that will be in version 2 of the label */ | 
| 435 | 	int sectPerSU;        /* Sectors per Stripe Unit */ | 
| 436 | 	int SUsPerPU;         /* Stripe Units per Parity Units */ | 
| 437 | 	int SUsPerRU;         /* Stripe Units per Reconstruction Units */ | 
| 438 | 	int parityConfig;     /* '0' == RAID0, '1' == RAID1, etc. */ | 
| 439 | 	int maxOutstanding;   /* maxOutstanding disk requests */ | 
| 440 | 	int blockSize;        /* size of component block. | 
| 441 | 				 (disklabel->d_secsize) */ | 
| 442 | 	u_int __numBlocks;    /* number of blocks on this component.  May | 
| 443 | 			         be smaller than the partition size. */ | 
| 444 | 	u_int __partitionSize;/* number of blocks on this *partition*. | 
| 445 | 				 Must exactly match the partition size | 
| 446 | 				 from the disklabel. */ | 
| 447 | 	/* Parity map stuff. */ | 
| 448 | 	int parity_map_modcount; /* If equal to mod_counter, then the last | 
| 449 | 				    kernel to touch this label was | 
| 450 | 				    parity-map-enabled. */ | 
| 451 | 	u_int parity_map_flags;  /* See top of rf_paritymap.h */ | 
| 452 | 	int parity_map_tickms; /* Length of parity map cooldown ticks. */ | 
| 453 | 	int parity_map_ntick;  /* Number of parity map cooldown ticks. */ | 
| 454 | 	u_int parity_map_regions; /* Number of parity map regions. */ | 
| 455 | 	int future_use[28];   /* Future expansion */ | 
| 456 |  | 
| 457 | 	int autoconfigure;    /* automatically configure this RAID set. | 
| 458 | 				 0 == no, 1 == yes */ | 
| 459 | 	int root_partition;   /* Use this set as / | 
| 460 | 				 0 == no, 1 == yes*/ | 
| 461 | 	int last_unit;        /* last unit number (e.g. 0 for /dev/raid0) | 
| 462 | 				 of this component.  Used for autoconfigure | 
| 463 | 				 only. */ | 
| 464 | 	int config_order;     /* 0 .. n.  The order in which the component | 
| 465 | 				 should be auto-configured.  E.g. 0 is will | 
| 466 | 				 done first, (and would become raid0). | 
| 467 | 				 This may be in conflict with last_unit!!?! */ | 
| 468 | 	                      /* Not currently used. */ | 
| 469 | 	u_int numBlocksHi;    /* The top 32-bits of the numBlocks member. */ | 
| 470 | 	u_int partitionSizeHi;/* The top 32-bits of the partitionSize member. */ | 
| 471 | 	int future_use2[42];  /* More future expansion */ | 
| 472 | } RF_ComponentLabel_t; | 
| 473 |  | 
| 474 | /* | 
| 475 |  * Following four functions are access macros for the number of blocks | 
| 476 |  * and partition size in component label. | 
| 477 |  */ | 
| 478 | static __inline RF_SectorCount_t | 
| 479 | rf_component_label_numblocks(const RF_ComponentLabel_t *cl) | 
| 480 | { | 
| 481 |  | 
| 482 | 	return ((RF_SectorCount_t)cl->numBlocksHi << 32) | | 
| 483 | 	    cl->__numBlocks; | 
| 484 | } | 
| 485 |  | 
| 486 | static __inline void | 
| 487 | rf_component_label_set_numblocks(RF_ComponentLabel_t *cl, RF_SectorCount_t siz) | 
| 488 | { | 
| 489 |  | 
| 490 | 	cl->numBlocksHi = siz >> 32; | 
| 491 | 	cl->__numBlocks = siz; | 
| 492 | } | 
| 493 |  | 
| 494 | static __inline RF_SectorCount_t | 
| 495 | rf_component_label_partitionsize(const RF_ComponentLabel_t *cl) | 
| 496 | { | 
| 497 |  | 
| 498 | 	return ((RF_SectorCount_t)cl->partitionSizeHi << 32) | | 
| 499 | 	    cl->__partitionSize; | 
| 500 | } | 
| 501 |  | 
| 502 | static __inline void | 
| 503 | rf_component_label_set_partitionsize(RF_ComponentLabel_t *cl, | 
| 504 |     RF_SectorCount_t siz) | 
| 505 | { | 
| 506 |  | 
| 507 | 	cl->partitionSizeHi = siz >> 32; | 
| 508 | 	cl->__partitionSize = siz; | 
| 509 | } | 
| 510 |  | 
| 511 | typedef struct RF_SingleComponent_s { | 
| 512 | 	int row;		/* obsolete */ | 
| 513 | 	int column; | 
| 514 | 	char component_name[50]; /* name of the component */ | 
| 515 | } RF_SingleComponent_t; | 
| 516 |  | 
| 517 | typedef struct RF_DeviceConfig_s { | 
| 518 | 	u_int   cols; | 
| 519 | 	u_int   maxqdepth; | 
| 520 | 	int     ndevs; | 
| 521 | 	RF_RaidDisk_t devs[RF_MAX_DISKS]; | 
| 522 | 	int     nspares; | 
| 523 | 	RF_RaidDisk_t spares[RF_MAX_DISKS]; | 
| 524 | }       RF_DeviceConfig_t; | 
| 525 |  | 
| 526 | typedef struct RF_ProgressInfo_s { | 
| 527 | 	RF_uint64 remaining; | 
| 528 | 	RF_uint64 completed; | 
| 529 | 	RF_uint64 total; | 
| 530 | } RF_ProgressInfo_t; | 
| 531 |  | 
| 532 | #ifndef _STANDALONE | 
| 533 | typedef struct RF_LayoutSW_s { | 
| 534 | 	RF_ParityConfig_t parityConfig; | 
| 535 | 	const char *configName; | 
| 536 |  | 
| 537 | #ifndef _KERNEL | 
| 538 | 	/* layout-specific parsing */ | 
| 539 | 	int     (*MakeLayoutSpecific) (FILE * fp, RF_Config_t * cfgPtr, | 
| 540 | 				       void *arg); | 
| 541 | 	void   *makeLayoutSpecificArg; | 
| 542 | #else				/* !KERNEL */ | 
| 543 |  | 
| 544 | 	/* initialization routine */ | 
| 545 | 	int     (*Configure) (RF_ShutdownList_t ** shutdownListp, | 
| 546 | 			      RF_Raid_t * raidPtr, RF_Config_t * cfgPtr); | 
| 547 |  | 
| 548 | 	/* routine to map RAID sector address -> physical (col, offset) */ | 
| 549 | 	void    (*MapSector) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector, | 
| 550 | 			      RF_RowCol_t * col, | 
| 551 | 			      RF_SectorNum_t * diskSector, int remap); | 
| 552 |  | 
| 553 | 	/* routine to map RAID sector address -> physical (c,o) of parity | 
| 554 | 	 * unit */ | 
| 555 | 	void    (*MapParity) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector, | 
| 556 | 			      RF_RowCol_t * col, | 
| 557 | 			      RF_SectorNum_t * diskSector, int remap); | 
| 558 |  | 
| 559 | 	/* routine to map RAID sector address -> physical (c,o) of Q unit */ | 
| 560 | 	void    (*MapQ) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector, | 
| 561 | 			 RF_RowCol_t * col, | 
| 562 | 			 RF_SectorNum_t * diskSector, int remap); | 
| 563 |  | 
| 564 | 	/* routine to identify the disks comprising a stripe */ | 
| 565 | 	void    (*IdentifyStripe) (RF_Raid_t * raidPtr, RF_RaidAddr_t addr, | 
| 566 | 				   RF_RowCol_t ** diskids); | 
| 567 |  | 
| 568 | 	/* routine to select a dag */ | 
| 569 | 	void    (*SelectionFunc) (RF_Raid_t * raidPtr, RF_IoType_t type, | 
| 570 | 				  RF_AccessStripeMap_t * asmap, | 
| 571 | 				  RF_VoidFuncPtr *); | 
| 572 |  | 
| 573 | 	/* map a stripe ID to a parity stripe ID.  This is typically the | 
| 574 | 	 * identity mapping */ | 
| 575 | 	void    (*MapSIDToPSID) (RF_RaidLayout_t * layoutPtr, | 
| 576 | 				 RF_StripeNum_t stripeID, | 
| 577 | 				 RF_StripeNum_t * psID, | 
| 578 | 				 RF_ReconUnitNum_t * which_ru); | 
| 579 |  | 
| 580 | 	/* get default head separation limit (may be NULL) */ | 
| 581 | 	RF_HeadSepLimit_t(*GetDefaultHeadSepLimit) (RF_Raid_t * raidPtr); | 
| 582 |  | 
| 583 | 	/* get default num recon buffers (may be NULL) */ | 
| 584 | 	int     (*GetDefaultNumFloatingReconBuffers) (RF_Raid_t * raidPtr); | 
| 585 |  | 
| 586 | 	/* get number of spare recon units (may be NULL) */ | 
| 587 | 	RF_ReconUnitCount_t(*GetNumSpareRUs) (RF_Raid_t * raidPtr); | 
| 588 |  | 
| 589 | 	/* spare table installation (may be NULL) */ | 
| 590 | 	int     (*InstallSpareTable) (RF_Raid_t * raidPtr, RF_RowCol_t fcol); | 
| 591 |  | 
| 592 | 	/* recon buffer submission function */ | 
| 593 | 	int     (*SubmitReconBuffer) (RF_ReconBuffer_t * rbuf, int keep_it, | 
| 594 | 				      int use_committed); | 
| 595 |  | 
| 596 | 	/* | 
| 597 |          * verify that parity information for a stripe is correct | 
| 598 |          * see rf_parityscan.h for return vals | 
| 599 |          */ | 
| 600 | 	int     (*VerifyParity) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidAddr, | 
| 601 | 				 RF_PhysDiskAddr_t * parityPDA, | 
| 602 | 				 int correct_it, RF_RaidAccessFlags_t flags); | 
| 603 |  | 
| 604 | 	/* number of faults tolerated by this mapping */ | 
| 605 | 	int     faultsTolerated; | 
| 606 |  | 
| 607 | 	/* states to step through in an access. Must end with "LastState". The | 
| 608 | 	 * default is DefaultStates in rf_layout.c */ | 
| 609 | 	const RF_AccessState_t *states; | 
| 610 |  | 
| 611 | 	RF_AccessStripeMapFlags_t flags; | 
| 612 | #endif				/* !KERNEL */ | 
| 613 | }       RF_LayoutSW_t; | 
| 614 | #endif | 
| 615 |  | 
| 616 |  | 
| 617 | /* Parity map declarations. */ | 
| 618 | #define RF_PARITYMAP_NREG 4096 | 
| 619 | #define RF_PARITYMAP_NBYTE howmany(RF_PARITYMAP_NREG, NBBY) | 
| 620 |  | 
| 621 | struct rf_pmctrs { | 
| 622 | 	uint64_t nwrite, ncachesync, nclearing; | 
| 623 | }; | 
| 624 |  | 
| 625 | struct rf_pmparams { | 
| 626 | 	int cooldown, tickms; | 
| 627 | 	u_int regions; | 
| 628 | }; | 
| 629 |  | 
| 630 | struct rf_pmstat { | 
| 631 | 	int enabled; /* if not set, rest of struct is zeroed */ | 
| 632 | 	struct rf_pmparams params; | 
| 633 | 	daddr_t region_size; | 
| 634 | 	char dirty[RF_PARITYMAP_NBYTE]; | 
| 635 | 	struct rf_pmctrs ctrs; | 
| 636 | }; | 
| 637 |  | 
| 638 |  | 
| 639 |  | 
| 640 | #endif				/* !_RF_RAIDFRAMEVAR_H_ */ | 
| 641 |  |