xref: /netbsd-src/sys/dev/raidframe/rf_states.c (revision 3b435a73967be44dfb4a27315acd72bfacde430c)
1 /*	$NetBSD: rf_states.c,v 1.7 1999/07/08 00:45:24 oster Exp $	*/
2 /*
3  * Copyright (c) 1995 Carnegie-Mellon University.
4  * All rights reserved.
5  *
6  * Author: Mark Holland, William V. Courtright II, Robby Findler
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@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 #include <sys/errno.h>
30 
31 #include "rf_archs.h"
32 #include "rf_threadstuff.h"
33 #include "rf_raid.h"
34 #include "rf_dag.h"
35 #include "rf_desc.h"
36 #include "rf_aselect.h"
37 #include "rf_threadid.h"
38 #include "rf_general.h"
39 #include "rf_states.h"
40 #include "rf_dagutils.h"
41 #include "rf_driver.h"
42 #include "rf_engine.h"
43 #include "rf_map.h"
44 #include "rf_etimer.h"
45 
46 #if defined(KERNEL) && (DKUSAGE > 0)
47 #include <sys/dkusage.h>
48 #include <io/common/iotypes.h>
49 #include <io/cam/dec_cam.h>
50 #include <io/cam/cam.h>
51 #include <io/cam/pdrv.h>
52 #endif				/* KERNEL && DKUSAGE > 0 */
53 
54 /* prototypes for some of the available states.
55 
56    States must:
57 
58      - not block.
59 
60      - either schedule rf_ContinueRaidAccess as a callback and return
61        RF_TRUE, or complete all of their work and return RF_FALSE.
62 
63      - increment desc->state when they have finished their work.
64 */
65 
66 static char *
67 StateName(RF_AccessState_t state)
68 {
69 	switch (state) {
70 		case rf_QuiesceState:return "QuiesceState";
71 	case rf_MapState:
72 		return "MapState";
73 	case rf_LockState:
74 		return "LockState";
75 	case rf_CreateDAGState:
76 		return "CreateDAGState";
77 	case rf_ExecuteDAGState:
78 		return "ExecuteDAGState";
79 	case rf_ProcessDAGState:
80 		return "ProcessDAGState";
81 	case rf_CleanupState:
82 		return "CleanupState";
83 	case rf_LastState:
84 		return "LastState";
85 	case rf_IncrAccessesCountState:
86 		return "IncrAccessesCountState";
87 	case rf_DecrAccessesCountState:
88 		return "DecrAccessesCountState";
89 	default:
90 		return "!!! UnnamedState !!!";
91 	}
92 }
93 
94 void
95 rf_ContinueRaidAccess(RF_RaidAccessDesc_t * desc)
96 {
97 	int     suspended = RF_FALSE;
98 	int     current_state_index = desc->state;
99 	RF_AccessState_t current_state = desc->states[current_state_index];
100 
101 	do {
102 
103 		current_state_index = desc->state;
104 		current_state = desc->states[current_state_index];
105 
106 		switch (current_state) {
107 
108 		case rf_QuiesceState:
109 			suspended = rf_State_Quiesce(desc);
110 			break;
111 		case rf_IncrAccessesCountState:
112 			suspended = rf_State_IncrAccessCount(desc);
113 			break;
114 		case rf_MapState:
115 			suspended = rf_State_Map(desc);
116 			break;
117 		case rf_LockState:
118 			suspended = rf_State_Lock(desc);
119 			break;
120 		case rf_CreateDAGState:
121 			suspended = rf_State_CreateDAG(desc);
122 			break;
123 		case rf_ExecuteDAGState:
124 			suspended = rf_State_ExecuteDAG(desc);
125 			break;
126 		case rf_ProcessDAGState:
127 			suspended = rf_State_ProcessDAG(desc);
128 			break;
129 		case rf_CleanupState:
130 			suspended = rf_State_Cleanup(desc);
131 			break;
132 		case rf_DecrAccessesCountState:
133 			suspended = rf_State_DecrAccessCount(desc);
134 			break;
135 		case rf_LastState:
136 			suspended = rf_State_LastState(desc);
137 			break;
138 		}
139 
140 		/* after this point, we cannot dereference desc since desc may
141 		 * have been freed. desc is only freed in LastState, so if we
142 		 * renter this function or loop back up, desc should be valid. */
143 
144 		if (rf_printStatesDebug) {
145 			int     tid;
146 			rf_get_threadid(tid);
147 
148 			printf("[%d] State: %-24s StateIndex: %3i desc: 0x%ld %s\n",
149 			    tid, StateName(current_state), current_state_index, (long) desc,
150 			    suspended ? "callback scheduled" : "looping");
151 		}
152 	} while (!suspended && current_state != rf_LastState);
153 
154 	return;
155 }
156 
157 
158 void
159 rf_ContinueDagAccess(RF_DagList_t * dagList)
160 {
161 	RF_AccTraceEntry_t *tracerec = &(dagList->desc->tracerec);
162 	RF_RaidAccessDesc_t *desc;
163 	RF_DagHeader_t *dag_h;
164 	RF_Etimer_t timer;
165 	int     i;
166 
167 	desc = dagList->desc;
168 
169 	timer = tracerec->timer;
170 	RF_ETIMER_STOP(timer);
171 	RF_ETIMER_EVAL(timer);
172 	tracerec->specific.user.exec_us = RF_ETIMER_VAL_US(timer);
173 	RF_ETIMER_START(tracerec->timer);
174 
175 	/* skip to dag which just finished */
176 	dag_h = dagList->dags;
177 	for (i = 0; i < dagList->numDagsDone; i++) {
178 		dag_h = dag_h->next;
179 	}
180 
181 	/* check to see if retry is required */
182 	if (dag_h->status == rf_rollBackward) {
183 		/* when a dag fails, mark desc status as bad and allow all
184 		 * other dags in the desc to execute to completion.  then,
185 		 * free all dags and start over */
186 		desc->status = 1;	/* bad status */
187 		{
188 			printf("[%d] DAG failure: %c addr 0x%lx (%ld) nblk 0x%x (%d) buf 0x%lx\n",
189 			    desc->tid, desc->type, (long) desc->raidAddress,
190 			    (long) desc->raidAddress, (int) desc->numBlocks,
191 			    (int) desc->numBlocks, (unsigned long) (desc->bufPtr));
192 		}
193 	}
194 	dagList->numDagsDone++;
195 	rf_ContinueRaidAccess(desc);
196 }
197 
198 
199 int
200 rf_State_LastState(RF_RaidAccessDesc_t * desc)
201 {
202 	void    (*callbackFunc) (RF_CBParam_t) = desc->callbackFunc;
203 	RF_CBParam_t callbackArg;
204 
205 	callbackArg.p = desc->callbackArg;
206 
207 	if (!(desc->flags & RF_DAG_TEST_ACCESS)) {	/* don't biodone if this */
208 #if DKUSAGE > 0
209 		RF_DKU_END_IO(((RF_Raid_t *) desc->raidPtr)->raidid, (struct buf *) desc->bp);
210 #else
211 		RF_DKU_END_IO(((RF_Raid_t *) desc->raidPtr)->raidid);
212 #endif				/* DKUSAGE > 0 */
213 
214 		/*
215 	         * If this is not an async request, wake up the caller
216 	         */
217 		if (desc->async_flag == 0)
218 			wakeup(desc->bp);
219 
220 		/*
221 		 * Wakeup any requests waiting to go.
222 		 */
223 
224 		RF_LOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
225 		((RF_Raid_t *) desc->raidPtr)->openings++;
226 		wakeup(&(((RF_Raid_t *) desc->raidPtr)->openings));
227 		RF_UNLOCK_MUTEX(((RF_Raid_t *) desc->raidPtr)->mutex);
228 
229 
230 		/* printf("Calling biodone on 0x%x\n",desc->bp); */
231 		biodone(desc->bp);	/* access came through ioctl */
232 	}
233 	if (callbackFunc)
234 		callbackFunc(callbackArg);
235 	rf_FreeRaidAccDesc(desc);
236 
237 	return RF_FALSE;
238 }
239 
240 int
241 rf_State_IncrAccessCount(RF_RaidAccessDesc_t * desc)
242 {
243 	RF_Raid_t *raidPtr;
244 
245 	raidPtr = desc->raidPtr;
246 	/* Bummer. We have to do this to be 100% safe w.r.t. the increment
247 	 * below */
248 	RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
249 	raidPtr->accs_in_flight++;	/* used to detect quiescence */
250 	RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
251 
252 	desc->state++;
253 	return RF_FALSE;
254 }
255 
256 int
257 rf_State_DecrAccessCount(RF_RaidAccessDesc_t * desc)
258 {
259 	RF_Raid_t *raidPtr;
260 
261 	raidPtr = desc->raidPtr;
262 
263 	RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
264 	raidPtr->accs_in_flight--;
265 	if (raidPtr->accesses_suspended && raidPtr->accs_in_flight == 0) {
266 		rf_SignalQuiescenceLock(raidPtr, raidPtr->reconDesc);
267 	}
268 	rf_UpdateUserStats(raidPtr, RF_ETIMER_VAL_US(desc->timer), desc->numBlocks);
269 	RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
270 
271 	desc->state++;
272 	return RF_FALSE;
273 }
274 
275 int
276 rf_State_Quiesce(RF_RaidAccessDesc_t * desc)
277 {
278 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
279 	RF_Etimer_t timer;
280 	int     suspended = RF_FALSE;
281 	RF_Raid_t *raidPtr;
282 
283 	raidPtr = desc->raidPtr;
284 
285 	RF_ETIMER_START(timer);
286 	RF_ETIMER_START(desc->timer);
287 
288 	RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
289 	if (raidPtr->accesses_suspended) {
290 		RF_CallbackDesc_t *cb;
291 		cb = rf_AllocCallbackDesc();
292 		/* XXX the following cast is quite bogus...
293 		 * rf_ContinueRaidAccess takes a (RF_RaidAccessDesc_t *) as an
294 		 * argument..  GO */
295 		cb->callbackFunc = (void (*) (RF_CBParam_t)) rf_ContinueRaidAccess;
296 		cb->callbackArg.p = (void *) desc;
297 		cb->next = raidPtr->quiesce_wait_list;
298 		raidPtr->quiesce_wait_list = cb;
299 		suspended = RF_TRUE;
300 	}
301 	RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
302 
303 	RF_ETIMER_STOP(timer);
304 	RF_ETIMER_EVAL(timer);
305 	tracerec->specific.user.suspend_ovhd_us += RF_ETIMER_VAL_US(timer);
306 
307 	if (suspended && rf_quiesceDebug)
308 		printf("Stalling access due to quiescence lock\n");
309 
310 	desc->state++;
311 	return suspended;
312 }
313 
314 int
315 rf_State_Map(RF_RaidAccessDesc_t * desc)
316 {
317 	RF_Raid_t *raidPtr = desc->raidPtr;
318 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
319 	RF_Etimer_t timer;
320 
321 	RF_ETIMER_START(timer);
322 
323 	if (!(desc->asmap = rf_MapAccess(raidPtr, desc->raidAddress, desc->numBlocks,
324 		    desc->bufPtr, RF_DONT_REMAP)))
325 		RF_PANIC();
326 
327 	RF_ETIMER_STOP(timer);
328 	RF_ETIMER_EVAL(timer);
329 	tracerec->specific.user.map_us = RF_ETIMER_VAL_US(timer);
330 
331 	desc->state++;
332 	return RF_FALSE;
333 }
334 
335 int
336 rf_State_Lock(RF_RaidAccessDesc_t * desc)
337 {
338 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
339 	RF_Raid_t *raidPtr = desc->raidPtr;
340 	RF_AccessStripeMapHeader_t *asmh = desc->asmap;
341 	RF_AccessStripeMap_t *asm_p;
342 	RF_Etimer_t timer;
343 	int     suspended = RF_FALSE;
344 
345 	RF_ETIMER_START(timer);
346 	if (!(raidPtr->Layout.map->flags & RF_NO_STRIPE_LOCKS)) {
347 		RF_StripeNum_t lastStripeID = -1;
348 
349 		/* acquire each lock that we don't already hold */
350 		for (asm_p = asmh->stripeMap; asm_p; asm_p = asm_p->next) {
351 			RF_ASSERT(RF_IO_IS_R_OR_W(desc->type));
352 			if (!rf_suppressLocksAndLargeWrites &&
353 			    asm_p->parityInfo &&
354 			    !(desc->flags & RF_DAG_SUPPRESS_LOCKS) &&
355 			    !(asm_p->flags & RF_ASM_FLAGS_LOCK_TRIED)) {
356 				asm_p->flags |= RF_ASM_FLAGS_LOCK_TRIED;
357 				RF_ASSERT(asm_p->stripeID > lastStripeID);	/* locks must be
358 										 * acquired
359 										 * hierarchically */
360 				lastStripeID = asm_p->stripeID;
361 				/* XXX the cast to (void (*)(RF_CBParam_t))
362 				 * below is bogus!  GO */
363 				RF_INIT_LOCK_REQ_DESC(asm_p->lockReqDesc, desc->type,
364 				    (void (*) (struct buf *)) rf_ContinueRaidAccess, desc, asm_p,
365 				    raidPtr->Layout.dataSectorsPerStripe);
366 				if (rf_AcquireStripeLock(raidPtr->lockTable, asm_p->stripeID,
367 					&asm_p->lockReqDesc)) {
368 					suspended = RF_TRUE;
369 					break;
370 				}
371 			}
372 			if (desc->type == RF_IO_TYPE_WRITE &&
373 			    raidPtr->status[asm_p->physInfo->row] == rf_rs_reconstructing) {
374 				if (!(asm_p->flags & RF_ASM_FLAGS_FORCE_TRIED)) {
375 					int     val;
376 
377 					asm_p->flags |= RF_ASM_FLAGS_FORCE_TRIED;
378 					/* XXX the cast below is quite
379 					 * bogus!!! XXX  GO */
380 					val = rf_ForceOrBlockRecon(raidPtr, asm_p,
381 					    (void (*) (RF_Raid_t *, void *)) rf_ContinueRaidAccess, desc);
382 					if (val == 0) {
383 						asm_p->flags |= RF_ASM_FLAGS_RECON_BLOCKED;
384 					} else {
385 						suspended = RF_TRUE;
386 						break;
387 					}
388 				} else {
389 					if (rf_pssDebug) {
390 						printf("[%d] skipping force/block because already done, psid %ld\n",
391 						    desc->tid, (long) asm_p->stripeID);
392 					}
393 				}
394 			} else {
395 				if (rf_pssDebug) {
396 					printf("[%d] skipping force/block because not write or not under recon, psid %ld\n",
397 					    desc->tid, (long) asm_p->stripeID);
398 				}
399 			}
400 		}
401 
402 		RF_ETIMER_STOP(timer);
403 		RF_ETIMER_EVAL(timer);
404 		tracerec->specific.user.lock_us += RF_ETIMER_VAL_US(timer);
405 
406 		if (suspended)
407 			return (RF_TRUE);
408 	}
409 	desc->state++;
410 	return (RF_FALSE);
411 }
412 /*
413  * the following three states create, execute, and post-process dags
414  * the error recovery unit is a single dag.
415  * by default, SelectAlgorithm creates an array of dags, one per parity stripe
416  * in some tricky cases, multiple dags per stripe are created
417  *   - dags within a parity stripe are executed sequentially (arbitrary order)
418  *   - dags for distinct parity stripes are executed concurrently
419  *
420  * repeat until all dags complete successfully -or- dag selection fails
421  *
422  * while !done
423  *   create dag(s) (SelectAlgorithm)
424  *   if dag
425  *     execute dag (DispatchDAG)
426  *     if dag successful
427  *       done (SUCCESS)
428  *     else
429  *       !done (RETRY - start over with new dags)
430  *   else
431  *     done (FAIL)
432  */
433 int
434 rf_State_CreateDAG(RF_RaidAccessDesc_t * desc)
435 {
436 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
437 	RF_Etimer_t timer;
438 	RF_DagHeader_t *dag_h;
439 	int     i, selectStatus;
440 
441 	/* generate a dag for the access, and fire it off.  When the dag
442 	 * completes, we'll get re-invoked in the next state. */
443 	RF_ETIMER_START(timer);
444 	/* SelectAlgorithm returns one or more dags */
445 	selectStatus = rf_SelectAlgorithm(desc, desc->flags | RF_DAG_SUPPRESS_LOCKS);
446 	if (rf_printDAGsDebug)
447 		for (i = 0; i < desc->numStripes; i++)
448 			rf_PrintDAGList(desc->dagArray[i].dags);
449 	RF_ETIMER_STOP(timer);
450 	RF_ETIMER_EVAL(timer);
451 	/* update time to create all dags */
452 	tracerec->specific.user.dag_create_us = RF_ETIMER_VAL_US(timer);
453 
454 	desc->status = 0;	/* good status */
455 
456 	if (selectStatus) {
457 		/* failed to create a dag */
458 		/* this happens when there are too many faults or incomplete
459 		 * dag libraries */
460 		printf("[Failed to create a DAG\n]");
461 		RF_PANIC();
462 	} else {
463 		/* bind dags to desc */
464 		for (i = 0; i < desc->numStripes; i++) {
465 			dag_h = desc->dagArray[i].dags;
466 			while (dag_h) {
467 				dag_h->bp = (struct buf *) desc->bp;
468 				dag_h->tracerec = tracerec;
469 				dag_h = dag_h->next;
470 			}
471 		}
472 		desc->flags |= RF_DAG_DISPATCH_RETURNED;
473 		desc->state++;	/* next state should be rf_State_ExecuteDAG */
474 	}
475 	return RF_FALSE;
476 }
477 
478 
479 
480 /* the access has an array of dagLists, one dagList per parity stripe.
481  * fire the first dag in each parity stripe (dagList).
482  * dags within a stripe (dagList) must be executed sequentially
483  *  - this preserves atomic parity update
484  * dags for independents parity groups (stripes) are fired concurrently */
485 
486 int
487 rf_State_ExecuteDAG(RF_RaidAccessDesc_t * desc)
488 {
489 	int     i;
490 	RF_DagHeader_t *dag_h;
491 	RF_DagList_t *dagArray = desc->dagArray;
492 
493 	/* next state is always rf_State_ProcessDAG important to do this
494 	 * before firing the first dag (it may finish before we leave this
495 	 * routine) */
496 	desc->state++;
497 
498 	/* sweep dag array, a stripe at a time, firing the first dag in each
499 	 * stripe */
500 	for (i = 0; i < desc->numStripes; i++) {
501 		RF_ASSERT(dagArray[i].numDags > 0);
502 		RF_ASSERT(dagArray[i].numDagsDone == 0);
503 		RF_ASSERT(dagArray[i].numDagsFired == 0);
504 		RF_ETIMER_START(dagArray[i].tracerec.timer);
505 		/* fire first dag in this stripe */
506 		dag_h = dagArray[i].dags;
507 		RF_ASSERT(dag_h);
508 		dagArray[i].numDagsFired++;
509 		/* XXX Yet another case where we pass in a conflicting
510 		 * function pointer :-(  XXX  GO */
511 		rf_DispatchDAG(dag_h, (void (*) (void *)) rf_ContinueDagAccess, &dagArray[i]);
512 	}
513 
514 	/* the DAG will always call the callback, even if there was no
515 	 * blocking, so we are always suspended in this state */
516 	return RF_TRUE;
517 }
518 
519 
520 
521 /* rf_State_ProcessDAG is entered when a dag completes.
522  * first, check to all dags in the access have completed
523  * if not, fire as many dags as possible */
524 
525 int
526 rf_State_ProcessDAG(RF_RaidAccessDesc_t * desc)
527 {
528 	RF_AccessStripeMapHeader_t *asmh = desc->asmap;
529 	RF_Raid_t *raidPtr = desc->raidPtr;
530 	RF_DagHeader_t *dag_h;
531 	int     i, j, done = RF_TRUE;
532 	RF_DagList_t *dagArray = desc->dagArray;
533 	RF_Etimer_t timer;
534 
535 	/* check to see if this is the last dag */
536 	for (i = 0; i < desc->numStripes; i++)
537 		if (dagArray[i].numDags != dagArray[i].numDagsDone)
538 			done = RF_FALSE;
539 
540 	if (done) {
541 		if (desc->status) {
542 			/* a dag failed, retry */
543 			RF_ETIMER_START(timer);
544 			/* free all dags */
545 			for (i = 0; i < desc->numStripes; i++) {
546 				rf_FreeDAG(desc->dagArray[i].dags);
547 			}
548 			rf_MarkFailuresInASMList(raidPtr, asmh);
549 			/* back up to rf_State_CreateDAG */
550 			desc->state = desc->state - 2;
551 			return RF_FALSE;
552 		} else {
553 			/* move on to rf_State_Cleanup */
554 			desc->state++;
555 		}
556 		return RF_FALSE;
557 	} else {
558 		/* more dags to execute */
559 		/* see if any are ready to be fired.  if so, fire them */
560 		/* don't fire the initial dag in a list, it's fired in
561 		 * rf_State_ExecuteDAG */
562 		for (i = 0; i < desc->numStripes; i++) {
563 			if ((dagArray[i].numDagsDone < dagArray[i].numDags)
564 			    && (dagArray[i].numDagsDone == dagArray[i].numDagsFired)
565 			    && (dagArray[i].numDagsFired > 0)) {
566 				RF_ETIMER_START(dagArray[i].tracerec.timer);
567 				/* fire next dag in this stripe */
568 				/* first, skip to next dag awaiting execution */
569 				dag_h = dagArray[i].dags;
570 				for (j = 0; j < dagArray[i].numDagsDone; j++)
571 					dag_h = dag_h->next;
572 				dagArray[i].numDagsFired++;
573 				/* XXX and again we pass a different function
574 				 * pointer.. GO */
575 				rf_DispatchDAG(dag_h, (void (*) (void *)) rf_ContinueDagAccess,
576 				    &dagArray[i]);
577 			}
578 		}
579 		return RF_TRUE;
580 	}
581 }
582 /* only make it this far if all dags complete successfully */
583 int
584 rf_State_Cleanup(RF_RaidAccessDesc_t * desc)
585 {
586 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
587 	RF_AccessStripeMapHeader_t *asmh = desc->asmap;
588 	RF_Raid_t *raidPtr = desc->raidPtr;
589 	RF_AccessStripeMap_t *asm_p;
590 	RF_DagHeader_t *dag_h;
591 	RF_Etimer_t timer;
592 	int     tid, i;
593 
594 	desc->state++;
595 
596 	rf_get_threadid(tid);
597 
598 	timer = tracerec->timer;
599 	RF_ETIMER_STOP(timer);
600 	RF_ETIMER_EVAL(timer);
601 	tracerec->specific.user.dag_retry_us = RF_ETIMER_VAL_US(timer);
602 
603 	/* the RAID I/O is complete.  Clean up. */
604 	tracerec->specific.user.dag_retry_us = 0;
605 
606 	RF_ETIMER_START(timer);
607 	if (desc->flags & RF_DAG_RETURN_DAG) {
608 		/* copy dags into paramDAG */
609 		*(desc->paramDAG) = desc->dagArray[0].dags;
610 		dag_h = *(desc->paramDAG);
611 		for (i = 1; i < desc->numStripes; i++) {
612 			/* concatenate dags from remaining stripes */
613 			RF_ASSERT(dag_h);
614 			while (dag_h->next)
615 				dag_h = dag_h->next;
616 			dag_h->next = desc->dagArray[i].dags;
617 		}
618 	} else {
619 		/* free all dags */
620 		for (i = 0; i < desc->numStripes; i++) {
621 			rf_FreeDAG(desc->dagArray[i].dags);
622 		}
623 	}
624 
625 	RF_ETIMER_STOP(timer);
626 	RF_ETIMER_EVAL(timer);
627 	tracerec->specific.user.cleanup_us = RF_ETIMER_VAL_US(timer);
628 
629 	RF_ETIMER_START(timer);
630 	if (!(raidPtr->Layout.map->flags & RF_NO_STRIPE_LOCKS)) {
631 		for (asm_p = asmh->stripeMap; asm_p; asm_p = asm_p->next) {
632 			if (!rf_suppressLocksAndLargeWrites &&
633 			    asm_p->parityInfo &&
634 			    !(desc->flags & RF_DAG_SUPPRESS_LOCKS)) {
635 				RF_ASSERT_VALID_LOCKREQ(&asm_p->lockReqDesc);
636 				rf_ReleaseStripeLock(raidPtr->lockTable, asm_p->stripeID,
637 				    &asm_p->lockReqDesc);
638 			}
639 			if (asm_p->flags & RF_ASM_FLAGS_RECON_BLOCKED) {
640 				rf_UnblockRecon(raidPtr, asm_p);
641 			}
642 		}
643 	}
644 	RF_ETIMER_STOP(timer);
645 	RF_ETIMER_EVAL(timer);
646 	tracerec->specific.user.lock_us += RF_ETIMER_VAL_US(timer);
647 
648 	RF_ETIMER_START(timer);
649 	if (desc->flags & RF_DAG_RETURN_ASM)
650 		*(desc->paramASM) = asmh;
651 	else
652 		rf_FreeAccessStripeMap(asmh);
653 	RF_ETIMER_STOP(timer);
654 	RF_ETIMER_EVAL(timer);
655 	tracerec->specific.user.cleanup_us += RF_ETIMER_VAL_US(timer);
656 
657 	RF_ETIMER_STOP(desc->timer);
658 	RF_ETIMER_EVAL(desc->timer);
659 
660 	timer = desc->tracerec.tot_timer;
661 	RF_ETIMER_STOP(timer);
662 	RF_ETIMER_EVAL(timer);
663 	desc->tracerec.total_us = RF_ETIMER_VAL_US(timer);
664 
665 	rf_LogTraceRec(raidPtr, tracerec);
666 
667 	desc->flags |= RF_DAG_ACCESS_COMPLETE;
668 
669 	return RF_FALSE;
670 }
671