rf_layout.c revision 1.5 1 1.5 oster /* $NetBSD: rf_layout.c,v 1.5 2000/04/16 03:24:26 oster 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.c -- driver code dealing with layout and mapping issues
30 1.1 oster */
31 1.1 oster
32 1.5 oster #include <sys/types.h>
33 1.5 oster #include <machine/param.h>
34 1.5 oster
35 1.1 oster #include "rf_types.h"
36 1.1 oster #include "rf_archs.h"
37 1.1 oster #include "rf_raid.h"
38 1.1 oster #include "rf_configure.h"
39 1.1 oster #include "rf_dag.h"
40 1.1 oster #include "rf_desc.h"
41 1.1 oster #include "rf_decluster.h"
42 1.1 oster #include "rf_pq.h"
43 1.1 oster #include "rf_declusterPQ.h"
44 1.1 oster #include "rf_raid0.h"
45 1.1 oster #include "rf_raid1.h"
46 1.1 oster #include "rf_raid4.h"
47 1.1 oster #include "rf_raid5.h"
48 1.1 oster #include "rf_states.h"
49 1.1 oster #if RF_INCLUDE_RAID5_RS > 0
50 1.1 oster #include "rf_raid5_rotatedspare.h"
51 1.3 oster #endif /* RF_INCLUDE_RAID5_RS > 0 */
52 1.1 oster #if RF_INCLUDE_CHAINDECLUSTER > 0
53 1.1 oster #include "rf_chaindecluster.h"
54 1.3 oster #endif /* RF_INCLUDE_CHAINDECLUSTER > 0 */
55 1.1 oster #if RF_INCLUDE_INTERDECLUSTER > 0
56 1.1 oster #include "rf_interdecluster.h"
57 1.3 oster #endif /* RF_INCLUDE_INTERDECLUSTER > 0 */
58 1.1 oster #if RF_INCLUDE_PARITYLOGGING > 0
59 1.1 oster #include "rf_paritylogging.h"
60 1.3 oster #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
61 1.1 oster #if RF_INCLUDE_EVENODD > 0
62 1.1 oster #include "rf_evenodd.h"
63 1.3 oster #endif /* RF_INCLUDE_EVENODD > 0 */
64 1.1 oster #include "rf_general.h"
65 1.1 oster #include "rf_driver.h"
66 1.1 oster #include "rf_parityscan.h"
67 1.1 oster #include "rf_reconbuffer.h"
68 1.1 oster #include "rf_reconutil.h"
69 1.1 oster
70 1.1 oster /***********************************************************************
71 1.1 oster *
72 1.1 oster * the layout switch defines all the layouts that are supported.
73 1.1 oster * fields are: layout ID, init routine, shutdown routine, map
74 1.1 oster * sector, map parity, identify stripe, dag selection, map stripeid
75 1.1 oster * to parity stripe id (optional), num faults tolerated, special
76 1.1 oster * flags.
77 1.1 oster *
78 1.1 oster ***********************************************************************/
79 1.1 oster
80 1.1 oster static RF_AccessState_t DefaultStates[] = {rf_QuiesceState,
81 1.1 oster rf_IncrAccessesCountState, rf_MapState, rf_LockState, rf_CreateDAGState,
82 1.1 oster rf_ExecuteDAGState, rf_ProcessDAGState, rf_DecrAccessesCountState,
83 1.3 oster rf_CleanupState, rf_LastState};
84 1.1 oster #if defined(__NetBSD__) && !defined(_KERNEL)
85 1.3 oster /* XXX Gross hack to shutup gcc -- it complains that DefaultStates is not
86 1.1 oster used when compiling this in userland.. I hate to burst it's bubble, but
87 1.1 oster DefaultStates is used all over the place here in the initialization of
88 1.1 oster lots of data structures. GO */
89 1.1 oster RF_AccessState_t *NothingAtAll = DefaultStates;
90 1.1 oster #endif
91 1.3 oster
92 1.1 oster #if defined(__NetBSD__) && defined(_KERNEL)
93 1.1 oster /* XXX Remove static so GCC doesn't complain about these being unused! */
94 1.3 oster int distSpareYes = 1;
95 1.3 oster int distSpareNo = 0;
96 1.1 oster #else
97 1.1 oster static int distSpareYes = 1;
98 1.3 oster static int distSpareNo = 0;
99 1.1 oster #endif
100 1.2 oster #ifdef _KERNEL
101 1.1 oster #define RF_NK2(a,b)
102 1.3 oster #else /* _KERNEL */
103 1.1 oster #define RF_NK2(a,b) a,b,
104 1.3 oster #endif /* _KERNEL */
105 1.1 oster
106 1.1 oster #if RF_UTILITY > 0
107 1.1 oster #define RF_NU(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
108 1.3 oster #else /* RF_UTILITY > 0 */
109 1.1 oster #define RF_NU(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p
110 1.3 oster #endif /* RF_UTILITY > 0 */
111 1.1 oster
112 1.1 oster static RF_LayoutSW_t mapsw[] = {
113 1.1 oster /* parity declustering */
114 1.1 oster {'T', "Parity declustering",
115 1.3 oster RF_NK2(rf_MakeLayoutSpecificDeclustered, &distSpareNo)
116 1.3 oster RF_NU(
117 1.3 oster rf_ConfigureDeclustered,
118 1.3 oster rf_MapSectorDeclustered, rf_MapParityDeclustered, NULL,
119 1.3 oster rf_IdentifyStripeDeclustered,
120 1.3 oster rf_RaidFiveDagSelect,
121 1.3 oster rf_MapSIDToPSIDDeclustered,
122 1.3 oster rf_GetDefaultHeadSepLimitDeclustered,
123 1.3 oster rf_GetDefaultNumFloatingReconBuffersDeclustered,
124 1.3 oster NULL, NULL,
125 1.3 oster rf_SubmitReconBufferBasic,
126 1.3 oster rf_VerifyParityBasic,
127 1.3 oster 1,
128 1.3 oster DefaultStates,
129 1.3 oster 0)
130 1.1 oster },
131 1.1 oster
132 1.1 oster /* parity declustering with distributed sparing */
133 1.1 oster {'D', "Distributed sparing parity declustering",
134 1.3 oster RF_NK2(rf_MakeLayoutSpecificDeclustered, &distSpareYes)
135 1.3 oster RF_NU(
136 1.3 oster rf_ConfigureDeclusteredDS,
137 1.3 oster rf_MapSectorDeclustered, rf_MapParityDeclustered, NULL,
138 1.3 oster rf_IdentifyStripeDeclustered,
139 1.3 oster rf_RaidFiveDagSelect,
140 1.3 oster rf_MapSIDToPSIDDeclustered,
141 1.3 oster rf_GetDefaultHeadSepLimitDeclustered,
142 1.3 oster rf_GetDefaultNumFloatingReconBuffersDeclustered,
143 1.3 oster rf_GetNumSpareRUsDeclustered, rf_InstallSpareTable,
144 1.3 oster rf_SubmitReconBufferBasic,
145 1.3 oster rf_VerifyParityBasic,
146 1.3 oster 1,
147 1.3 oster DefaultStates,
148 1.3 oster RF_DISTRIBUTE_SPARE | RF_BD_DECLUSTERED)
149 1.1 oster },
150 1.1 oster
151 1.1 oster #if RF_INCLUDE_DECL_PQ > 0
152 1.1 oster /* declustered P+Q */
153 1.1 oster {'Q', "Declustered P+Q",
154 1.3 oster RF_NK2(rf_MakeLayoutSpecificDeclustered, &distSpareNo)
155 1.3 oster RF_NU(
156 1.3 oster rf_ConfigureDeclusteredPQ,
157 1.3 oster rf_MapSectorDeclusteredPQ, rf_MapParityDeclusteredPQ, rf_MapQDeclusteredPQ,
158 1.3 oster rf_IdentifyStripeDeclusteredPQ,
159 1.3 oster rf_PQDagSelect,
160 1.3 oster rf_MapSIDToPSIDDeclustered,
161 1.3 oster rf_GetDefaultHeadSepLimitDeclustered,
162 1.3 oster rf_GetDefaultNumFloatingReconBuffersPQ,
163 1.3 oster NULL, NULL,
164 1.3 oster NULL,
165 1.3 oster rf_VerifyParityBasic,
166 1.3 oster 2,
167 1.3 oster DefaultStates,
168 1.3 oster 0)
169 1.1 oster },
170 1.3 oster #endif /* RF_INCLUDE_DECL_PQ > 0 */
171 1.1 oster
172 1.1 oster #if RF_INCLUDE_RAID5_RS > 0
173 1.1 oster /* RAID 5 with rotated sparing */
174 1.1 oster {'R', "RAID Level 5 rotated sparing",
175 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
176 1.3 oster RF_NU(
177 1.3 oster rf_ConfigureRAID5_RS,
178 1.3 oster rf_MapSectorRAID5_RS, rf_MapParityRAID5_RS, NULL,
179 1.3 oster rf_IdentifyStripeRAID5_RS,
180 1.3 oster rf_RaidFiveDagSelect,
181 1.3 oster rf_MapSIDToPSIDRAID5_RS,
182 1.3 oster rf_GetDefaultHeadSepLimitRAID5,
183 1.3 oster rf_GetDefaultNumFloatingReconBuffersRAID5,
184 1.3 oster rf_GetNumSpareRUsRAID5_RS, NULL,
185 1.3 oster rf_SubmitReconBufferBasic,
186 1.3 oster rf_VerifyParityBasic,
187 1.3 oster 1,
188 1.3 oster DefaultStates,
189 1.3 oster RF_DISTRIBUTE_SPARE)
190 1.1 oster },
191 1.3 oster #endif /* RF_INCLUDE_RAID5_RS > 0 */
192 1.1 oster
193 1.1 oster #if RF_INCLUDE_CHAINDECLUSTER > 0
194 1.1 oster /* Chained Declustering */
195 1.1 oster {'C', "Chained Declustering",
196 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
197 1.3 oster RF_NU(
198 1.3 oster rf_ConfigureChainDecluster,
199 1.3 oster rf_MapSectorChainDecluster, rf_MapParityChainDecluster, NULL,
200 1.3 oster rf_IdentifyStripeChainDecluster,
201 1.3 oster rf_RAIDCDagSelect,
202 1.3 oster rf_MapSIDToPSIDChainDecluster,
203 1.3 oster NULL,
204 1.3 oster NULL,
205 1.3 oster rf_GetNumSpareRUsChainDecluster, NULL,
206 1.3 oster rf_SubmitReconBufferBasic,
207 1.3 oster rf_VerifyParityBasic,
208 1.3 oster 1,
209 1.3 oster DefaultStates,
210 1.3 oster 0)
211 1.1 oster },
212 1.3 oster #endif /* RF_INCLUDE_CHAINDECLUSTER > 0 */
213 1.1 oster
214 1.1 oster #if RF_INCLUDE_INTERDECLUSTER > 0
215 1.1 oster /* Interleaved Declustering */
216 1.1 oster {'I', "Interleaved Declustering",
217 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
218 1.3 oster RF_NU(
219 1.3 oster rf_ConfigureInterDecluster,
220 1.3 oster rf_MapSectorInterDecluster, rf_MapParityInterDecluster, NULL,
221 1.3 oster rf_IdentifyStripeInterDecluster,
222 1.3 oster rf_RAIDIDagSelect,
223 1.3 oster rf_MapSIDToPSIDInterDecluster,
224 1.3 oster rf_GetDefaultHeadSepLimitInterDecluster,
225 1.3 oster rf_GetDefaultNumFloatingReconBuffersInterDecluster,
226 1.3 oster rf_GetNumSpareRUsInterDecluster, NULL,
227 1.3 oster rf_SubmitReconBufferBasic,
228 1.3 oster rf_VerifyParityBasic,
229 1.3 oster 1,
230 1.3 oster DefaultStates,
231 1.3 oster RF_DISTRIBUTE_SPARE)
232 1.1 oster },
233 1.3 oster #endif /* RF_INCLUDE_INTERDECLUSTER > 0 */
234 1.1 oster
235 1.1 oster #if RF_INCLUDE_RAID0 > 0
236 1.1 oster /* RAID level 0 */
237 1.1 oster {'0', "RAID Level 0",
238 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
239 1.3 oster RF_NU(
240 1.3 oster rf_ConfigureRAID0,
241 1.3 oster rf_MapSectorRAID0, rf_MapParityRAID0, NULL,
242 1.3 oster rf_IdentifyStripeRAID0,
243 1.3 oster rf_RAID0DagSelect,
244 1.3 oster rf_MapSIDToPSIDRAID0,
245 1.3 oster NULL,
246 1.3 oster NULL,
247 1.3 oster NULL, NULL,
248 1.3 oster NULL,
249 1.3 oster rf_VerifyParityRAID0,
250 1.3 oster 0,
251 1.3 oster DefaultStates,
252 1.3 oster 0)
253 1.1 oster },
254 1.3 oster #endif /* RF_INCLUDE_RAID0 > 0 */
255 1.1 oster
256 1.1 oster #if RF_INCLUDE_RAID1 > 0
257 1.1 oster /* RAID level 1 */
258 1.1 oster {'1', "RAID Level 1",
259 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
260 1.3 oster RF_NU(
261 1.3 oster rf_ConfigureRAID1,
262 1.3 oster rf_MapSectorRAID1, rf_MapParityRAID1, NULL,
263 1.3 oster rf_IdentifyStripeRAID1,
264 1.3 oster rf_RAID1DagSelect,
265 1.3 oster rf_MapSIDToPSIDRAID1,
266 1.3 oster NULL,
267 1.3 oster NULL,
268 1.3 oster NULL, NULL,
269 1.3 oster rf_SubmitReconBufferRAID1,
270 1.3 oster rf_VerifyParityRAID1,
271 1.3 oster 1,
272 1.3 oster DefaultStates,
273 1.3 oster 0)
274 1.1 oster },
275 1.3 oster #endif /* RF_INCLUDE_RAID1 > 0 */
276 1.1 oster
277 1.1 oster #if RF_INCLUDE_RAID4 > 0
278 1.1 oster /* RAID level 4 */
279 1.1 oster {'4', "RAID Level 4",
280 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
281 1.3 oster RF_NU(
282 1.3 oster rf_ConfigureRAID4,
283 1.3 oster rf_MapSectorRAID4, rf_MapParityRAID4, NULL,
284 1.3 oster rf_IdentifyStripeRAID4,
285 1.3 oster rf_RaidFiveDagSelect,
286 1.3 oster rf_MapSIDToPSIDRAID4,
287 1.3 oster rf_GetDefaultHeadSepLimitRAID4,
288 1.3 oster rf_GetDefaultNumFloatingReconBuffersRAID4,
289 1.3 oster NULL, NULL,
290 1.3 oster rf_SubmitReconBufferBasic,
291 1.3 oster rf_VerifyParityBasic,
292 1.3 oster 1,
293 1.3 oster DefaultStates,
294 1.3 oster 0)
295 1.1 oster },
296 1.3 oster #endif /* RF_INCLUDE_RAID4 > 0 */
297 1.1 oster
298 1.1 oster #if RF_INCLUDE_RAID5 > 0
299 1.1 oster /* RAID level 5 */
300 1.1 oster {'5', "RAID Level 5",
301 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
302 1.3 oster RF_NU(
303 1.3 oster rf_ConfigureRAID5,
304 1.3 oster rf_MapSectorRAID5, rf_MapParityRAID5, NULL,
305 1.3 oster rf_IdentifyStripeRAID5,
306 1.3 oster rf_RaidFiveDagSelect,
307 1.3 oster rf_MapSIDToPSIDRAID5,
308 1.3 oster rf_GetDefaultHeadSepLimitRAID5,
309 1.3 oster rf_GetDefaultNumFloatingReconBuffersRAID5,
310 1.3 oster NULL, NULL,
311 1.3 oster rf_SubmitReconBufferBasic,
312 1.3 oster rf_VerifyParityBasic,
313 1.3 oster 1,
314 1.3 oster DefaultStates,
315 1.3 oster 0)
316 1.1 oster },
317 1.3 oster #endif /* RF_INCLUDE_RAID5 > 0 */
318 1.1 oster
319 1.1 oster #if RF_INCLUDE_EVENODD > 0
320 1.1 oster /* Evenodd */
321 1.1 oster {'E', "EvenOdd",
322 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
323 1.3 oster RF_NU(
324 1.3 oster rf_ConfigureEvenOdd,
325 1.3 oster rf_MapSectorRAID5, rf_MapParityEvenOdd, rf_MapEEvenOdd,
326 1.3 oster rf_IdentifyStripeEvenOdd,
327 1.3 oster rf_EODagSelect,
328 1.3 oster rf_MapSIDToPSIDRAID5,
329 1.3 oster NULL,
330 1.3 oster NULL,
331 1.3 oster NULL, NULL,
332 1.3 oster NULL, /* no reconstruction, yet */
333 1.3 oster rf_VerifyParityEvenOdd,
334 1.3 oster 2,
335 1.3 oster DefaultStates,
336 1.3 oster 0)
337 1.1 oster },
338 1.3 oster #endif /* RF_INCLUDE_EVENODD > 0 */
339 1.1 oster
340 1.1 oster #if RF_INCLUDE_EVENODD > 0
341 1.1 oster /* Declustered Evenodd */
342 1.1 oster {'e', "Declustered EvenOdd",
343 1.3 oster RF_NK2(rf_MakeLayoutSpecificDeclustered, &distSpareNo)
344 1.3 oster RF_NU(
345 1.3 oster rf_ConfigureDeclusteredPQ,
346 1.3 oster rf_MapSectorDeclusteredPQ, rf_MapParityDeclusteredPQ, rf_MapQDeclusteredPQ,
347 1.3 oster rf_IdentifyStripeDeclusteredPQ,
348 1.3 oster rf_EODagSelect,
349 1.3 oster rf_MapSIDToPSIDRAID5,
350 1.3 oster rf_GetDefaultHeadSepLimitDeclustered,
351 1.3 oster rf_GetDefaultNumFloatingReconBuffersPQ,
352 1.3 oster NULL, NULL,
353 1.3 oster NULL, /* no reconstruction, yet */
354 1.3 oster rf_VerifyParityEvenOdd,
355 1.3 oster 2,
356 1.3 oster DefaultStates,
357 1.3 oster 0)
358 1.1 oster },
359 1.3 oster #endif /* RF_INCLUDE_EVENODD > 0 */
360 1.1 oster
361 1.1 oster #if RF_INCLUDE_PARITYLOGGING > 0
362 1.1 oster /* parity logging */
363 1.1 oster {'L', "Parity logging",
364 1.3 oster RF_NK2(rf_MakeLayoutSpecificNULL, NULL)
365 1.3 oster RF_NU(
366 1.3 oster rf_ConfigureParityLogging,
367 1.3 oster rf_MapSectorParityLogging, rf_MapParityParityLogging, NULL,
368 1.3 oster rf_IdentifyStripeParityLogging,
369 1.3 oster rf_ParityLoggingDagSelect,
370 1.3 oster rf_MapSIDToPSIDParityLogging,
371 1.3 oster rf_GetDefaultHeadSepLimitParityLogging,
372 1.3 oster rf_GetDefaultNumFloatingReconBuffersParityLogging,
373 1.3 oster NULL, NULL,
374 1.3 oster rf_SubmitReconBufferBasic,
375 1.3 oster NULL,
376 1.3 oster 1,
377 1.3 oster DefaultStates,
378 1.3 oster 0)
379 1.1 oster },
380 1.3 oster #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
381 1.1 oster
382 1.1 oster /* end-of-list marker */
383 1.3 oster {'\0', NULL,
384 1.3 oster RF_NK2(NULL, NULL)
385 1.3 oster RF_NU(
386 1.3 oster NULL,
387 1.3 oster NULL, NULL, NULL,
388 1.3 oster NULL,
389 1.3 oster NULL,
390 1.3 oster NULL,
391 1.3 oster NULL,
392 1.3 oster NULL,
393 1.3 oster NULL, NULL,
394 1.3 oster NULL,
395 1.3 oster NULL,
396 1.3 oster 0,
397 1.3 oster NULL,
398 1.3 oster 0)
399 1.1 oster }
400 1.1 oster };
401 1.1 oster
402 1.3 oster RF_LayoutSW_t *
403 1.3 oster rf_GetLayout(RF_ParityConfig_t parityConfig)
404 1.1 oster {
405 1.3 oster RF_LayoutSW_t *p;
406 1.1 oster
407 1.3 oster /* look up the specific layout */
408 1.3 oster for (p = &mapsw[0]; p->parityConfig; p++)
409 1.3 oster if (p->parityConfig == parityConfig)
410 1.3 oster break;
411 1.3 oster if (!p->parityConfig)
412 1.3 oster return (NULL);
413 1.3 oster RF_ASSERT(p->parityConfig == parityConfig);
414 1.3 oster return (p);
415 1.1 oster }
416 1.1 oster #if RF_UTILITY == 0
417 1.1 oster /*****************************************************************************************
418 1.1 oster *
419 1.3 oster * ConfigureLayout --
420 1.1 oster *
421 1.1 oster * read the configuration file and set up the RAID layout parameters. After reading
422 1.1 oster * common params, invokes the layout-specific configuration routine to finish
423 1.1 oster * the configuration.
424 1.1 oster *
425 1.1 oster ****************************************************************************************/
426 1.3 oster int
427 1.3 oster rf_ConfigureLayout(
428 1.3 oster RF_ShutdownList_t ** listp,
429 1.3 oster RF_Raid_t * raidPtr,
430 1.3 oster RF_Config_t * cfgPtr)
431 1.1 oster {
432 1.3 oster RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
433 1.3 oster RF_ParityConfig_t parityConfig;
434 1.3 oster RF_LayoutSW_t *p;
435 1.3 oster int retval;
436 1.3 oster
437 1.3 oster layoutPtr->sectorsPerStripeUnit = cfgPtr->sectPerSU;
438 1.3 oster layoutPtr->SUsPerPU = cfgPtr->SUsPerPU;
439 1.3 oster layoutPtr->SUsPerRU = cfgPtr->SUsPerRU;
440 1.3 oster parityConfig = cfgPtr->parityConfig;
441 1.4 oster
442 1.4 oster if (layoutPtr->sectorsPerStripeUnit <= 0) {
443 1.4 oster RF_ERRORMSG2("raid%d: Invalid sectorsPerStripeUnit: %d\n",
444 1.4 oster raidPtr->raidid,
445 1.4 oster (int)layoutPtr->sectorsPerStripeUnit );
446 1.5 oster return (EINVAL);
447 1.5 oster }
448 1.5 oster
449 1.5 oster if ((layoutPtr->sectorsPerStripeUnit *
450 1.5 oster (1 << raidPtr->logBytesPerSector)) > MAXPHYS) {
451 1.5 oster RF_ERRORMSG2("raid%d: sectorsPerStripeUnit (%d) would exceed MAXPHYS\n",
452 1.5 oster raidPtr->raidid,
453 1.5 oster (int)layoutPtr->sectorsPerStripeUnit);
454 1.4 oster return (EINVAL);
455 1.4 oster }
456 1.3 oster
457 1.3 oster layoutPtr->stripeUnitsPerDisk = raidPtr->sectorsPerDisk / layoutPtr->sectorsPerStripeUnit;
458 1.3 oster
459 1.3 oster p = rf_GetLayout(parityConfig);
460 1.3 oster if (p == NULL) {
461 1.3 oster RF_ERRORMSG1("Unknown parity configuration '%c'", parityConfig);
462 1.3 oster return (EINVAL);
463 1.3 oster }
464 1.3 oster RF_ASSERT(p->parityConfig == parityConfig);
465 1.3 oster layoutPtr->map = p;
466 1.3 oster
467 1.3 oster /* initialize the specific layout */
468 1.3 oster
469 1.3 oster retval = (p->Configure) (listp, raidPtr, cfgPtr);
470 1.3 oster
471 1.3 oster if (retval)
472 1.3 oster return (retval);
473 1.3 oster
474 1.3 oster layoutPtr->dataBytesPerStripe = layoutPtr->dataSectorsPerStripe << raidPtr->logBytesPerSector;
475 1.3 oster raidPtr->sectorsPerDisk = layoutPtr->stripeUnitsPerDisk * layoutPtr->sectorsPerStripeUnit;
476 1.1 oster
477 1.3 oster if (rf_forceNumFloatingReconBufs >= 0) {
478 1.3 oster raidPtr->numFloatingReconBufs = rf_forceNumFloatingReconBufs;
479 1.3 oster } else {
480 1.3 oster raidPtr->numFloatingReconBufs = rf_GetDefaultNumFloatingReconBuffers(raidPtr);
481 1.3 oster }
482 1.3 oster
483 1.3 oster if (rf_forceHeadSepLimit >= 0) {
484 1.3 oster raidPtr->headSepLimit = rf_forceHeadSepLimit;
485 1.3 oster } else {
486 1.3 oster raidPtr->headSepLimit = rf_GetDefaultHeadSepLimit(raidPtr);
487 1.3 oster }
488 1.3 oster
489 1.3 oster printf("RAIDFRAME: Configure (%s): total number of sectors is %lu (%lu MB)\n",
490 1.3 oster layoutPtr->map->configName,
491 1.3 oster (unsigned long) raidPtr->totalSectors,
492 1.3 oster (unsigned long) (raidPtr->totalSectors / 1024 * (1 << raidPtr->logBytesPerSector) / 1024));
493 1.3 oster if (raidPtr->headSepLimit >= 0) {
494 1.3 oster printf("RAIDFRAME(%s): Using %ld floating recon bufs with head sep limit %ld\n",
495 1.3 oster layoutPtr->map->configName, (long) raidPtr->numFloatingReconBufs, (long) raidPtr->headSepLimit);
496 1.3 oster } else {
497 1.3 oster printf("RAIDFRAME(%s): Using %ld floating recon bufs with no head sep limit\n",
498 1.3 oster layoutPtr->map->configName, (long) raidPtr->numFloatingReconBufs);
499 1.3 oster }
500 1.3 oster
501 1.3 oster return (0);
502 1.1 oster }
503 1.1 oster /* typically there is a 1-1 mapping between stripes and parity stripes.
504 1.1 oster * however, the declustering code supports packing multiple stripes into
505 1.1 oster * a single parity stripe, so as to increase the size of the reconstruction
506 1.1 oster * unit without affecting the size of the stripe unit. This routine finds
507 1.1 oster * the parity stripe identifier associated with a stripe ID. There is also
508 1.1 oster * a RaidAddressToParityStripeID macro in layout.h
509 1.1 oster */
510 1.3 oster RF_StripeNum_t
511 1.3 oster rf_MapStripeIDToParityStripeID(layoutPtr, stripeID, which_ru)
512 1.3 oster RF_RaidLayout_t *layoutPtr;
513 1.3 oster RF_StripeNum_t stripeID;
514 1.3 oster RF_ReconUnitNum_t *which_ru;
515 1.1 oster {
516 1.3 oster RF_StripeNum_t parityStripeID;
517 1.1 oster
518 1.3 oster /* quick exit in the common case of SUsPerPU==1 */
519 1.3 oster if ((layoutPtr->SUsPerPU == 1) || !layoutPtr->map->MapSIDToPSID) {
520 1.3 oster *which_ru = 0;
521 1.3 oster return (stripeID);
522 1.3 oster } else {
523 1.3 oster (layoutPtr->map->MapSIDToPSID) (layoutPtr, stripeID, &parityStripeID, which_ru);
524 1.3 oster }
525 1.3 oster return (parityStripeID);
526 1.1 oster }
527 1.3 oster #endif /* RF_UTILITY == 0 */
528