Home | History | Annotate | Line # | Download | only in raidframe
rf_raid0.c revision 1.2
      1 /*	$NetBSD: rf_raid0.c,v 1.2 1999/01/26 02:34:00 oster Exp $	*/
      2 /*
      3  * Copyright (c) 1995 Carnegie-Mellon University.
      4  * All rights reserved.
      5  *
      6  * Author: Mark Holland
      7  *
      8  * Permission to use, copy, modify and distribute this software and
      9  * its documentation is hereby granted, provided that both the copyright
     10  * notice and this permission notice appear in all copies of the
     11  * software, derivative works or modified versions, and any portions
     12  * thereof, and that both notices appear in supporting documentation.
     13  *
     14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17  *
     18  * Carnegie Mellon requests users of this software to return to
     19  *
     20  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21  *  School of Computer Science
     22  *  Carnegie Mellon University
     23  *  Pittsburgh PA 15213-3890
     24  *
     25  * any improvements or extensions that they make and grant Carnegie the
     26  * rights to redistribute these changes.
     27  */
     28 
     29 /***************************************
     30  *
     31  * rf_raid0.c -- implements RAID Level 0
     32  *
     33  ***************************************/
     34 
     35 #include "rf_types.h"
     36 #include "rf_raid.h"
     37 #include "rf_raid0.h"
     38 #include "rf_dag.h"
     39 #include "rf_dagffrd.h"
     40 #include "rf_dagffwr.h"
     41 #include "rf_dagutils.h"
     42 #include "rf_dagfuncs.h"
     43 #include "rf_threadid.h"
     44 #include "rf_general.h"
     45 #include "rf_configure.h"
     46 #include "rf_parityscan.h"
     47 
     48 typedef struct RF_Raid0ConfigInfo_s {
     49   RF_RowCol_t  *stripeIdentifier;
     50 } RF_Raid0ConfigInfo_t;
     51 
     52 int rf_ConfigureRAID0(
     53   RF_ShutdownList_t  **listp,
     54   RF_Raid_t           *raidPtr,
     55   RF_Config_t         *cfgPtr)
     56 {
     57   RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
     58   RF_Raid0ConfigInfo_t *info;
     59   RF_RowCol_t i;
     60 
     61   /* create a RAID level 0 configuration structure */
     62   RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList);
     63   if (info == NULL)
     64     return(ENOMEM);
     65   layoutPtr->layoutSpecificInfo = (void *)info;
     66 
     67   RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
     68   if (info->stripeIdentifier == NULL)
     69     return(ENOMEM);
     70   for (i=0; i<raidPtr->numCol; i++)
     71     info->stripeIdentifier[i] = i;
     72 
     73   RF_ASSERT(raidPtr->numRow == 1);
     74   raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
     75   layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
     76   layoutPtr->dataSectorsPerStripe = raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
     77   layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
     78   layoutPtr->numDataCol = raidPtr->numCol;
     79   layoutPtr->numParityCol = 0;
     80   return(0);
     81 }
     82 
     83 void rf_MapSectorRAID0(
     84   RF_Raid_t         *raidPtr,
     85   RF_RaidAddr_t      raidSector,
     86   RF_RowCol_t       *row,
     87   RF_RowCol_t       *col,
     88   RF_SectorNum_t    *diskSector,
     89   int                remap)
     90 {
     91   RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
     92   *row = 0;
     93   *col = SUID % raidPtr->numCol;
     94   *diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit +
     95     (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
     96 }
     97 
     98 void rf_MapParityRAID0(
     99   RF_Raid_t       *raidPtr,
    100   RF_RaidAddr_t    raidSector,
    101   RF_RowCol_t     *row,
    102   RF_RowCol_t     *col,
    103   RF_SectorNum_t  *diskSector,
    104   int              remap)
    105 {
    106   *row = *col = 0;
    107   *diskSector = 0;
    108 }
    109 
    110 void rf_IdentifyStripeRAID0(
    111   RF_Raid_t        *raidPtr,
    112   RF_RaidAddr_t     addr,
    113   RF_RowCol_t     **diskids,
    114   RF_RowCol_t      *outRow)
    115 {
    116   RF_Raid0ConfigInfo_t *info;
    117 
    118   info = raidPtr->Layout.layoutSpecificInfo;
    119   *diskids = info->stripeIdentifier;
    120   *outRow = 0;
    121 }
    122 
    123 void rf_MapSIDToPSIDRAID0(
    124   RF_RaidLayout_t    *layoutPtr,
    125   RF_StripeNum_t      stripeID,
    126   RF_StripeNum_t     *psID,
    127   RF_ReconUnitNum_t  *which_ru)
    128 {
    129   *which_ru = 0;
    130   *psID = stripeID;
    131 }
    132 
    133 void rf_RAID0DagSelect(
    134   RF_Raid_t             *raidPtr,
    135   RF_IoType_t            type,
    136   RF_AccessStripeMap_t  *asmap,
    137   RF_VoidFuncPtr        *createFunc)
    138 {
    139   *createFunc = ((type == RF_IO_TYPE_READ) ?
    140     (RF_VoidFuncPtr)rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr)rf_CreateRAID0WriteDAG);
    141 }
    142 
    143 int rf_VerifyParityRAID0(
    144   RF_Raid_t             *raidPtr,
    145   RF_RaidAddr_t          raidAddr,
    146   RF_PhysDiskAddr_t     *parityPDA,
    147   int                    correct_it,
    148   RF_RaidAccessFlags_t   flags)
    149 {
    150   /*
    151    * No parity is always okay.
    152    */
    153   return(RF_PARITY_OKAY);
    154 }
    155