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