1 /* $NetBSD: rf_raid0.c,v 1.4 2000/01/07 03:41:02 oster Exp $ */
6 * Copyright (c) 1995 Carnegie-Mellon University.
11 * Permission to use, copy, modify and distribute this software and
12 * its documentation is hereby granted, provided that both the copyright
13 * notice and this permission notice appear in all copies of the
14 * software, derivative works or modified versions, and any portions
15 * thereof, and that both notices appear in supporting documentation.
17 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
18 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
19 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21 * Carnegie Mellon requests users of this software to return to
23 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
24 * School of Computer Science
25 * Carnegie Mellon University
26 * Pittsburgh PA 15213-3890
28 * any improvements or extensions that they make and grant Carnegie the
29 * rights to redistribute these changes.
32 /***************************************
34 * rf_raid0.c -- implements RAID Level 0
36 ***************************************/
38 #include <dev/raidframe/rf_types.h>
39 #include <dev/raidframe/rf_raid.h>
40 #include <dev/raidframe/rf_raid0.h>
41 #include <dev/raidframe/rf_dag.h>
42 #include <dev/raidframe/rf_dagffrd.h>
43 #include <dev/raidframe/rf_dagffwr.h>
44 #include <dev/raidframe/rf_dagutils.h>
45 #include <dev/raidframe/rf_dagfuncs.h>
46 #include <dev/raidframe/rf_general.h>
47 #include <dev/raidframe/rf_configure.h>
48 #include <dev/raidframe/rf_parityscan.h>
50 typedef struct RF_Raid0ConfigInfo_s {
51 RF_RowCol_t *stripeIdentifier;
52 } RF_Raid0ConfigInfo_t;
56 RF_ShutdownList_t ** listp,
60 RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
61 RF_Raid0ConfigInfo_t *info;
64 /* create a RAID level 0 configuration structure */
65 RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList);
68 layoutPtr->layoutSpecificInfo = (void *) info;
70 RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
71 if (info->stripeIdentifier == NULL)
73 for (i = 0; i < raidPtr->numCol; i++)
74 info->stripeIdentifier[i] = i;
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->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
81 layoutPtr->numDataCol = raidPtr->numCol;
82 layoutPtr->numParityCol = 0;
89 RF_RaidAddr_t raidSector,
92 RF_SectorNum_t * diskSector,
95 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
97 *col = SUID % raidPtr->numCol;
98 *diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit +
99 (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
105 RF_RaidAddr_t raidSector,
108 RF_SectorNum_t * diskSector,
116 rf_IdentifyStripeRAID0(
119 RF_RowCol_t ** diskids,
120 RF_RowCol_t * outRow)
122 RF_Raid0ConfigInfo_t *info;
124 info = raidPtr->Layout.layoutSpecificInfo;
125 *diskids = info->stripeIdentifier;
130 rf_MapSIDToPSIDRAID0(
131 RF_RaidLayout_t * layoutPtr,
132 RF_StripeNum_t stripeID,
133 RF_StripeNum_t * psID,
134 RF_ReconUnitNum_t * which_ru)
144 RF_AccessStripeMap_t * asmap,
145 RF_VoidFuncPtr * createFunc)
147 *createFunc = ((type == RF_IO_TYPE_READ) ?
148 (RF_VoidFuncPtr) rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr) rf_CreateRAID0WriteDAG);
152 rf_VerifyParityRAID0(
154 RF_RaidAddr_t raidAddr,
155 RF_PhysDiskAddr_t * parityPDA,
157 RF_RaidAccessFlags_t flags)
160 * No parity is always okay.
162 return (RF_PARITY_OKAY);