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