Home | History | Annotate | Line # | Download | only in raidframe
rf_raid0.c revision 1.7
      1 /*	$NetBSD: rf_raid0.c,v 1.7 2002/09/23 02:40:09 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 <sys/cdefs.h>
     36 __KERNEL_RCSID(0, "$NetBSD: rf_raid0.c,v 1.7 2002/09/23 02:40:09 oster Exp $");
     37 
     38 #include <dev/raidframe/raidframevar.h>
     39 
     40 #include "rf_raid.h"
     41 #include "rf_raid0.h"
     42 #include "rf_dag.h"
     43 #include "rf_dagffrd.h"
     44 #include "rf_dagffwr.h"
     45 #include "rf_dagutils.h"
     46 #include "rf_dagfuncs.h"
     47 #include "rf_general.h"
     48 #include "rf_parityscan.h"
     49 
     50 typedef struct RF_Raid0ConfigInfo_s {
     51 	RF_RowCol_t *stripeIdentifier;
     52 }       RF_Raid0ConfigInfo_t;
     53 
     54 int
     55 rf_ConfigureRAID0(
     56     RF_ShutdownList_t ** listp,
     57     RF_Raid_t * raidPtr,
     58     RF_Config_t * cfgPtr)
     59 {
     60 	RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
     61 	RF_Raid0ConfigInfo_t *info;
     62 	RF_RowCol_t i;
     63 
     64 	/* create a RAID level 0 configuration structure */
     65 	RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList);
     66 	if (info == NULL)
     67 		return (ENOMEM);
     68 	layoutPtr->layoutSpecificInfo = (void *) info;
     69 
     70 	RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
     71 	if (info->stripeIdentifier == NULL)
     72 		return (ENOMEM);
     73 	for (i = 0; i < raidPtr->numCol; i++)
     74 		info->stripeIdentifier[i] = i;
     75 
     76 	RF_ASSERT(raidPtr->numRow == 1);
     77 	raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
     78 	layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
     79 	layoutPtr->dataSectorsPerStripe = raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
     80 	layoutPtr->numDataCol = raidPtr->numCol;
     81 	layoutPtr->numParityCol = 0;
     82 	return (0);
     83 }
     84 
     85 void
     86 rf_MapSectorRAID0(
     87     RF_Raid_t * raidPtr,
     88     RF_RaidAddr_t raidSector,
     89     RF_RowCol_t * row,
     90     RF_RowCol_t * col,
     91     RF_SectorNum_t * diskSector,
     92     int remap)
     93 {
     94 	RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
     95 	*row = 0;
     96 	*col = SUID % raidPtr->numCol;
     97 	*diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit +
     98 	    (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
     99 }
    100 
    101 void
    102 rf_MapParityRAID0(
    103     RF_Raid_t * raidPtr,
    104     RF_RaidAddr_t raidSector,
    105     RF_RowCol_t * row,
    106     RF_RowCol_t * col,
    107     RF_SectorNum_t * diskSector,
    108     int remap)
    109 {
    110 	*row = *col = 0;
    111 	*diskSector = 0;
    112 }
    113 
    114 void
    115 rf_IdentifyStripeRAID0(
    116     RF_Raid_t * raidPtr,
    117     RF_RaidAddr_t addr,
    118     RF_RowCol_t ** diskids,
    119     RF_RowCol_t * outRow)
    120 {
    121 	RF_Raid0ConfigInfo_t *info;
    122 
    123 	info = raidPtr->Layout.layoutSpecificInfo;
    124 	*diskids = info->stripeIdentifier;
    125 	*outRow = 0;
    126 }
    127 
    128 void
    129 rf_MapSIDToPSIDRAID0(
    130     RF_RaidLayout_t * layoutPtr,
    131     RF_StripeNum_t stripeID,
    132     RF_StripeNum_t * psID,
    133     RF_ReconUnitNum_t * which_ru)
    134 {
    135 	*which_ru = 0;
    136 	*psID = stripeID;
    137 }
    138 
    139 void
    140 rf_RAID0DagSelect(
    141     RF_Raid_t * raidPtr,
    142     RF_IoType_t type,
    143     RF_AccessStripeMap_t * asmap,
    144     RF_VoidFuncPtr * createFunc)
    145 {
    146 	*createFunc = ((type == RF_IO_TYPE_READ) ?
    147 	    (RF_VoidFuncPtr) rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr) rf_CreateRAID0WriteDAG);
    148 }
    149 
    150 int
    151 rf_VerifyParityRAID0(
    152     RF_Raid_t * raidPtr,
    153     RF_RaidAddr_t raidAddr,
    154     RF_PhysDiskAddr_t * parityPDA,
    155     int correct_it,
    156     RF_RaidAccessFlags_t flags)
    157 {
    158 	/*
    159          * No parity is always okay.
    160          */
    161 	return (RF_PARITY_OKAY);
    162 }
    163