Home | History | Annotate | Line # | Download | only in raidframe
rf_states.c revision 1.6
      1 /*	$NetBSD: rf_states.c,v 1.6 1999/02/05 00:06:17 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 
     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 		/* printf("Calling biodone on 0x%x\n",desc->bp); */
    221 		biodone(desc->bp);	/* access came through ioctl */
    222 	}
    223 	if (callbackFunc)
    224 		callbackFunc(callbackArg);
    225 	rf_FreeRaidAccDesc(desc);
    226 
    227 	return RF_FALSE;
    228 }
    229 
    230 int
    231 rf_State_IncrAccessCount(RF_RaidAccessDesc_t * desc)
    232 {
    233 	RF_Raid_t *raidPtr;
    234 
    235 	raidPtr = desc->raidPtr;
    236 	/* Bummer. We have to do this to be 100% safe w.r.t. the increment
    237 	 * below */
    238 	RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
    239 	raidPtr->accs_in_flight++;	/* used to detect quiescence */
    240 	RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
    241 
    242 	desc->state++;
    243 	return RF_FALSE;
    244 }
    245 
    246 int
    247 rf_State_DecrAccessCount(RF_RaidAccessDesc_t * desc)
    248 {
    249 	RF_Raid_t *raidPtr;
    250 
    251 	raidPtr = desc->raidPtr;
    252 
    253 	RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
    254 	raidPtr->accs_in_flight--;
    255 	if (raidPtr->accesses_suspended && raidPtr->accs_in_flight == 0) {
    256 		rf_SignalQuiescenceLock(raidPtr, raidPtr->reconDesc);
    257 	}
    258 	rf_UpdateUserStats(raidPtr, RF_ETIMER_VAL_US(desc->timer), desc->numBlocks);
    259 	RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
    260 
    261 	desc->state++;
    262 	return RF_FALSE;
    263 }
    264 
    265 int
    266 rf_State_Quiesce(RF_RaidAccessDesc_t * desc)
    267 {
    268 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
    269 	RF_Etimer_t timer;
    270 	int     suspended = RF_FALSE;
    271 	RF_Raid_t *raidPtr;
    272 
    273 	raidPtr = desc->raidPtr;
    274 
    275 	RF_ETIMER_START(timer);
    276 	RF_ETIMER_START(desc->timer);
    277 
    278 	RF_LOCK_MUTEX(raidPtr->access_suspend_mutex);
    279 	if (raidPtr->accesses_suspended) {
    280 		RF_CallbackDesc_t *cb;
    281 		cb = rf_AllocCallbackDesc();
    282 		/* XXX the following cast is quite bogus...
    283 		 * rf_ContinueRaidAccess takes a (RF_RaidAccessDesc_t *) as an
    284 		 * argument..  GO */
    285 		cb->callbackFunc = (void (*) (RF_CBParam_t)) rf_ContinueRaidAccess;
    286 		cb->callbackArg.p = (void *) desc;
    287 		cb->next = raidPtr->quiesce_wait_list;
    288 		raidPtr->quiesce_wait_list = cb;
    289 		suspended = RF_TRUE;
    290 	}
    291 	RF_UNLOCK_MUTEX(raidPtr->access_suspend_mutex);
    292 
    293 	RF_ETIMER_STOP(timer);
    294 	RF_ETIMER_EVAL(timer);
    295 	tracerec->specific.user.suspend_ovhd_us += RF_ETIMER_VAL_US(timer);
    296 
    297 	if (suspended && rf_quiesceDebug)
    298 		printf("Stalling access due to quiescence lock\n");
    299 
    300 	desc->state++;
    301 	return suspended;
    302 }
    303 
    304 int
    305 rf_State_Map(RF_RaidAccessDesc_t * desc)
    306 {
    307 	RF_Raid_t *raidPtr = desc->raidPtr;
    308 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
    309 	RF_Etimer_t timer;
    310 
    311 	RF_ETIMER_START(timer);
    312 
    313 	if (!(desc->asmap = rf_MapAccess(raidPtr, desc->raidAddress, desc->numBlocks,
    314 		    desc->bufPtr, RF_DONT_REMAP)))
    315 		RF_PANIC();
    316 
    317 	RF_ETIMER_STOP(timer);
    318 	RF_ETIMER_EVAL(timer);
    319 	tracerec->specific.user.map_us = RF_ETIMER_VAL_US(timer);
    320 
    321 	desc->state++;
    322 	return RF_FALSE;
    323 }
    324 
    325 int
    326 rf_State_Lock(RF_RaidAccessDesc_t * desc)
    327 {
    328 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
    329 	RF_Raid_t *raidPtr = desc->raidPtr;
    330 	RF_AccessStripeMapHeader_t *asmh = desc->asmap;
    331 	RF_AccessStripeMap_t *asm_p;
    332 	RF_Etimer_t timer;
    333 	int     suspended = RF_FALSE;
    334 
    335 	RF_ETIMER_START(timer);
    336 	if (!(raidPtr->Layout.map->flags & RF_NO_STRIPE_LOCKS)) {
    337 		RF_StripeNum_t lastStripeID = -1;
    338 
    339 		/* acquire each lock that we don't already hold */
    340 		for (asm_p = asmh->stripeMap; asm_p; asm_p = asm_p->next) {
    341 			RF_ASSERT(RF_IO_IS_R_OR_W(desc->type));
    342 			if (!rf_suppressLocksAndLargeWrites &&
    343 			    asm_p->parityInfo &&
    344 			    !(desc->flags & RF_DAG_SUPPRESS_LOCKS) &&
    345 			    !(asm_p->flags & RF_ASM_FLAGS_LOCK_TRIED)) {
    346 				asm_p->flags |= RF_ASM_FLAGS_LOCK_TRIED;
    347 				RF_ASSERT(asm_p->stripeID > lastStripeID);	/* locks must be
    348 										 * acquired
    349 										 * hierarchically */
    350 				lastStripeID = asm_p->stripeID;
    351 				/* XXX the cast to (void (*)(RF_CBParam_t))
    352 				 * below is bogus!  GO */
    353 				RF_INIT_LOCK_REQ_DESC(asm_p->lockReqDesc, desc->type,
    354 				    (void (*) (struct buf *)) rf_ContinueRaidAccess, desc, asm_p,
    355 				    raidPtr->Layout.dataSectorsPerStripe);
    356 				if (rf_AcquireStripeLock(raidPtr->lockTable, asm_p->stripeID,
    357 					&asm_p->lockReqDesc)) {
    358 					suspended = RF_TRUE;
    359 					break;
    360 				}
    361 			}
    362 			if (desc->type == RF_IO_TYPE_WRITE &&
    363 			    raidPtr->status[asm_p->physInfo->row] == rf_rs_reconstructing) {
    364 				if (!(asm_p->flags & RF_ASM_FLAGS_FORCE_TRIED)) {
    365 					int     val;
    366 
    367 					asm_p->flags |= RF_ASM_FLAGS_FORCE_TRIED;
    368 					/* XXX the cast below is quite
    369 					 * bogus!!! XXX  GO */
    370 					val = rf_ForceOrBlockRecon(raidPtr, asm_p,
    371 					    (void (*) (RF_Raid_t *, void *)) rf_ContinueRaidAccess, desc);
    372 					if (val == 0) {
    373 						asm_p->flags |= RF_ASM_FLAGS_RECON_BLOCKED;
    374 					} else {
    375 						suspended = RF_TRUE;
    376 						break;
    377 					}
    378 				} else {
    379 					if (rf_pssDebug) {
    380 						printf("[%d] skipping force/block because already done, psid %ld\n",
    381 						    desc->tid, (long) asm_p->stripeID);
    382 					}
    383 				}
    384 			} else {
    385 				if (rf_pssDebug) {
    386 					printf("[%d] skipping force/block because not write or not under recon, psid %ld\n",
    387 					    desc->tid, (long) asm_p->stripeID);
    388 				}
    389 			}
    390 		}
    391 
    392 		RF_ETIMER_STOP(timer);
    393 		RF_ETIMER_EVAL(timer);
    394 		tracerec->specific.user.lock_us += RF_ETIMER_VAL_US(timer);
    395 
    396 		if (suspended)
    397 			return (RF_TRUE);
    398 	}
    399 	desc->state++;
    400 	return (RF_FALSE);
    401 }
    402 /*
    403  * the following three states create, execute, and post-process dags
    404  * the error recovery unit is a single dag.
    405  * by default, SelectAlgorithm creates an array of dags, one per parity stripe
    406  * in some tricky cases, multiple dags per stripe are created
    407  *   - dags within a parity stripe are executed sequentially (arbitrary order)
    408  *   - dags for distinct parity stripes are executed concurrently
    409  *
    410  * repeat until all dags complete successfully -or- dag selection fails
    411  *
    412  * while !done
    413  *   create dag(s) (SelectAlgorithm)
    414  *   if dag
    415  *     execute dag (DispatchDAG)
    416  *     if dag successful
    417  *       done (SUCCESS)
    418  *     else
    419  *       !done (RETRY - start over with new dags)
    420  *   else
    421  *     done (FAIL)
    422  */
    423 int
    424 rf_State_CreateDAG(RF_RaidAccessDesc_t * desc)
    425 {
    426 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
    427 	RF_Etimer_t timer;
    428 	RF_DagHeader_t *dag_h;
    429 	int     i, selectStatus;
    430 
    431 	/* generate a dag for the access, and fire it off.  When the dag
    432 	 * completes, we'll get re-invoked in the next state. */
    433 	RF_ETIMER_START(timer);
    434 	/* SelectAlgorithm returns one or more dags */
    435 	selectStatus = rf_SelectAlgorithm(desc, desc->flags | RF_DAG_SUPPRESS_LOCKS);
    436 	if (rf_printDAGsDebug)
    437 		for (i = 0; i < desc->numStripes; i++)
    438 			rf_PrintDAGList(desc->dagArray[i].dags);
    439 	RF_ETIMER_STOP(timer);
    440 	RF_ETIMER_EVAL(timer);
    441 	/* update time to create all dags */
    442 	tracerec->specific.user.dag_create_us = RF_ETIMER_VAL_US(timer);
    443 
    444 	desc->status = 0;	/* good status */
    445 
    446 	if (selectStatus) {
    447 		/* failed to create a dag */
    448 		/* this happens when there are too many faults or incomplete
    449 		 * dag libraries */
    450 		printf("[Failed to create a DAG\n]");
    451 		RF_PANIC();
    452 	} else {
    453 		/* bind dags to desc */
    454 		for (i = 0; i < desc->numStripes; i++) {
    455 			dag_h = desc->dagArray[i].dags;
    456 			while (dag_h) {
    457 				dag_h->bp = (struct buf *) desc->bp;
    458 				dag_h->tracerec = tracerec;
    459 				dag_h = dag_h->next;
    460 			}
    461 		}
    462 		desc->flags |= RF_DAG_DISPATCH_RETURNED;
    463 		desc->state++;	/* next state should be rf_State_ExecuteDAG */
    464 	}
    465 	return RF_FALSE;
    466 }
    467 
    468 
    469 
    470 /* the access has an array of dagLists, one dagList per parity stripe.
    471  * fire the first dag in each parity stripe (dagList).
    472  * dags within a stripe (dagList) must be executed sequentially
    473  *  - this preserves atomic parity update
    474  * dags for independents parity groups (stripes) are fired concurrently */
    475 
    476 int
    477 rf_State_ExecuteDAG(RF_RaidAccessDesc_t * desc)
    478 {
    479 	int     i;
    480 	RF_DagHeader_t *dag_h;
    481 	RF_DagList_t *dagArray = desc->dagArray;
    482 
    483 	/* next state is always rf_State_ProcessDAG important to do this
    484 	 * before firing the first dag (it may finish before we leave this
    485 	 * routine) */
    486 	desc->state++;
    487 
    488 	/* sweep dag array, a stripe at a time, firing the first dag in each
    489 	 * stripe */
    490 	for (i = 0; i < desc->numStripes; i++) {
    491 		RF_ASSERT(dagArray[i].numDags > 0);
    492 		RF_ASSERT(dagArray[i].numDagsDone == 0);
    493 		RF_ASSERT(dagArray[i].numDagsFired == 0);
    494 		RF_ETIMER_START(dagArray[i].tracerec.timer);
    495 		/* fire first dag in this stripe */
    496 		dag_h = dagArray[i].dags;
    497 		RF_ASSERT(dag_h);
    498 		dagArray[i].numDagsFired++;
    499 		/* XXX Yet another case where we pass in a conflicting
    500 		 * function pointer :-(  XXX  GO */
    501 		rf_DispatchDAG(dag_h, (void (*) (void *)) rf_ContinueDagAccess, &dagArray[i]);
    502 	}
    503 
    504 	/* the DAG will always call the callback, even if there was no
    505 	 * blocking, so we are always suspended in this state */
    506 	return RF_TRUE;
    507 }
    508 
    509 
    510 
    511 /* rf_State_ProcessDAG is entered when a dag completes.
    512  * first, check to all dags in the access have completed
    513  * if not, fire as many dags as possible */
    514 
    515 int
    516 rf_State_ProcessDAG(RF_RaidAccessDesc_t * desc)
    517 {
    518 	RF_AccessStripeMapHeader_t *asmh = desc->asmap;
    519 	RF_Raid_t *raidPtr = desc->raidPtr;
    520 	RF_DagHeader_t *dag_h;
    521 	int     i, j, done = RF_TRUE;
    522 	RF_DagList_t *dagArray = desc->dagArray;
    523 	RF_Etimer_t timer;
    524 
    525 	/* check to see if this is the last dag */
    526 	for (i = 0; i < desc->numStripes; i++)
    527 		if (dagArray[i].numDags != dagArray[i].numDagsDone)
    528 			done = RF_FALSE;
    529 
    530 	if (done) {
    531 		if (desc->status) {
    532 			/* a dag failed, retry */
    533 			RF_ETIMER_START(timer);
    534 			/* free all dags */
    535 			for (i = 0; i < desc->numStripes; i++) {
    536 				rf_FreeDAG(desc->dagArray[i].dags);
    537 			}
    538 			rf_MarkFailuresInASMList(raidPtr, asmh);
    539 			/* back up to rf_State_CreateDAG */
    540 			desc->state = desc->state - 2;
    541 			return RF_FALSE;
    542 		} else {
    543 			/* move on to rf_State_Cleanup */
    544 			desc->state++;
    545 		}
    546 		return RF_FALSE;
    547 	} else {
    548 		/* more dags to execute */
    549 		/* see if any are ready to be fired.  if so, fire them */
    550 		/* don't fire the initial dag in a list, it's fired in
    551 		 * rf_State_ExecuteDAG */
    552 		for (i = 0; i < desc->numStripes; i++) {
    553 			if ((dagArray[i].numDagsDone < dagArray[i].numDags)
    554 			    && (dagArray[i].numDagsDone == dagArray[i].numDagsFired)
    555 			    && (dagArray[i].numDagsFired > 0)) {
    556 				RF_ETIMER_START(dagArray[i].tracerec.timer);
    557 				/* fire next dag in this stripe */
    558 				/* first, skip to next dag awaiting execution */
    559 				dag_h = dagArray[i].dags;
    560 				for (j = 0; j < dagArray[i].numDagsDone; j++)
    561 					dag_h = dag_h->next;
    562 				dagArray[i].numDagsFired++;
    563 				/* XXX and again we pass a different function
    564 				 * pointer.. GO */
    565 				rf_DispatchDAG(dag_h, (void (*) (void *)) rf_ContinueDagAccess,
    566 				    &dagArray[i]);
    567 			}
    568 		}
    569 		return RF_TRUE;
    570 	}
    571 }
    572 /* only make it this far if all dags complete successfully */
    573 int
    574 rf_State_Cleanup(RF_RaidAccessDesc_t * desc)
    575 {
    576 	RF_AccTraceEntry_t *tracerec = &desc->tracerec;
    577 	RF_AccessStripeMapHeader_t *asmh = desc->asmap;
    578 	RF_Raid_t *raidPtr = desc->raidPtr;
    579 	RF_AccessStripeMap_t *asm_p;
    580 	RF_DagHeader_t *dag_h;
    581 	RF_Etimer_t timer;
    582 	int     tid, i;
    583 
    584 	desc->state++;
    585 
    586 	rf_get_threadid(tid);
    587 
    588 	timer = tracerec->timer;
    589 	RF_ETIMER_STOP(timer);
    590 	RF_ETIMER_EVAL(timer);
    591 	tracerec->specific.user.dag_retry_us = RF_ETIMER_VAL_US(timer);
    592 
    593 	/* the RAID I/O is complete.  Clean up. */
    594 	tracerec->specific.user.dag_retry_us = 0;
    595 
    596 	RF_ETIMER_START(timer);
    597 	if (desc->flags & RF_DAG_RETURN_DAG) {
    598 		/* copy dags into paramDAG */
    599 		*(desc->paramDAG) = desc->dagArray[0].dags;
    600 		dag_h = *(desc->paramDAG);
    601 		for (i = 1; i < desc->numStripes; i++) {
    602 			/* concatenate dags from remaining stripes */
    603 			RF_ASSERT(dag_h);
    604 			while (dag_h->next)
    605 				dag_h = dag_h->next;
    606 			dag_h->next = desc->dagArray[i].dags;
    607 		}
    608 	} else {
    609 		/* free all dags */
    610 		for (i = 0; i < desc->numStripes; i++) {
    611 			rf_FreeDAG(desc->dagArray[i].dags);
    612 		}
    613 	}
    614 
    615 	RF_ETIMER_STOP(timer);
    616 	RF_ETIMER_EVAL(timer);
    617 	tracerec->specific.user.cleanup_us = RF_ETIMER_VAL_US(timer);
    618 
    619 	RF_ETIMER_START(timer);
    620 	if (!(raidPtr->Layout.map->flags & RF_NO_STRIPE_LOCKS)) {
    621 		for (asm_p = asmh->stripeMap; asm_p; asm_p = asm_p->next) {
    622 			if (!rf_suppressLocksAndLargeWrites &&
    623 			    asm_p->parityInfo &&
    624 			    !(desc->flags & RF_DAG_SUPPRESS_LOCKS)) {
    625 				RF_ASSERT_VALID_LOCKREQ(&asm_p->lockReqDesc);
    626 				rf_ReleaseStripeLock(raidPtr->lockTable, asm_p->stripeID,
    627 				    &asm_p->lockReqDesc);
    628 			}
    629 			if (asm_p->flags & RF_ASM_FLAGS_RECON_BLOCKED) {
    630 				rf_UnblockRecon(raidPtr, asm_p);
    631 			}
    632 		}
    633 	}
    634 	RF_ETIMER_STOP(timer);
    635 	RF_ETIMER_EVAL(timer);
    636 	tracerec->specific.user.lock_us += RF_ETIMER_VAL_US(timer);
    637 
    638 	RF_ETIMER_START(timer);
    639 	if (desc->flags & RF_DAG_RETURN_ASM)
    640 		*(desc->paramASM) = asmh;
    641 	else
    642 		rf_FreeAccessStripeMap(asmh);
    643 	RF_ETIMER_STOP(timer);
    644 	RF_ETIMER_EVAL(timer);
    645 	tracerec->specific.user.cleanup_us += RF_ETIMER_VAL_US(timer);
    646 
    647 	RF_ETIMER_STOP(desc->timer);
    648 	RF_ETIMER_EVAL(desc->timer);
    649 
    650 	timer = desc->tracerec.tot_timer;
    651 	RF_ETIMER_STOP(timer);
    652 	RF_ETIMER_EVAL(timer);
    653 	desc->tracerec.total_us = RF_ETIMER_VAL_US(timer);
    654 
    655 	rf_LogTraceRec(raidPtr, tracerec);
    656 
    657 	desc->flags |= RF_DAG_ACCESS_COMPLETE;
    658 
    659 	return RF_FALSE;
    660 }
    661