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