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