rf_aselect.c revision 1.19 1 1.19 oster /* $NetBSD: rf_aselect.c,v 1.19 2004/03/20 21:25:55 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, William V. Courtright II
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 /*****************************************************************************
30 1.1 oster *
31 1.1 oster * aselect.c -- algorithm selection code
32 1.3 oster *
33 1.1 oster *****************************************************************************/
34 1.5 lukem
35 1.5 lukem #include <sys/cdefs.h>
36 1.19 oster __KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.19 2004/03/20 21:25:55 oster Exp $");
37 1.2 oster
38 1.4 oster #include <dev/raidframe/raidframevar.h>
39 1.1 oster
40 1.1 oster #include "rf_archs.h"
41 1.1 oster #include "rf_raid.h"
42 1.1 oster #include "rf_dag.h"
43 1.1 oster #include "rf_dagutils.h"
44 1.1 oster #include "rf_dagfuncs.h"
45 1.1 oster #include "rf_general.h"
46 1.1 oster #include "rf_desc.h"
47 1.1 oster #include "rf_map.h"
48 1.1 oster
49 1.16 oster static void InitHdrNode(RF_DagHeader_t **, RF_Raid_t *);
50 1.3 oster int rf_SelectAlgorithm(RF_RaidAccessDesc_t *, RF_RaidAccessFlags_t);
51 1.1 oster
52 1.1 oster /******************************************************************************
53 1.1 oster *
54 1.1 oster * Create and Initialiaze a dag header and termination node
55 1.1 oster *
56 1.1 oster *****************************************************************************/
57 1.16 oster static void
58 1.10 oster InitHdrNode(RF_DagHeader_t **hdr, RF_Raid_t *raidPtr)
59 1.1 oster {
60 1.3 oster /* create and initialize dag hdr */
61 1.3 oster *hdr = rf_AllocDAGHeader();
62 1.3 oster rf_MakeAllocList((*hdr)->allocList);
63 1.3 oster (*hdr)->status = rf_enable;
64 1.3 oster (*hdr)->numSuccedents = 0;
65 1.17 oster (*hdr)->nodes = NULL;
66 1.3 oster (*hdr)->raidPtr = raidPtr;
67 1.3 oster (*hdr)->next = NULL;
68 1.1 oster }
69 1.1 oster
70 1.1 oster /******************************************************************************
71 1.1 oster *
72 1.1 oster * Create a DAG to do a read or write operation.
73 1.1 oster *
74 1.12 oster * create a list of dagLists, one list per parity stripe.
75 1.12 oster * return the lists in the desc->dagList (which is a list of lists).
76 1.1 oster *
77 1.1 oster * Normally, each list contains one dag for the entire stripe. In some
78 1.1 oster * tricky cases, we break this into multiple dags, either one per stripe
79 1.1 oster * unit or one per block (sector). When this occurs, these dags are returned
80 1.1 oster * as a linked list (dagList) which is executed sequentially (to preserve
81 1.1 oster * atomic parity updates in the stripe).
82 1.3 oster *
83 1.1 oster * dags which operate on independent parity goups (stripes) are returned in
84 1.1 oster * independent dagLists (distinct elements in desc->dagArray) and may be
85 1.1 oster * executed concurrently.
86 1.1 oster *
87 1.1 oster * Finally, if the SelectionFunc fails to create a dag for a block, we punt
88 1.1 oster * and return 1.
89 1.1 oster *
90 1.1 oster * The above process is performed in two phases:
91 1.1 oster * 1) create an array(s) of creation functions (eg stripeFuncs)
92 1.1 oster * 2) create dags and concatenate/merge to form the final dag.
93 1.1 oster *
94 1.1 oster * Because dag's are basic blocks (single entry, single exit, unconditional
95 1.1 oster * control flow, we can add the following optimizations (future work):
96 1.1 oster * first-pass optimizer to allow max concurrency (need all data dependencies)
97 1.1 oster * second-pass optimizer to eliminate common subexpressions (need true
98 1.1 oster * data dependencies)
99 1.1 oster * third-pass optimizer to eliminate dead code (need true data dependencies)
100 1.1 oster *****************************************************************************/
101 1.1 oster
102 1.1 oster #define MAXNSTRIPES 50
103 1.1 oster
104 1.3 oster int
105 1.10 oster rf_SelectAlgorithm(RF_RaidAccessDesc_t *desc, RF_RaidAccessFlags_t flags)
106 1.1 oster {
107 1.3 oster RF_AccessStripeMapHeader_t *asm_h = desc->asmap;
108 1.3 oster RF_IoType_t type = desc->type;
109 1.3 oster RF_Raid_t *raidPtr = desc->raidPtr;
110 1.3 oster void *bp = desc->bp;
111 1.3 oster
112 1.3 oster RF_AccessStripeMap_t *asmap = asm_h->stripeMap;
113 1.3 oster RF_AccessStripeMap_t *asm_p;
114 1.3 oster RF_DagHeader_t *dag_h = NULL, *tempdag_h, *lastdag_h;
115 1.12 oster RF_DagList_t *dagList, *dagListend;
116 1.3 oster int i, j, k;
117 1.13 oster RF_FuncList_t *stripeFuncsList, *stripeFuncs, *stripeFuncsEnd, *temp;
118 1.3 oster RF_AccessStripeMap_t *asm_up, *asm_bp;
119 1.3 oster RF_AccessStripeMapHeader_t ***asmh_u, *endASMList;
120 1.3 oster RF_AccessStripeMapHeader_t ***asmh_b;
121 1.18 oster RF_ASMHeaderListElem_t *asmhle, *tmpasmhle;
122 1.18 oster RF_VoidFunctionPointerListElem_t *vfple, *tmpvfple;
123 1.18 oster RF_FailedStripe_t *failed_stripes_list, *failed_stripes_list_end;
124 1.18 oster RF_FailedStripe_t *tmpfailed_stripe, *failed_stripe = NULL;
125 1.18 oster RF_ASMHeaderListElem_t *failed_stripes_asmh_u_end = NULL;
126 1.18 oster RF_ASMHeaderListElem_t *failed_stripes_asmh_b_end = NULL;
127 1.18 oster RF_VoidFunctionPointerListElem_t *failed_stripes_vfple_end = NULL;
128 1.18 oster RF_VoidFunctionPointerListElem_t *failed_stripes_bvfple_end = NULL;
129 1.3 oster RF_VoidFuncPtr **stripeUnitFuncs, uFunc;
130 1.3 oster RF_VoidFuncPtr **blockFuncs, bFunc;
131 1.3 oster int numStripesBailed = 0, cantCreateDAGs = RF_FALSE;
132 1.3 oster int numStripeUnitsBailed = 0;
133 1.3 oster int stripeNum, numUnitDags = 0, stripeUnitNum, numBlockDags = 0;
134 1.3 oster RF_StripeNum_t numStripeUnits;
135 1.3 oster RF_SectorNum_t numBlocks;
136 1.3 oster RF_RaidAddr_t address;
137 1.3 oster int length;
138 1.3 oster RF_PhysDiskAddr_t *physPtr;
139 1.3 oster caddr_t buffer;
140 1.3 oster
141 1.3 oster lastdag_h = NULL;
142 1.3 oster asmh_u = asmh_b = NULL;
143 1.3 oster stripeUnitFuncs = NULL;
144 1.3 oster blockFuncs = NULL;
145 1.3 oster
146 1.13 oster stripeFuncsList = NULL;
147 1.13 oster stripeFuncsEnd = NULL;
148 1.3 oster
149 1.18 oster failed_stripes_list = NULL;
150 1.18 oster failed_stripes_list_end = NULL;
151 1.18 oster
152 1.3 oster /* walk through the asm list once collecting information */
153 1.3 oster /* attempt to find a single creation function for each stripe */
154 1.3 oster desc->numStripes = 0;
155 1.3 oster for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
156 1.3 oster desc->numStripes++;
157 1.13 oster stripeFuncs = rf_AllocFuncList();
158 1.13 oster
159 1.13 oster if (stripeFuncsEnd == NULL) {
160 1.13 oster stripeFuncsList = stripeFuncs;
161 1.13 oster } else {
162 1.13 oster stripeFuncsEnd->next = stripeFuncs;
163 1.13 oster }
164 1.13 oster stripeFuncsEnd = stripeFuncs;
165 1.13 oster
166 1.13 oster (raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_p, &(stripeFuncs->fp));
167 1.3 oster /* check to see if we found a creation func for this stripe */
168 1.13 oster if (stripeFuncs->fp == NULL) {
169 1.3 oster /* could not find creation function for entire stripe
170 1.3 oster * so, let's see if we can find one for each stripe
171 1.3 oster * unit in the stripe */
172 1.18 oster
173 1.18 oster /* create a failed stripe structure to attempt to deal with the failure */
174 1.18 oster failed_stripe = rf_AllocFailedStripeStruct();
175 1.18 oster if (failed_stripes_list == NULL) {
176 1.18 oster failed_stripes_list = failed_stripe;
177 1.18 oster failed_stripes_list_end = failed_stripe;
178 1.18 oster } else {
179 1.18 oster failed_stripes_list_end->next = failed_stripe;
180 1.18 oster failed_stripes_list_end = failed_stripe;
181 1.18 oster }
182 1.3 oster
183 1.3 oster /* create an array of creation funcs (called
184 1.3 oster * stripeFuncs) for this stripe */
185 1.3 oster numStripeUnits = asm_p->numStripeUnitsAccessed;
186 1.3 oster
187 1.18 oster /* lookup array of stripeUnitFuncs for this stripe */
188 1.18 oster failed_stripes_asmh_u_end = NULL;
189 1.18 oster failed_stripes_vfple_end = NULL;
190 1.3 oster for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
191 1.3 oster /* remap for series of single stripe-unit
192 1.3 oster * accesses */
193 1.3 oster address = physPtr->raidAddress;
194 1.3 oster length = physPtr->numSector;
195 1.3 oster buffer = physPtr->bufPtr;
196 1.3 oster
197 1.18 oster asmhle = rf_AllocASMHeaderListElem();
198 1.18 oster if (failed_stripe->asmh_u == NULL) {
199 1.18 oster failed_stripe->asmh_u = asmhle; /* we're the head... */
200 1.18 oster failed_stripes_asmh_u_end = asmhle; /* and the tail */
201 1.18 oster } else {
202 1.18 oster /* tack us onto the end of the list */
203 1.18 oster failed_stripes_asmh_u_end->next = asmhle;
204 1.18 oster failed_stripes_asmh_u_end = asmhle;
205 1.18 oster }
206 1.18 oster
207 1.18 oster
208 1.18 oster asmhle->asmh = rf_MapAccess(raidPtr, address, length, buffer, RF_DONT_REMAP);
209 1.18 oster asm_up = asmhle->asmh->stripeMap;
210 1.18 oster
211 1.18 oster vfple = rf_AllocVFPListElem();
212 1.18 oster if (failed_stripe->vfple == NULL) {
213 1.18 oster failed_stripe->vfple = vfple;
214 1.18 oster failed_stripes_vfple_end = vfple;
215 1.18 oster } else {
216 1.18 oster failed_stripes_vfple_end->next = vfple;
217 1.18 oster failed_stripes_vfple_end = vfple;
218 1.18 oster }
219 1.3 oster
220 1.3 oster /* get the creation func for this stripe unit */
221 1.18 oster (raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_up, &(vfple->fn));
222 1.3 oster
223 1.3 oster /* check to see if we found a creation func
224 1.3 oster * for this stripe unit */
225 1.18 oster
226 1.18 oster if (vfple->fn == (RF_VoidFuncPtr) NULL) {
227 1.3 oster /* could not find creation function
228 1.3 oster * for stripe unit so, let's see if we
229 1.3 oster * can find one for each block in the
230 1.3 oster * stripe unit */
231 1.18 oster
232 1.3 oster numBlocks = physPtr->numSector;
233 1.3 oster numBlockDags += numBlocks;
234 1.3 oster
235 1.3 oster /* lookup array of blockFuncs for this
236 1.3 oster * stripe unit */
237 1.3 oster for (k = 0; k < numBlocks; k++) {
238 1.3 oster /* remap for series of single
239 1.3 oster * stripe-unit accesses */
240 1.3 oster address = physPtr->raidAddress + k;
241 1.3 oster length = 1;
242 1.3 oster buffer = physPtr->bufPtr + (k * (1 << raidPtr->logBytesPerSector));
243 1.3 oster
244 1.18 oster asmhle = rf_AllocASMHeaderListElem();
245 1.18 oster if (failed_stripe->asmh_b == NULL) {
246 1.18 oster failed_stripe->asmh_b = asmhle;
247 1.18 oster failed_stripes_asmh_b_end = asmhle;
248 1.18 oster } else {
249 1.18 oster failed_stripes_asmh_b_end->next = asmhle;
250 1.18 oster failed_stripes_asmh_b_end = asmhle;
251 1.18 oster }
252 1.3 oster
253 1.18 oster asmhle->asmh = rf_MapAccess(raidPtr, address, length, buffer, RF_DONT_REMAP);
254 1.18 oster asm_bp = asmhle->asmh->stripeMap;
255 1.18 oster
256 1.18 oster vfple = rf_AllocVFPListElem();
257 1.18 oster if (failed_stripe->bvfple == NULL) {
258 1.18 oster failed_stripe->bvfple = vfple;
259 1.18 oster failed_stripes_bvfple_end = vfple;
260 1.18 oster } else {
261 1.18 oster failed_stripes_bvfple_end->next = vfple;
262 1.18 oster failed_stripes_bvfple_end = vfple;
263 1.18 oster }
264 1.18 oster (raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_bp, &(vfple->fn));
265 1.3 oster
266 1.3 oster /* check to see if we found a
267 1.3 oster * creation func for this
268 1.3 oster * stripe unit */
269 1.18 oster
270 1.18 oster if (vfple->fn == NULL)
271 1.3 oster cantCreateDAGs = RF_TRUE;
272 1.3 oster }
273 1.3 oster numStripeUnitsBailed++;
274 1.3 oster } else {
275 1.3 oster numUnitDags++;
276 1.3 oster }
277 1.3 oster }
278 1.3 oster RF_ASSERT(j == numStripeUnits);
279 1.3 oster numStripesBailed++;
280 1.3 oster }
281 1.1 oster }
282 1.3 oster
283 1.3 oster if (cantCreateDAGs) {
284 1.3 oster /* free memory and punt */
285 1.3 oster if (numStripesBailed > 0) {
286 1.3 oster stripeNum = 0;
287 1.13 oster stripeFuncs = stripeFuncsList;
288 1.18 oster failed_stripe = failed_stripes_list;
289 1.13 oster for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
290 1.13 oster if (stripeFuncs->fp == NULL) {
291 1.18 oster
292 1.18 oster asmhle = failed_stripe->asmh_u;
293 1.18 oster while (asmhle) {
294 1.18 oster tmpasmhle= asmhle;
295 1.18 oster asmhle = tmpasmhle->next;
296 1.18 oster rf_FreeAccessStripeMap(tmpasmhle->asmh);
297 1.18 oster rf_FreeASMHeaderListElem(tmpasmhle);
298 1.18 oster }
299 1.18 oster
300 1.18 oster asmhle = failed_stripe->asmh_b;
301 1.18 oster while (asmhle) {
302 1.18 oster tmpasmhle= asmhle;
303 1.18 oster asmhle = tmpasmhle->next;
304 1.18 oster rf_FreeAccessStripeMap(tmpasmhle->asmh);
305 1.18 oster rf_FreeASMHeaderListElem(tmpasmhle);
306 1.18 oster }
307 1.18 oster
308 1.18 oster vfple = failed_stripe->vfple;
309 1.18 oster while (vfple) {
310 1.18 oster tmpvfple = vfple;
311 1.18 oster vfple = tmpvfple->next;
312 1.18 oster rf_FreeVFPListElem(tmpvfple);
313 1.18 oster }
314 1.18 oster
315 1.18 oster vfple = failed_stripe->bvfple;
316 1.18 oster while (vfple) {
317 1.18 oster tmpvfple = vfple;
318 1.18 oster vfple = tmpvfple->next;
319 1.18 oster rf_FreeVFPListElem(tmpvfple);
320 1.18 oster }
321 1.18 oster
322 1.3 oster stripeNum++;
323 1.18 oster /* only move to the next failed stripe slot if the current one was used */
324 1.18 oster tmpfailed_stripe = failed_stripe;
325 1.18 oster failed_stripe = failed_stripe->next;
326 1.18 oster rf_FreeFailedStripeStruct(tmpfailed_stripe);
327 1.3 oster }
328 1.13 oster stripeFuncs = stripeFuncs->next;
329 1.13 oster }
330 1.3 oster RF_ASSERT(stripeNum == numStripesBailed);
331 1.3 oster }
332 1.13 oster while (stripeFuncsList != NULL) {
333 1.13 oster temp = stripeFuncsList;
334 1.13 oster stripeFuncsList = stripeFuncsList->next;
335 1.13 oster rf_FreeFuncList(temp);
336 1.13 oster }
337 1.11 oster desc->numStripes = 0;
338 1.3 oster return (1);
339 1.3 oster } else {
340 1.3 oster /* begin dag creation */
341 1.3 oster stripeNum = 0;
342 1.3 oster stripeUnitNum = 0;
343 1.3 oster
344 1.12 oster /* create a list of dagLists and fill them in */
345 1.12 oster
346 1.12 oster dagListend = NULL;
347 1.3 oster
348 1.13 oster stripeFuncs = stripeFuncsList;
349 1.18 oster failed_stripe = failed_stripes_list;
350 1.3 oster for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
351 1.3 oster /* grab dag header for this stripe */
352 1.3 oster dag_h = NULL;
353 1.12 oster
354 1.12 oster dagList = rf_AllocDAGList();
355 1.12 oster
356 1.12 oster /* always tack the new dagList onto the end of the list... */
357 1.12 oster if (dagListend == NULL) {
358 1.12 oster desc->dagList = dagList;
359 1.12 oster } else {
360 1.12 oster dagListend->next = dagList;
361 1.12 oster }
362 1.12 oster dagListend = dagList;
363 1.12 oster
364 1.12 oster dagList->desc = desc;
365 1.3 oster
366 1.13 oster if (stripeFuncs->fp == NULL) {
367 1.3 oster /* use bailout functions for this stripe */
368 1.18 oster asmhle = failed_stripe->asmh_u;
369 1.18 oster vfple = failed_stripe->vfple;
370 1.18 oster /* the following two may contain asm headers and
371 1.18 oster block function pointers for multiple asm within
372 1.18 oster this access. We initialize tmpasmhle and tmpvfple
373 1.18 oster here in order to allow for that, and for correct
374 1.18 oster operation below */
375 1.18 oster tmpasmhle = failed_stripe->asmh_b;
376 1.18 oster tmpvfple = failed_stripe->bvfple;
377 1.3 oster for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
378 1.18 oster uFunc = vfple->fn; /* stripeUnitFuncs[stripeNum][j]; */
379 1.3 oster if (uFunc == (RF_VoidFuncPtr) NULL) {
380 1.3 oster /* use bailout functions for
381 1.3 oster * this stripe unit */
382 1.3 oster for (k = 0; k < physPtr->numSector; k++) {
383 1.3 oster /* create a dag for
384 1.3 oster * this block */
385 1.7 oster InitHdrNode(&tempdag_h, raidPtr);
386 1.12 oster dagList->numDags++;
387 1.3 oster if (dag_h == NULL) {
388 1.3 oster dag_h = tempdag_h;
389 1.3 oster } else {
390 1.3 oster lastdag_h->next = tempdag_h;
391 1.3 oster }
392 1.3 oster lastdag_h = tempdag_h;
393 1.3 oster
394 1.18 oster bFunc = tmpvfple->fn; /* blockFuncs[stripeUnitNum][k]; */
395 1.3 oster RF_ASSERT(bFunc);
396 1.18 oster asm_bp = tmpasmhle->asmh->stripeMap; /* asmh_b[stripeUnitNum][k]->stripeMap; */
397 1.3 oster (*bFunc) (raidPtr, asm_bp, tempdag_h, bp, flags, tempdag_h->allocList);
398 1.18 oster
399 1.18 oster tmpasmhle = tmpasmhle->next;
400 1.18 oster tmpvfple = tmpvfple->next;
401 1.3 oster }
402 1.3 oster stripeUnitNum++;
403 1.3 oster } else {
404 1.3 oster /* create a dag for this unit */
405 1.7 oster InitHdrNode(&tempdag_h, raidPtr);
406 1.12 oster dagList->numDags++;
407 1.3 oster if (dag_h == NULL) {
408 1.3 oster dag_h = tempdag_h;
409 1.3 oster } else {
410 1.3 oster lastdag_h->next = tempdag_h;
411 1.3 oster }
412 1.3 oster lastdag_h = tempdag_h;
413 1.3 oster
414 1.18 oster asm_up = asmhle->asmh->stripeMap; /* asmh_u[stripeNum][j]->stripeMap; */
415 1.3 oster (*uFunc) (raidPtr, asm_up, tempdag_h, bp, flags, tempdag_h->allocList);
416 1.3 oster }
417 1.18 oster asmhle = asmhle->next;
418 1.18 oster vfple = vfple->next;
419 1.3 oster }
420 1.3 oster RF_ASSERT(j == asm_p->numStripeUnitsAccessed);
421 1.3 oster /* merge linked bailout dag to existing dag
422 1.3 oster * collection */
423 1.3 oster stripeNum++;
424 1.18 oster failed_stripe = failed_stripe->next;
425 1.3 oster } else {
426 1.3 oster /* Create a dag for this parity stripe */
427 1.7 oster InitHdrNode(&tempdag_h, raidPtr);
428 1.12 oster dagList->numDags++;
429 1.3 oster if (dag_h == NULL) {
430 1.3 oster dag_h = tempdag_h;
431 1.3 oster } else {
432 1.3 oster lastdag_h->next = tempdag_h;
433 1.3 oster }
434 1.3 oster lastdag_h = tempdag_h;
435 1.3 oster
436 1.13 oster (stripeFuncs->fp) (raidPtr, asm_p, tempdag_h, bp, flags, tempdag_h->allocList);
437 1.1 oster }
438 1.12 oster dagList->dags = dag_h;
439 1.13 oster stripeFuncs = stripeFuncs->next;
440 1.3 oster }
441 1.3 oster RF_ASSERT(i == desc->numStripes);
442 1.3 oster
443 1.3 oster /* free memory */
444 1.3 oster if ((numStripesBailed > 0) || (numStripeUnitsBailed > 0)) {
445 1.3 oster stripeNum = 0;
446 1.3 oster stripeUnitNum = 0;
447 1.3 oster if (dag_h->asmList) {
448 1.3 oster endASMList = dag_h->asmList;
449 1.3 oster while (endASMList->next)
450 1.3 oster endASMList = endASMList->next;
451 1.3 oster } else
452 1.3 oster endASMList = NULL;
453 1.3 oster /* walk through io, stripe by stripe */
454 1.18 oster /* here we build up dag_h->asmList for this dag...
455 1.18 oster we need all of these asm's to do the IO, and
456 1.18 oster want them in a convenient place for freeing at a
457 1.18 oster later time */
458 1.13 oster stripeFuncs = stripeFuncsList;
459 1.18 oster failed_stripe = failed_stripes_list;
460 1.13 oster for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
461 1.13 oster if (stripeFuncs->fp == NULL) {
462 1.3 oster numStripeUnits = asm_p->numStripeUnitsAccessed;
463 1.3 oster /* walk through stripe, stripe unit by
464 1.3 oster * stripe unit */
465 1.18 oster asmhle = failed_stripe->asmh_u;
466 1.18 oster vfple = failed_stripe->vfple;
467 1.18 oster /* this contains all of the asm headers for block funcs,
468 1.18 oster so we have to initialize this here instead of below.*/
469 1.18 oster tmpasmhle = failed_stripe->asmh_b;
470 1.3 oster for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
471 1.18 oster if (vfple->fn == NULL) {
472 1.3 oster numBlocks = physPtr->numSector;
473 1.3 oster /* walk through stripe
474 1.3 oster * unit, block by
475 1.3 oster * block */
476 1.18 oster for (k = 0; k < numBlocks; k++) {
477 1.3 oster if (dag_h->asmList == NULL) {
478 1.18 oster dag_h->asmList = tmpasmhle->asmh; /* asmh_b[stripeUnitNum][k];*/
479 1.3 oster endASMList = dag_h->asmList;
480 1.3 oster } else {
481 1.18 oster endASMList->next = tmpasmhle->asmh;
482 1.3 oster endASMList = endASMList->next;
483 1.3 oster }
484 1.18 oster tmpasmhle = tmpasmhle->next;
485 1.18 oster }
486 1.3 oster stripeUnitNum++;
487 1.3 oster }
488 1.3 oster if (dag_h->asmList == NULL) {
489 1.18 oster dag_h->asmList = asmhle->asmh;
490 1.3 oster endASMList = dag_h->asmList;
491 1.3 oster } else {
492 1.18 oster endASMList->next = asmhle->asmh;
493 1.3 oster endASMList = endASMList->next;
494 1.3 oster }
495 1.18 oster asmhle = asmhle->next;
496 1.18 oster vfple = vfple->next;
497 1.3 oster }
498 1.3 oster stripeNum++;
499 1.18 oster failed_stripe = failed_stripe->next;
500 1.3 oster }
501 1.13 oster stripeFuncs = stripeFuncs->next;
502 1.13 oster }
503 1.3 oster RF_ASSERT(stripeNum == numStripesBailed);
504 1.19 oster RF_ASSERT(stripeUnitNum == numStripeUnitsBailed);
505 1.18 oster
506 1.19 oster failed_stripe = failed_stripes_list;
507 1.19 oster while (failed_stripe) {
508 1.18 oster
509 1.19 oster asmhle = failed_stripe->asmh_u;
510 1.19 oster while (asmhle) {
511 1.19 oster tmpasmhle= asmhle;
512 1.19 oster asmhle = tmpasmhle->next;
513 1.19 oster rf_FreeASMHeaderListElem(tmpasmhle);
514 1.19 oster }
515 1.18 oster
516 1.19 oster asmhle = failed_stripe->asmh_b;
517 1.19 oster while (asmhle) {
518 1.19 oster tmpasmhle= asmhle;
519 1.19 oster asmhle = tmpasmhle->next;
520 1.19 oster rf_FreeASMHeaderListElem(tmpasmhle);
521 1.19 oster }
522 1.19 oster vfple = failed_stripe->vfple;
523 1.19 oster while (vfple) {
524 1.19 oster tmpvfple = vfple;
525 1.19 oster vfple = tmpvfple->next;
526 1.19 oster rf_FreeVFPListElem(tmpvfple);
527 1.19 oster }
528 1.19 oster
529 1.19 oster vfple = failed_stripe->bvfple;
530 1.19 oster while (vfple) {
531 1.19 oster tmpvfple = vfple;
532 1.19 oster vfple = tmpvfple->next;
533 1.19 oster rf_FreeVFPListElem(tmpvfple);
534 1.18 oster }
535 1.19 oster
536 1.19 oster tmpfailed_stripe = failed_stripe;
537 1.19 oster failed_stripe = tmpfailed_stripe->next;
538 1.19 oster rf_FreeFailedStripeStruct(tmpfailed_stripe);
539 1.1 oster }
540 1.3 oster }
541 1.13 oster while (stripeFuncsList != NULL) {
542 1.13 oster temp = stripeFuncsList;
543 1.13 oster stripeFuncsList = stripeFuncsList->next;
544 1.13 oster rf_FreeFuncList(temp);
545 1.13 oster }
546 1.3 oster return (0);
547 1.1 oster }
548 1.1 oster }
549