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