rf_raid0.c revision 1.1 1 /* $NetBSD: rf_raid0.c,v 1.1 1998/11/13 04:20:33 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 /*
36 * :
37 * Log: rf_raid0.c,v
38 * Revision 1.24 1996/07/31 16:56:18 jimz
39 * dataBytesPerStripe, sectorsPerDisk init arch-indep.
40 *
41 * Revision 1.23 1996/07/27 23:36:08 jimz
42 * Solaris port of simulator
43 *
44 * Revision 1.22 1996/07/18 22:57:14 jimz
45 * port simulator to AIX
46 *
47 * Revision 1.21 1996/06/19 22:07:34 jimz
48 * added parity verify
49 *
50 * Revision 1.20 1996/06/17 14:38:33 jimz
51 * properly #if out RF_DEMO code
52 * fix bug in MakeConfig that was causing weird behavior
53 * in configuration routines (config was not zeroed at start)
54 * clean up genplot handling of stacks
55 *
56 * Revision 1.19 1996/06/10 11:55:47 jimz
57 * Straightened out some per-array/not-per-array distinctions, fixed
58 * a couple bugs related to confusion. Added shutdown lists. Removed
59 * layout shutdown function (now subsumed by shutdown lists).
60 *
61 * Revision 1.18 1996/06/07 22:26:27 jimz
62 * type-ify which_ru (RF_ReconUnitNum_t)
63 *
64 * Revision 1.17 1996/06/07 21:33:04 jimz
65 * begin using consistent types for sector numbers,
66 * stripe numbers, row+col numbers, recon unit numbers
67 *
68 * Revision 1.16 1996/06/03 23:28:26 jimz
69 * more bugfixes
70 * check in tree to sync for IPDS runs with current bugfixes
71 * there still may be a problem with threads in the script test
72 * getting I/Os stuck- not trivially reproducible (runs ~50 times
73 * in a row without getting stuck)
74 *
75 * Revision 1.15 1996/05/31 22:26:54 jimz
76 * fix a lot of mapping problems, memory allocation problems
77 * found some weird lock issues, fixed 'em
78 * more code cleanup
79 *
80 * Revision 1.14 1996/05/27 18:56:37 jimz
81 * more code cleanup
82 * better typing
83 * compiles in all 3 environments
84 *
85 * Revision 1.13 1996/05/24 22:17:04 jimz
86 * continue code + namespace cleanup
87 * typed a bunch of flags
88 *
89 * Revision 1.12 1996/05/24 01:59:45 jimz
90 * another checkpoint in code cleanup for release
91 * time to sync kernel tree
92 *
93 * Revision 1.11 1996/05/18 19:51:34 jimz
94 * major code cleanup- fix syntax, make some types consistent,
95 * add prototypes, clean out dead code, et cetera
96 *
97 * Revision 1.10 1996/05/03 19:37:32 wvcii
98 * moved dag creation routines to dag library
99 *
100 * Revision 1.9 1995/12/12 18:10:06 jimz
101 * MIN -> RF_MIN, MAX -> RF_MAX, ASSERT -> RF_ASSERT
102 * fix 80-column brain damage in comments
103 *
104 * Revision 1.8 1995/12/06 15:06:36 root
105 * added copyright info
106 *
107 * Revision 1.7 1995/11/17 18:57:15 wvcii
108 * added prototypint to MapParity
109 *
110 * Revision 1.6 1995/11/16 13:53:51 wvcii
111 * fixed bug in CreateRAID0WriteDAG prototype
112 *
113 * Revision 1.5 1995/11/07 15:22:01 wvcii
114 * changed RAID0DagSelect prototype
115 * function no longer generates numHdrSucc, numTermAnt
116 *
117 * Revision 1.4 1995/06/23 13:39:17 robby
118 * updeated to prototypes in rf_layout.h
119 *
120 */
121
122 #include "rf_types.h"
123 #include "rf_raid.h"
124 #include "rf_raid0.h"
125 #include "rf_dag.h"
126 #include "rf_dagffrd.h"
127 #include "rf_dagffwr.h"
128 #include "rf_dagutils.h"
129 #include "rf_dagfuncs.h"
130 #include "rf_threadid.h"
131 #include "rf_general.h"
132 #include "rf_configure.h"
133 #include "rf_parityscan.h"
134
135 typedef struct RF_Raid0ConfigInfo_s {
136 RF_RowCol_t *stripeIdentifier;
137 } RF_Raid0ConfigInfo_t;
138
139 int rf_ConfigureRAID0(
140 RF_ShutdownList_t **listp,
141 RF_Raid_t *raidPtr,
142 RF_Config_t *cfgPtr)
143 {
144 RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
145 RF_Raid0ConfigInfo_t *info;
146 RF_RowCol_t i;
147
148 /* create a RAID level 0 configuration structure */
149 RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList);
150 if (info == NULL)
151 return(ENOMEM);
152 layoutPtr->layoutSpecificInfo = (void *)info;
153
154 RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
155 if (info->stripeIdentifier == NULL)
156 return(ENOMEM);
157 for (i=0; i<raidPtr->numCol; i++)
158 info->stripeIdentifier[i] = i;
159
160 RF_ASSERT(raidPtr->numRow == 1);
161 raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
162 layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
163 layoutPtr->dataSectorsPerStripe = raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
164 layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
165 layoutPtr->numDataCol = raidPtr->numCol;
166 layoutPtr->numParityCol = 0;
167 return(0);
168 }
169
170 void rf_MapSectorRAID0(
171 RF_Raid_t *raidPtr,
172 RF_RaidAddr_t raidSector,
173 RF_RowCol_t *row,
174 RF_RowCol_t *col,
175 RF_SectorNum_t *diskSector,
176 int remap)
177 {
178 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
179 *row = 0;
180 *col = SUID % raidPtr->numCol;
181 *diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit +
182 (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
183 }
184
185 void rf_MapParityRAID0(
186 RF_Raid_t *raidPtr,
187 RF_RaidAddr_t raidSector,
188 RF_RowCol_t *row,
189 RF_RowCol_t *col,
190 RF_SectorNum_t *diskSector,
191 int remap)
192 {
193 *row = *col = 0;
194 *diskSector = 0;
195 }
196
197 void rf_IdentifyStripeRAID0(
198 RF_Raid_t *raidPtr,
199 RF_RaidAddr_t addr,
200 RF_RowCol_t **diskids,
201 RF_RowCol_t *outRow)
202 {
203 RF_Raid0ConfigInfo_t *info;
204
205 info = raidPtr->Layout.layoutSpecificInfo;
206 *diskids = info->stripeIdentifier;
207 *outRow = 0;
208 }
209
210 void rf_MapSIDToPSIDRAID0(
211 RF_RaidLayout_t *layoutPtr,
212 RF_StripeNum_t stripeID,
213 RF_StripeNum_t *psID,
214 RF_ReconUnitNum_t *which_ru)
215 {
216 *which_ru = 0;
217 *psID = stripeID;
218 }
219
220 void rf_RAID0DagSelect(
221 RF_Raid_t *raidPtr,
222 RF_IoType_t type,
223 RF_AccessStripeMap_t *asmap,
224 RF_VoidFuncPtr *createFunc)
225 {
226 *createFunc = ((type == RF_IO_TYPE_READ) ?
227 (RF_VoidFuncPtr)rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr)rf_CreateRAID0WriteDAG);
228 }
229
230 int rf_VerifyParityRAID0(
231 RF_Raid_t *raidPtr,
232 RF_RaidAddr_t raidAddr,
233 RF_PhysDiskAddr_t *parityPDA,
234 int correct_it,
235 RF_RaidAccessFlags_t flags)
236 {
237 /*
238 * No parity is always okay.
239 */
240 return(RF_PARITY_OKAY);
241 }
242