Home | History | Annotate | Line # | Download | only in raidframe
rf_layout.h revision 1.16.26.1
      1  1.16.26.1     rmind /*	$NetBSD: rf_layout.h,v 1.16.26.1 2007/03/12 05:56:53 rmind Exp $	*/
      2        1.1     oster /*
      3        1.1     oster  * Copyright (c) 1995 Carnegie-Mellon University.
      4        1.1     oster  * All rights reserved.
      5        1.1     oster  *
      6        1.1     oster  * Author: Mark Holland
      7        1.1     oster  *
      8        1.1     oster  * Permission to use, copy, modify and distribute this software and
      9        1.1     oster  * its documentation is hereby granted, provided that both the copyright
     10        1.1     oster  * notice and this permission notice appear in all copies of the
     11        1.1     oster  * software, derivative works or modified versions, and any portions
     12        1.1     oster  * thereof, and that both notices appear in supporting documentation.
     13        1.1     oster  *
     14        1.1     oster  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15        1.1     oster  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16        1.1     oster  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17        1.1     oster  *
     18        1.1     oster  * Carnegie Mellon requests users of this software to return to
     19        1.1     oster  *
     20        1.1     oster  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21        1.1     oster  *  School of Computer Science
     22        1.1     oster  *  Carnegie Mellon University
     23        1.1     oster  *  Pittsburgh PA 15213-3890
     24        1.1     oster  *
     25        1.1     oster  * any improvements or extensions that they make and grant Carnegie the
     26        1.1     oster  * rights to redistribute these changes.
     27        1.1     oster  */
     28        1.1     oster 
     29        1.1     oster /* rf_layout.h -- header file defining layout data structures
     30        1.1     oster  */
     31        1.1     oster 
     32        1.1     oster #ifndef _RF__RF_LAYOUT_H_
     33        1.1     oster #define _RF__RF_LAYOUT_H_
     34        1.1     oster 
     35        1.6     oster #include <dev/raidframe/raidframevar.h>
     36        1.1     oster #include "rf_archs.h"
     37        1.1     oster #include "rf_alloclist.h"
     38        1.1     oster 
     39        1.1     oster /* enables remapping to spare location under dist sparing */
     40        1.1     oster #define RF_REMAP       1
     41        1.1     oster #define RF_DONT_REMAP  0
     42        1.1     oster 
     43        1.1     oster /*
     44        1.1     oster  * Flags values for RF_AccessStripeMapFlags_t
     45        1.1     oster  */
     46        1.3     oster #define RF_NO_STRIPE_LOCKS   0x0001	/* suppress stripe locks */
     47        1.3     oster #define RF_DISTRIBUTE_SPARE  0x0002	/* distribute spare space in archs
     48        1.3     oster 					 * that support it */
     49        1.3     oster #define RF_BD_DECLUSTERED    0x0004	/* declustering uses block designs */
     50        1.1     oster 
     51        1.1     oster /*************************************************************************
     52        1.1     oster  *
     53        1.1     oster  * this structure forms the layout component of the main Raid
     54        1.1     oster  * structure.  It describes everything needed to define and perform
     55        1.1     oster  * the mapping of logical RAID addresses <-> physical disk addresses.
     56        1.3     oster  *
     57        1.1     oster  *************************************************************************/
     58        1.1     oster struct RF_RaidLayout_s {
     59        1.3     oster 	/* configuration parameters */
     60        1.3     oster 	RF_SectorCount_t sectorsPerStripeUnit;	/* number of sectors in one
     61        1.3     oster 						 * stripe unit */
     62        1.3     oster 	RF_StripeCount_t SUsPerPU;	/* stripe units per parity unit */
     63        1.3     oster 	RF_StripeCount_t SUsPerRU;	/* stripe units per reconstruction
     64        1.3     oster 					 * unit */
     65        1.3     oster 
     66        1.3     oster 	/* redundant-but-useful info computed from the above, used in all
     67        1.3     oster 	 * layouts */
     68        1.3     oster 	RF_StripeCount_t numStripe;	/* total number of stripes in the
     69        1.3     oster 					 * array */
     70        1.3     oster 	RF_SectorCount_t dataSectorsPerStripe;
     71        1.3     oster 	RF_StripeCount_t dataStripeUnitsPerDisk;
     72        1.3     oster 	RF_StripeCount_t numDataCol;	/* number of SUs of data per stripe
     73        1.3     oster 					 * (name here is a la RAID4) */
     74        1.3     oster 	RF_StripeCount_t numParityCol;	/* number of SUs of parity per stripe.
     75        1.3     oster 					 * Always 1 for now */
     76        1.3     oster 	RF_StripeCount_t numParityLogCol;	/* number of SUs of parity log
     77        1.3     oster 						 * per stripe.  Always 1 for
     78        1.3     oster 						 * now */
     79        1.3     oster 	RF_StripeCount_t stripeUnitsPerDisk;
     80        1.3     oster 
     81       1.10  jdolecek 	const RF_LayoutSW_t *map;	/* ptr to struct holding mapping fns and
     82       1.10  jdolecek 					 * information */
     83        1.3     oster 	void   *layoutSpecificInfo;	/* ptr to a structure holding
     84        1.3     oster 					 * layout-specific params */
     85        1.1     oster };
     86        1.1     oster /*****************************************************************************************
     87        1.1     oster  *
     88        1.1     oster  * The mapping code returns a pointer to a list of AccessStripeMap structures, which
     89        1.1     oster  * describes all the mapping information about an access.  The list contains one
     90        1.1     oster  * AccessStripeMap structure per stripe touched by the access.  Each element in the list
     91        1.1     oster  * contains a stripe identifier and a pointer to a list of PhysDiskAddr structuress.  Each
     92        1.1     oster  * element in this latter list describes the physical location of a stripe unit accessed
     93        1.1     oster  * within the corresponding stripe.
     94        1.3     oster  *
     95        1.1     oster  ****************************************************************************************/
     96        1.1     oster 
     97        1.1     oster #define RF_PDA_TYPE_DATA   0
     98        1.1     oster #define RF_PDA_TYPE_PARITY 1
     99        1.1     oster #define RF_PDA_TYPE_Q      2
    100        1.1     oster 
    101        1.1     oster struct RF_PhysDiskAddr_s {
    102       1.11     oster 	RF_RowCol_t col;	/* disk identifier */
    103        1.3     oster 	RF_SectorNum_t startSector;	/* sector offset into the disk */
    104        1.3     oster 	RF_SectorCount_t numSector;	/* number of sectors accessed */
    105        1.3     oster 	int     type;		/* used by higher levels: currently, data,
    106        1.3     oster 				 * parity, or q */
    107  1.16.26.1     rmind 	void *bufPtr;		/* pointer to buffer supplying/receiving data */
    108        1.3     oster 	RF_RaidAddr_t raidAddress;	/* raid address corresponding to this
    109        1.3     oster 					 * physical disk address */
    110        1.3     oster 	RF_PhysDiskAddr_t *next;
    111        1.1     oster };
    112        1.1     oster #define RF_MAX_FAILED_PDA RF_MAXCOL
    113        1.1     oster 
    114        1.1     oster struct RF_AccessStripeMap_s {
    115        1.3     oster 	RF_StripeNum_t stripeID;/* the stripe index */
    116        1.3     oster 	RF_RaidAddr_t raidAddress;	/* the starting raid address within
    117        1.3     oster 					 * this stripe */
    118        1.3     oster 	RF_RaidAddr_t endRaidAddress;	/* raid address one sector past the
    119        1.3     oster 					 * end of the access */
    120        1.3     oster 	RF_SectorCount_t totalSectorsAccessed;	/* total num sectors
    121        1.3     oster 						 * identified in physInfo list */
    122        1.3     oster 	RF_StripeCount_t numStripeUnitsAccessed;	/* total num elements in
    123        1.3     oster 							 * physInfo list */
    124        1.3     oster 	int     numDataFailed;	/* number of failed data disks accessed */
    125        1.3     oster 	int     numParityFailed;/* number of failed parity disks accessed (0
    126        1.3     oster 				 * or 1) */
    127        1.3     oster 	int     numQFailed;	/* number of failed Q units accessed (0 or 1) */
    128        1.3     oster 	RF_AccessStripeMapFlags_t flags;	/* various flags */
    129        1.3     oster 	int     numFailedPDAs;	/* number of failed phys addrs */
    130        1.3     oster 	RF_PhysDiskAddr_t *failedPDAs[RF_MAX_FAILED_PDA];	/* array of failed phys
    131        1.3     oster 								 * addrs */
    132        1.3     oster 	RF_PhysDiskAddr_t *physInfo;	/* a list of PhysDiskAddr structs */
    133        1.3     oster 	RF_PhysDiskAddr_t *parityInfo;	/* list of physical addrs for the
    134        1.3     oster 					 * parity (P of P + Q ) */
    135        1.3     oster 	RF_PhysDiskAddr_t *qInfo;	/* list of physical addrs for the Q of
    136        1.3     oster 					 * P + Q */
    137        1.3     oster 	RF_LockReqDesc_t lockReqDesc;	/* used for stripe locking */
    138        1.3     oster 	RF_AccessStripeMap_t *next;
    139        1.1     oster };
    140        1.1     oster /* flag values */
    141        1.3     oster #define RF_ASM_REDIR_LARGE_WRITE   0x00000001	/* allows large-write creation
    142        1.3     oster 						 * code to redirect failed
    143        1.3     oster 						 * accs */
    144        1.3     oster #define RF_ASM_BAILOUT_DAG_USED    0x00000002	/* allows us to detect
    145        1.3     oster 						 * recursive calls to the
    146        1.3     oster 						 * bailout write dag */
    147        1.3     oster #define RF_ASM_FLAGS_LOCK_TRIED    0x00000004	/* we've acquired the lock on
    148        1.3     oster 						 * the first parity range in
    149        1.3     oster 						 * this parity stripe */
    150        1.3     oster #define RF_ASM_FLAGS_LOCK_TRIED2   0x00000008	/* we've acquired the lock on
    151        1.3     oster 						 * the 2nd   parity range in
    152        1.3     oster 						 * this parity stripe */
    153        1.3     oster #define RF_ASM_FLAGS_FORCE_TRIED   0x00000010	/* we've done the force-recon
    154        1.3     oster 						 * call on this parity stripe */
    155        1.3     oster #define RF_ASM_FLAGS_RECON_BLOCKED 0x00000020	/* we blocked recon => we must
    156        1.3     oster 						 * unblock it later */
    157        1.1     oster 
    158        1.1     oster struct RF_AccessStripeMapHeader_s {
    159        1.3     oster 	RF_StripeCount_t numStripes;	/* total number of stripes touched by
    160        1.3     oster 					 * this acc */
    161        1.3     oster 	RF_AccessStripeMap_t *stripeMap;	/* pointer to the actual map.
    162        1.3     oster 						 * Also used for making lists */
    163        1.3     oster 	RF_AccessStripeMapHeader_t *next;
    164        1.1     oster };
    165       1.12     oster 
    166       1.13     oster /* A structure to be used in a linked list to keep track of function pointers. */
    167       1.12     oster typedef struct RF_VoidFunctionPointerListElem_s RF_VoidFunctionPointerListElem_t;
    168       1.12     oster struct RF_VoidFunctionPointerListElem_s {
    169       1.12     oster 	RF_VoidFuncPtr fn;
    170       1.12     oster 	RF_VoidFunctionPointerListElem_t *next;
    171       1.12     oster };
    172       1.13     oster 
    173       1.14     oster /* We need something to just be a linked list of anonymous pointers
    174       1.14     oster    to stuff */
    175       1.14     oster typedef struct RF_VoidPointerListElem_s RF_VoidPointerListElem_t;
    176       1.14     oster struct RF_VoidPointerListElem_s {
    177       1.14     oster 	void *p;
    178       1.14     oster 	RF_VoidPointerListElem_t *next;
    179       1.14     oster };
    180       1.14     oster 
    181       1.13     oster /* A structure to be used in a linked list to keep track of ASM Headers */
    182       1.12     oster typedef struct RF_ASMHeaderListElem_s RF_ASMHeaderListElem_t;
    183       1.12     oster struct RF_ASMHeaderListElem_s {
    184       1.12     oster 	RF_AccessStripeMapHeader_t *asmh;
    185       1.12     oster 	RF_ASMHeaderListElem_t *next;
    186       1.12     oster };
    187       1.12     oster 
    188       1.15     perry /* A structure to keep track of all the data structures associated with
    189       1.13     oster a failed stripe.  Used for constructing the appropriate DAGs in
    190       1.13     oster rf_SelectAlgorithm() in rf_aselect.c */
    191       1.12     oster typedef struct RF_FailedStripe_s RF_FailedStripe_t;
    192       1.12     oster struct RF_FailedStripe_s {
    193       1.13     oster 	RF_VoidFunctionPointerListElem_t *vfple;   /* linked list of pointers to DAG creation
    194       1.13     oster 						      functions for stripes */
    195       1.13     oster 	RF_VoidFunctionPointerListElem_t *bvfple;  /* linked list of poitners to DAG creation
    196       1.13     oster 						      functions for blocks */
    197       1.13     oster 	RF_ASMHeaderListElem_t *asmh_u;            /* Access Stripe Map Headers for regular
    198       1.13     oster 						      stripes */
    199       1.13     oster 	RF_ASMHeaderListElem_t *asmh_b;            /* Access Stripe Map Headers used for the
    200       1.13     oster 						      block functions */
    201       1.12     oster 	RF_FailedStripe_t *next;
    202       1.12     oster };
    203       1.12     oster 
    204       1.12     oster 
    205       1.12     oster 
    206        1.1     oster /*****************************************************************************************
    207        1.1     oster  *
    208        1.1     oster  * various routines mapping addresses in the RAID address space.  These work across
    209        1.1     oster  * all layouts.  DON'T PUT ANY LAYOUT-SPECIFIC CODE HERE.
    210        1.1     oster  *
    211        1.1     oster  ****************************************************************************************/
    212        1.1     oster 
    213        1.1     oster /* return the identifier of the stripe containing the given address */
    214        1.1     oster #define rf_RaidAddressToStripeID(_layoutPtr_, _addr_) \
    215        1.1     oster   ( ((_addr_) / (_layoutPtr_)->sectorsPerStripeUnit) / (_layoutPtr_)->numDataCol )
    216        1.1     oster 
    217        1.1     oster /* return the raid address of the start of the indicates stripe ID */
    218        1.1     oster #define rf_StripeIDToRaidAddress(_layoutPtr_, _sid_) \
    219        1.1     oster   ( ((_sid_) * (_layoutPtr_)->sectorsPerStripeUnit) * (_layoutPtr_)->numDataCol )
    220        1.1     oster 
    221        1.1     oster /* return the identifier of the stripe containing the given stripe unit id */
    222        1.1     oster #define rf_StripeUnitIDToStripeID(_layoutPtr_, _addr_) \
    223        1.1     oster   ( (_addr_) / (_layoutPtr_)->numDataCol )
    224        1.1     oster 
    225        1.1     oster /* return the identifier of the stripe unit containing the given address */
    226        1.1     oster #define rf_RaidAddressToStripeUnitID(_layoutPtr_, _addr_) \
    227        1.1     oster   ( ((_addr_) / (_layoutPtr_)->sectorsPerStripeUnit) )
    228        1.1     oster 
    229        1.1     oster /* return the RAID address of next stripe boundary beyond the given address */
    230        1.1     oster #define rf_RaidAddressOfNextStripeBoundary(_layoutPtr_, _addr_) \
    231        1.1     oster   ( (((_addr_)/(_layoutPtr_)->dataSectorsPerStripe)+1) * (_layoutPtr_)->dataSectorsPerStripe )
    232        1.1     oster 
    233        1.1     oster /* return the RAID address of the start of the stripe containing the given address */
    234        1.1     oster #define rf_RaidAddressOfPrevStripeBoundary(_layoutPtr_, _addr_) \
    235        1.1     oster   ( (((_addr_)/(_layoutPtr_)->dataSectorsPerStripe)+0) * (_layoutPtr_)->dataSectorsPerStripe )
    236        1.1     oster 
    237        1.1     oster /* return the RAID address of next stripe unit boundary beyond the given address */
    238        1.1     oster #define rf_RaidAddressOfNextStripeUnitBoundary(_layoutPtr_, _addr_) \
    239        1.1     oster   ( (((_addr_)/(_layoutPtr_)->sectorsPerStripeUnit)+1L)*(_layoutPtr_)->sectorsPerStripeUnit )
    240        1.1     oster 
    241        1.1     oster /* return the RAID address of the start of the stripe unit containing RAID address _addr_ */
    242        1.1     oster #define rf_RaidAddressOfPrevStripeUnitBoundary(_layoutPtr_, _addr_) \
    243        1.1     oster   ( (((_addr_)/(_layoutPtr_)->sectorsPerStripeUnit)+0)*(_layoutPtr_)->sectorsPerStripeUnit )
    244        1.1     oster 
    245        1.1     oster /* returns the offset into the stripe.  used by RaidAddressStripeAligned */
    246        1.1     oster #define rf_RaidAddressStripeOffset(_layoutPtr_, _addr_) \
    247        1.1     oster   ( (_addr_) % ((_layoutPtr_)->dataSectorsPerStripe) )
    248        1.1     oster 
    249        1.1     oster /* returns the offset into the stripe unit.  */
    250        1.1     oster #define rf_StripeUnitOffset(_layoutPtr_, _addr_) \
    251        1.1     oster   ( (_addr_) % ((_layoutPtr_)->sectorsPerStripeUnit) )
    252        1.1     oster 
    253        1.1     oster /* returns nonzero if the given RAID address is stripe-aligned */
    254        1.1     oster #define rf_RaidAddressStripeAligned( __layoutPtr__, __addr__ ) \
    255        1.1     oster   ( rf_RaidAddressStripeOffset(__layoutPtr__, __addr__) == 0 )
    256        1.1     oster 
    257        1.1     oster /* returns nonzero if the given address is stripe-unit aligned */
    258        1.1     oster #define rf_StripeUnitAligned( __layoutPtr__, __addr__ ) \
    259        1.1     oster   ( rf_StripeUnitOffset(__layoutPtr__, __addr__) == 0 )
    260        1.1     oster 
    261        1.1     oster /* convert an address expressed in RAID blocks to/from an addr expressed in bytes */
    262        1.1     oster #define rf_RaidAddressToByte(_raidPtr_, _addr_) \
    263        1.1     oster   ( (_addr_) << ( (_raidPtr_)->logBytesPerSector ) )
    264        1.1     oster 
    265        1.1     oster #define rf_ByteToRaidAddress(_raidPtr_, _addr_) \
    266        1.1     oster   ( (_addr_) >> ( (_raidPtr_)->logBytesPerSector ) )
    267        1.1     oster 
    268        1.1     oster /* convert a raid address to/from a parity stripe ID.  Conversion to raid address is easy,
    269        1.1     oster  * since we're asking for the address of the first sector in the parity stripe.  Conversion to a
    270        1.1     oster  * parity stripe ID is more complex, since stripes are not contiguously allocated in
    271        1.1     oster  * parity stripes.
    272        1.1     oster  */
    273        1.1     oster #define rf_RaidAddressToParityStripeID(_layoutPtr_, _addr_, _ru_num_) \
    274        1.1     oster   rf_MapStripeIDToParityStripeID( (_layoutPtr_), rf_RaidAddressToStripeID( (_layoutPtr_), (_addr_) ), (_ru_num_) )
    275        1.1     oster 
    276        1.1     oster #define rf_ParityStripeIDToRaidAddress(_layoutPtr_, _psid_) \
    277        1.1     oster   ( (_psid_) * (_layoutPtr_)->SUsPerPU * (_layoutPtr_)->numDataCol * (_layoutPtr_)->sectorsPerStripeUnit )
    278        1.1     oster 
    279       1.10  jdolecek const RF_LayoutSW_t *rf_GetLayout(RF_ParityConfig_t parityConfig);
    280       1.15     perry int
    281        1.3     oster rf_ConfigureLayout(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr,
    282        1.3     oster     RF_Config_t * cfgPtr);
    283       1.15     perry RF_StripeNum_t
    284        1.3     oster rf_MapStripeIDToParityStripeID(RF_RaidLayout_t * layoutPtr,
    285        1.3     oster     RF_StripeNum_t stripeID, RF_ReconUnitNum_t * which_ru);
    286        1.1     oster 
    287        1.3     oster #endif				/* !_RF__RF_LAYOUT_H_ */
    288