Home | History | Annotate | Line # | Download | only in raidframe
rf_aselect.c revision 1.13
      1  1.13  oster /*	$NetBSD: rf_aselect.c,v 1.13 2004/02/29 01:24:34 oster Exp $	*/
      2   1.1  oster /*
      3   1.1  oster  * Copyright (c) 1995 Carnegie-Mellon University.
      4   1.1  oster  * All rights reserved.
      5   1.1  oster  *
      6   1.1  oster  * Author: Mark Holland, William V. Courtright II
      7   1.1  oster  *
      8   1.1  oster  * Permission to use, copy, modify and distribute this software and
      9   1.1  oster  * its documentation is hereby granted, provided that both the copyright
     10   1.1  oster  * notice and this permission notice appear in all copies of the
     11   1.1  oster  * software, derivative works or modified versions, and any portions
     12   1.1  oster  * thereof, and that both notices appear in supporting documentation.
     13   1.1  oster  *
     14   1.1  oster  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15   1.1  oster  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16   1.1  oster  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17   1.1  oster  *
     18   1.1  oster  * Carnegie Mellon requests users of this software to return to
     19   1.1  oster  *
     20   1.1  oster  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21   1.1  oster  *  School of Computer Science
     22   1.1  oster  *  Carnegie Mellon University
     23   1.1  oster  *  Pittsburgh PA 15213-3890
     24   1.1  oster  *
     25   1.1  oster  * any improvements or extensions that they make and grant Carnegie the
     26   1.1  oster  * rights to redistribute these changes.
     27   1.1  oster  */
     28   1.1  oster 
     29   1.1  oster /*****************************************************************************
     30   1.1  oster  *
     31   1.1  oster  * aselect.c -- algorithm selection code
     32   1.3  oster  *
     33   1.1  oster  *****************************************************************************/
     34   1.5  lukem 
     35   1.5  lukem #include <sys/cdefs.h>
     36  1.13  oster __KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.13 2004/02/29 01:24:34 oster Exp $");
     37   1.2  oster 
     38   1.4  oster #include <dev/raidframe/raidframevar.h>
     39   1.1  oster 
     40   1.1  oster #include "rf_archs.h"
     41   1.1  oster #include "rf_raid.h"
     42   1.1  oster #include "rf_dag.h"
     43   1.1  oster #include "rf_dagutils.h"
     44   1.1  oster #include "rf_dagfuncs.h"
     45   1.1  oster #include "rf_general.h"
     46   1.1  oster #include "rf_desc.h"
     47   1.1  oster #include "rf_map.h"
     48   1.1  oster 
     49   1.1  oster #if defined(__NetBSD__) && defined(_KERNEL)
     50   1.1  oster /* the function below is not used... so don't define it! */
     51   1.1  oster #else
     52   1.1  oster static void TransferDagMemory(RF_DagHeader_t *, RF_DagHeader_t *);
     53   1.1  oster #endif
     54   1.1  oster 
     55   1.7  oster static int InitHdrNode(RF_DagHeader_t **, RF_Raid_t *);
     56   1.3  oster int     rf_SelectAlgorithm(RF_RaidAccessDesc_t *, RF_RaidAccessFlags_t);
     57   1.1  oster 
     58   1.1  oster /******************************************************************************
     59   1.1  oster  *
     60   1.1  oster  * Create and Initialiaze a dag header and termination node
     61   1.1  oster  *
     62   1.1  oster  *****************************************************************************/
     63   1.3  oster static int
     64  1.10  oster InitHdrNode(RF_DagHeader_t **hdr, RF_Raid_t *raidPtr)
     65   1.1  oster {
     66   1.3  oster 	/* create and initialize dag hdr */
     67   1.3  oster 	*hdr = rf_AllocDAGHeader();
     68   1.3  oster 	rf_MakeAllocList((*hdr)->allocList);
     69   1.3  oster 	if ((*hdr)->allocList == NULL) {
     70   1.3  oster 		rf_FreeDAGHeader(*hdr);
     71   1.3  oster 		return (ENOMEM);
     72   1.3  oster 	}
     73   1.3  oster 	(*hdr)->status = rf_enable;
     74   1.3  oster 	(*hdr)->numSuccedents = 0;
     75   1.3  oster 	(*hdr)->raidPtr = raidPtr;
     76   1.3  oster 	(*hdr)->next = NULL;
     77   1.3  oster 	return (0);
     78   1.1  oster }
     79   1.1  oster 
     80   1.1  oster /******************************************************************************
     81   1.1  oster  *
     82   1.1  oster  * Create a DAG to do a read or write operation.
     83   1.1  oster  *
     84  1.12  oster  * create a list of dagLists, one list per parity stripe.
     85  1.12  oster  * return the lists in the desc->dagList (which is a list of lists).
     86   1.1  oster  *
     87   1.1  oster  * Normally, each list contains one dag for the entire stripe.  In some
     88   1.1  oster  * tricky cases, we break this into multiple dags, either one per stripe
     89   1.1  oster  * unit or one per block (sector).  When this occurs, these dags are returned
     90   1.1  oster  * as a linked list (dagList) which is executed sequentially (to preserve
     91   1.1  oster  * atomic parity updates in the stripe).
     92   1.3  oster  *
     93   1.1  oster  * dags which operate on independent parity goups (stripes) are returned in
     94   1.1  oster  * independent dagLists (distinct elements in desc->dagArray) and may be
     95   1.1  oster  * executed concurrently.
     96   1.1  oster  *
     97   1.1  oster  * Finally, if the SelectionFunc fails to create a dag for a block, we punt
     98   1.1  oster  * and return 1.
     99   1.1  oster  *
    100   1.1  oster  * The above process is performed in two phases:
    101   1.1  oster  *   1) create an array(s) of creation functions (eg stripeFuncs)
    102   1.1  oster  *   2) create dags and concatenate/merge to form the final dag.
    103   1.1  oster  *
    104   1.1  oster  * Because dag's are basic blocks (single entry, single exit, unconditional
    105   1.1  oster  * control flow, we can add the following optimizations (future work):
    106   1.1  oster  *   first-pass optimizer to allow max concurrency (need all data dependencies)
    107   1.1  oster  *   second-pass optimizer to eliminate common subexpressions (need true
    108   1.1  oster  *                         data dependencies)
    109   1.1  oster  *   third-pass optimizer to eliminate dead code (need true data dependencies)
    110   1.1  oster  *****************************************************************************/
    111   1.1  oster 
    112   1.1  oster #define MAXNSTRIPES 50
    113   1.1  oster 
    114   1.3  oster int
    115  1.10  oster rf_SelectAlgorithm(RF_RaidAccessDesc_t *desc, RF_RaidAccessFlags_t flags)
    116   1.1  oster {
    117   1.3  oster 	RF_AccessStripeMapHeader_t *asm_h = desc->asmap;
    118   1.3  oster 	RF_IoType_t type = desc->type;
    119   1.3  oster 	RF_Raid_t *raidPtr = desc->raidPtr;
    120   1.3  oster 	void   *bp = desc->bp;
    121   1.3  oster 
    122   1.3  oster 	RF_AccessStripeMap_t *asmap = asm_h->stripeMap;
    123   1.3  oster 	RF_AccessStripeMap_t *asm_p;
    124   1.3  oster 	RF_DagHeader_t *dag_h = NULL, *tempdag_h, *lastdag_h;
    125  1.12  oster 	RF_DagList_t *dagList, *dagListend;
    126   1.3  oster 	int     i, j, k;
    127  1.13  oster 	RF_FuncList_t *stripeFuncsList, *stripeFuncs, *stripeFuncsEnd, *temp;
    128   1.3  oster 	RF_AccessStripeMap_t *asm_up, *asm_bp;
    129   1.3  oster 	RF_AccessStripeMapHeader_t ***asmh_u, *endASMList;
    130   1.3  oster 	RF_AccessStripeMapHeader_t ***asmh_b;
    131   1.3  oster 	RF_VoidFuncPtr **stripeUnitFuncs, uFunc;
    132   1.3  oster 	RF_VoidFuncPtr **blockFuncs, bFunc;
    133   1.3  oster 	int     numStripesBailed = 0, cantCreateDAGs = RF_FALSE;
    134   1.3  oster 	int     numStripeUnitsBailed = 0;
    135   1.3  oster 	int     stripeNum, numUnitDags = 0, stripeUnitNum, numBlockDags = 0;
    136   1.3  oster 	RF_StripeNum_t numStripeUnits;
    137   1.3  oster 	RF_SectorNum_t numBlocks;
    138   1.3  oster 	RF_RaidAddr_t address;
    139   1.3  oster 	int     length;
    140   1.3  oster 	RF_PhysDiskAddr_t *physPtr;
    141   1.3  oster 	caddr_t buffer;
    142   1.3  oster 
    143   1.3  oster 	lastdag_h = NULL;
    144   1.3  oster 	asmh_u = asmh_b = NULL;
    145   1.3  oster 	stripeUnitFuncs = NULL;
    146   1.3  oster 	blockFuncs = NULL;
    147   1.3  oster 
    148  1.13  oster 	stripeFuncsList = NULL;
    149  1.13  oster 	stripeFuncsEnd = NULL;
    150   1.3  oster 
    151   1.3  oster 	/* walk through the asm list once collecting information */
    152   1.3  oster 	/* attempt to find a single creation function for each stripe */
    153   1.3  oster 	desc->numStripes = 0;
    154   1.3  oster 	for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
    155   1.3  oster 		desc->numStripes++;
    156  1.13  oster 		stripeFuncs = rf_AllocFuncList();
    157  1.13  oster 
    158  1.13  oster 		if (stripeFuncsEnd == NULL) {
    159  1.13  oster 			stripeFuncsList = stripeFuncs;
    160  1.13  oster 		} else {
    161  1.13  oster 			stripeFuncsEnd->next = stripeFuncs;
    162  1.13  oster 		}
    163  1.13  oster 		stripeFuncsEnd = stripeFuncs;
    164  1.13  oster 
    165  1.13  oster 		(raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_p, &(stripeFuncs->fp));
    166   1.3  oster 		/* check to see if we found a creation func for this stripe */
    167  1.13  oster 		if (stripeFuncs->fp == NULL) {
    168   1.3  oster 			/* could not find creation function for entire stripe
    169   1.3  oster 			 * so, let's see if we can find one for each stripe
    170   1.3  oster 			 * unit in the stripe */
    171   1.3  oster 
    172   1.3  oster 			if (numStripesBailed == 0) {
    173   1.3  oster 				/* one stripe map header for each stripe we
    174   1.3  oster 				 * bail on */
    175   1.3  oster 				RF_Malloc(asmh_u, sizeof(RF_AccessStripeMapHeader_t **) * asm_h->numStripes, (RF_AccessStripeMapHeader_t ***));
    176   1.3  oster 				/* create an array of ptrs to arrays of
    177   1.3  oster 				 * stripeFuncs */
    178   1.9  oster 				RF_Malloc(stripeUnitFuncs, asm_h->numStripes * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr **));
    179   1.3  oster 			}
    180   1.3  oster 			/* create an array of creation funcs (called
    181   1.3  oster 			 * stripeFuncs) for this stripe */
    182   1.3  oster 			numStripeUnits = asm_p->numStripeUnitsAccessed;
    183   1.9  oster 			RF_Malloc(stripeUnitFuncs[numStripesBailed], numStripeUnits * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
    184   1.3  oster 			RF_Malloc(asmh_u[numStripesBailed], numStripeUnits * sizeof(RF_AccessStripeMapHeader_t *), (RF_AccessStripeMapHeader_t **));
    185   1.3  oster 
    186   1.3  oster 			/* lookup array of stripeUnitFuncs for this stripe */
    187   1.3  oster 			for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
    188   1.3  oster 				/* remap for series of single stripe-unit
    189   1.3  oster 				 * accesses */
    190   1.3  oster 				address = physPtr->raidAddress;
    191   1.3  oster 				length = physPtr->numSector;
    192   1.3  oster 				buffer = physPtr->bufPtr;
    193   1.3  oster 
    194   1.3  oster 				asmh_u[numStripesBailed][j] = rf_MapAccess(raidPtr, address, length, buffer, RF_DONT_REMAP);
    195   1.3  oster 				asm_up = asmh_u[numStripesBailed][j]->stripeMap;
    196   1.3  oster 
    197   1.3  oster 				/* get the creation func for this stripe unit */
    198   1.3  oster 				(raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_up, &(stripeUnitFuncs[numStripesBailed][j]));
    199   1.3  oster 
    200   1.3  oster 				/* check to see if we found a creation func
    201   1.3  oster 				 * for this stripe unit */
    202   1.3  oster 				if (stripeUnitFuncs[numStripesBailed][j] == (RF_VoidFuncPtr) NULL) {
    203   1.3  oster 					/* could not find creation function
    204   1.3  oster 					 * for stripe unit so, let's see if we
    205   1.3  oster 					 * can find one for each block in the
    206   1.3  oster 					 * stripe unit */
    207   1.3  oster 					if (numStripeUnitsBailed == 0) {
    208   1.3  oster 						/* one stripe map header for
    209   1.3  oster 						 * each stripe unit we bail on */
    210   1.3  oster 						RF_Malloc(asmh_b, sizeof(RF_AccessStripeMapHeader_t **) * asm_h->numStripes * raidPtr->Layout.numDataCol, (RF_AccessStripeMapHeader_t ***));
    211   1.3  oster 						/* create an array of ptrs to
    212   1.3  oster 						 * arrays of blockFuncs */
    213   1.9  oster 						RF_Malloc(blockFuncs, asm_h->numStripes * raidPtr->Layout.numDataCol * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr **));
    214   1.3  oster 					}
    215   1.3  oster 					/* create an array of creation funcs
    216   1.3  oster 					 * (called blockFuncs) for this stripe
    217   1.3  oster 					 * unit */
    218   1.3  oster 					numBlocks = physPtr->numSector;
    219   1.3  oster 					numBlockDags += numBlocks;
    220   1.9  oster 					RF_Malloc(blockFuncs[numStripeUnitsBailed], numBlocks * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
    221   1.3  oster 					RF_Malloc(asmh_b[numStripeUnitsBailed], numBlocks * sizeof(RF_AccessStripeMapHeader_t *), (RF_AccessStripeMapHeader_t **));
    222   1.3  oster 
    223   1.3  oster 					/* lookup array of blockFuncs for this
    224   1.3  oster 					 * stripe unit */
    225   1.3  oster 					for (k = 0; k < numBlocks; k++) {
    226   1.3  oster 						/* remap for series of single
    227   1.3  oster 						 * stripe-unit accesses */
    228   1.3  oster 						address = physPtr->raidAddress + k;
    229   1.3  oster 						length = 1;
    230   1.3  oster 						buffer = physPtr->bufPtr + (k * (1 << raidPtr->logBytesPerSector));
    231   1.3  oster 
    232   1.3  oster 						asmh_b[numStripeUnitsBailed][k] = rf_MapAccess(raidPtr, address, length, buffer, RF_DONT_REMAP);
    233   1.3  oster 						asm_bp = asmh_b[numStripeUnitsBailed][k]->stripeMap;
    234   1.3  oster 
    235   1.3  oster 						/* get the creation func for
    236   1.3  oster 						 * this stripe unit */
    237   1.3  oster 						(raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_bp, &(blockFuncs[numStripeUnitsBailed][k]));
    238   1.3  oster 
    239   1.3  oster 						/* check to see if we found a
    240   1.3  oster 						 * creation func for this
    241   1.3  oster 						 * stripe unit */
    242   1.3  oster 						if (blockFuncs[numStripeUnitsBailed][k] == NULL)
    243   1.3  oster 							cantCreateDAGs = RF_TRUE;
    244   1.3  oster 					}
    245   1.3  oster 					numStripeUnitsBailed++;
    246   1.3  oster 				} else {
    247   1.3  oster 					numUnitDags++;
    248   1.3  oster 				}
    249   1.3  oster 			}
    250   1.3  oster 			RF_ASSERT(j == numStripeUnits);
    251   1.3  oster 			numStripesBailed++;
    252   1.3  oster 		}
    253   1.1  oster 	}
    254   1.3  oster 
    255   1.3  oster 	if (cantCreateDAGs) {
    256   1.3  oster 		/* free memory and punt */
    257   1.3  oster 		if (numStripesBailed > 0) {
    258   1.3  oster 			stripeNum = 0;
    259  1.13  oster 			stripeFuncs = stripeFuncsList;
    260  1.13  oster 			for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
    261  1.13  oster 				if (stripeFuncs->fp == NULL) {
    262   1.3  oster 					numStripeUnits = asm_p->numStripeUnitsAccessed;
    263   1.3  oster 					for (j = 0; j < numStripeUnits; j++)
    264   1.3  oster 						rf_FreeAccessStripeMap(asmh_u[stripeNum][j]);
    265   1.3  oster 					RF_Free(asmh_u[stripeNum], numStripeUnits * sizeof(RF_AccessStripeMapHeader_t *));
    266   1.3  oster 					RF_Free(stripeUnitFuncs[stripeNum], numStripeUnits * sizeof(RF_VoidFuncPtr));
    267   1.3  oster 					stripeNum++;
    268   1.3  oster 				}
    269  1.13  oster 				stripeFuncs = stripeFuncs->next;
    270  1.13  oster 			}
    271   1.3  oster 			RF_ASSERT(stripeNum == numStripesBailed);
    272   1.3  oster 			RF_Free(stripeUnitFuncs, asm_h->numStripes * sizeof(RF_VoidFuncPtr));
    273   1.3  oster 			RF_Free(asmh_u, asm_h->numStripes * sizeof(RF_AccessStripeMapHeader_t **));
    274   1.3  oster 		}
    275  1.13  oster 		while (stripeFuncsList != NULL) {
    276  1.13  oster 			temp = stripeFuncsList;
    277  1.13  oster 			stripeFuncsList = stripeFuncsList->next;
    278  1.13  oster 			rf_FreeFuncList(temp);
    279  1.13  oster 		}
    280  1.11  oster 		desc->numStripes = 0;
    281   1.3  oster 		return (1);
    282   1.3  oster 	} else {
    283   1.3  oster 		/* begin dag creation */
    284   1.3  oster 		stripeNum = 0;
    285   1.3  oster 		stripeUnitNum = 0;
    286   1.3  oster 
    287  1.12  oster 		/* create a list of dagLists and fill them in */
    288  1.12  oster 
    289  1.12  oster 		dagListend = NULL;
    290   1.3  oster 
    291  1.13  oster 		stripeFuncs = stripeFuncsList;
    292   1.3  oster 		for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
    293   1.3  oster 			/* grab dag header for this stripe */
    294   1.3  oster 			dag_h = NULL;
    295  1.12  oster 
    296  1.12  oster 			dagList = rf_AllocDAGList();
    297  1.12  oster 
    298  1.12  oster 			/* always tack the new dagList onto the end of the list... */
    299  1.12  oster 			if (dagListend == NULL) {
    300  1.12  oster 				desc->dagList = dagList;
    301  1.12  oster 			} else {
    302  1.12  oster 				dagListend->next = dagList;
    303  1.12  oster 			}
    304  1.12  oster 			dagListend = dagList;
    305  1.12  oster 
    306  1.12  oster 			dagList->desc = desc;
    307   1.3  oster 
    308  1.13  oster 			if (stripeFuncs->fp == NULL) {
    309   1.3  oster 				/* use bailout functions for this stripe */
    310   1.3  oster 				for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
    311   1.3  oster 					uFunc = stripeUnitFuncs[stripeNum][j];
    312   1.3  oster 					if (uFunc == (RF_VoidFuncPtr) NULL) {
    313   1.3  oster 						/* use bailout functions for
    314   1.3  oster 						 * this stripe unit */
    315   1.3  oster 						for (k = 0; k < physPtr->numSector; k++) {
    316   1.3  oster 							/* create a dag for
    317   1.3  oster 							 * this block */
    318   1.7  oster 							InitHdrNode(&tempdag_h, raidPtr);
    319  1.12  oster 							dagList->numDags++;
    320   1.3  oster 							if (dag_h == NULL) {
    321   1.3  oster 								dag_h = tempdag_h;
    322   1.3  oster 							} else {
    323   1.3  oster 								lastdag_h->next = tempdag_h;
    324   1.3  oster 							}
    325   1.3  oster 							lastdag_h = tempdag_h;
    326   1.3  oster 
    327   1.3  oster 							bFunc = blockFuncs[stripeUnitNum][k];
    328   1.3  oster 							RF_ASSERT(bFunc);
    329   1.3  oster 							asm_bp = asmh_b[stripeUnitNum][k]->stripeMap;
    330   1.3  oster 							(*bFunc) (raidPtr, asm_bp, tempdag_h, bp, flags, tempdag_h->allocList);
    331   1.3  oster 						}
    332   1.3  oster 						stripeUnitNum++;
    333   1.3  oster 					} else {
    334   1.3  oster 						/* create a dag for this unit */
    335   1.7  oster 						InitHdrNode(&tempdag_h, raidPtr);
    336  1.12  oster 						dagList->numDags++;
    337   1.3  oster 						if (dag_h == NULL) {
    338   1.3  oster 							dag_h = tempdag_h;
    339   1.3  oster 						} else {
    340   1.3  oster 							lastdag_h->next = tempdag_h;
    341   1.3  oster 						}
    342   1.3  oster 						lastdag_h = tempdag_h;
    343   1.3  oster 
    344   1.3  oster 						asm_up = asmh_u[stripeNum][j]->stripeMap;
    345   1.3  oster 						(*uFunc) (raidPtr, asm_up, tempdag_h, bp, flags, tempdag_h->allocList);
    346   1.3  oster 					}
    347   1.3  oster 				}
    348   1.3  oster 				RF_ASSERT(j == asm_p->numStripeUnitsAccessed);
    349   1.3  oster 				/* merge linked bailout dag to existing dag
    350   1.3  oster 				 * collection */
    351   1.3  oster 				stripeNum++;
    352   1.3  oster 			} else {
    353   1.3  oster 				/* Create a dag for this parity stripe */
    354   1.7  oster 				InitHdrNode(&tempdag_h, raidPtr);
    355  1.12  oster 				dagList->numDags++;
    356   1.3  oster 				if (dag_h == NULL) {
    357   1.3  oster 					dag_h = tempdag_h;
    358   1.3  oster 				} else {
    359   1.3  oster 					lastdag_h->next = tempdag_h;
    360   1.3  oster 				}
    361   1.3  oster 				lastdag_h = tempdag_h;
    362   1.3  oster 
    363  1.13  oster 				(stripeFuncs->fp) (raidPtr, asm_p, tempdag_h, bp, flags, tempdag_h->allocList);
    364   1.1  oster 			}
    365  1.12  oster 			dagList->dags = dag_h;
    366  1.13  oster 			stripeFuncs = stripeFuncs->next;
    367   1.3  oster 		}
    368   1.3  oster 		RF_ASSERT(i == desc->numStripes);
    369   1.3  oster 
    370   1.3  oster 		/* free memory */
    371   1.3  oster 		if ((numStripesBailed > 0) || (numStripeUnitsBailed > 0)) {
    372   1.3  oster 			stripeNum = 0;
    373   1.3  oster 			stripeUnitNum = 0;
    374   1.3  oster 			if (dag_h->asmList) {
    375   1.3  oster 				endASMList = dag_h->asmList;
    376   1.3  oster 				while (endASMList->next)
    377   1.3  oster 					endASMList = endASMList->next;
    378   1.3  oster 			} else
    379   1.3  oster 				endASMList = NULL;
    380   1.3  oster 			/* walk through io, stripe by stripe */
    381  1.13  oster 			stripeFuncs = stripeFuncsList;
    382  1.13  oster 			for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
    383  1.13  oster 				if (stripeFuncs->fp == NULL) {
    384   1.3  oster 					numStripeUnits = asm_p->numStripeUnitsAccessed;
    385   1.3  oster 					/* walk through stripe, stripe unit by
    386   1.3  oster 					 * stripe unit */
    387   1.3  oster 					for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
    388   1.3  oster 						if (stripeUnitFuncs[stripeNum][j] == NULL) {
    389   1.3  oster 							numBlocks = physPtr->numSector;
    390   1.3  oster 							/* walk through stripe
    391   1.3  oster 							 * unit, block by
    392   1.3  oster 							 * block */
    393   1.3  oster 							for (k = 0; k < numBlocks; k++)
    394   1.3  oster 								if (dag_h->asmList == NULL) {
    395   1.3  oster 									dag_h->asmList = asmh_b[stripeUnitNum][k];
    396   1.3  oster 									endASMList = dag_h->asmList;
    397   1.3  oster 								} else {
    398   1.3  oster 									endASMList->next = asmh_b[stripeUnitNum][k];
    399   1.3  oster 									endASMList = endASMList->next;
    400   1.3  oster 								}
    401   1.3  oster 							RF_Free(asmh_b[stripeUnitNum], numBlocks * sizeof(RF_AccessStripeMapHeader_t *));
    402   1.3  oster 							RF_Free(blockFuncs[stripeUnitNum], numBlocks * sizeof(RF_VoidFuncPtr));
    403   1.3  oster 							stripeUnitNum++;
    404   1.3  oster 						}
    405   1.3  oster 						if (dag_h->asmList == NULL) {
    406   1.3  oster 							dag_h->asmList = asmh_u[stripeNum][j];
    407   1.3  oster 							endASMList = dag_h->asmList;
    408   1.3  oster 						} else {
    409   1.3  oster 							endASMList->next = asmh_u[stripeNum][j];
    410   1.3  oster 							endASMList = endASMList->next;
    411   1.3  oster 						}
    412   1.3  oster 					}
    413   1.3  oster 					RF_Free(asmh_u[stripeNum], numStripeUnits * sizeof(RF_AccessStripeMapHeader_t *));
    414   1.3  oster 					RF_Free(stripeUnitFuncs[stripeNum], numStripeUnits * sizeof(RF_VoidFuncPtr));
    415   1.3  oster 					stripeNum++;
    416   1.3  oster 				}
    417  1.13  oster 				stripeFuncs = stripeFuncs->next;
    418  1.13  oster 			}
    419   1.3  oster 			RF_ASSERT(stripeNum == numStripesBailed);
    420   1.3  oster 			RF_Free(stripeUnitFuncs, asm_h->numStripes * sizeof(RF_VoidFuncPtr));
    421   1.3  oster 			RF_Free(asmh_u, asm_h->numStripes * sizeof(RF_AccessStripeMapHeader_t **));
    422   1.3  oster 			if (numStripeUnitsBailed > 0) {
    423   1.3  oster 				RF_ASSERT(stripeUnitNum == numStripeUnitsBailed);
    424   1.3  oster 				RF_Free(blockFuncs, raidPtr->Layout.numDataCol * asm_h->numStripes * sizeof(RF_VoidFuncPtr));
    425   1.3  oster 				RF_Free(asmh_b, raidPtr->Layout.numDataCol * asm_h->numStripes * sizeof(RF_AccessStripeMapHeader_t **));
    426   1.1  oster 			}
    427   1.3  oster 		}
    428  1.13  oster 		while (stripeFuncsList != NULL) {
    429  1.13  oster 			temp = stripeFuncsList;
    430  1.13  oster 			stripeFuncsList = stripeFuncsList->next;
    431  1.13  oster 			rf_FreeFuncList(temp);
    432  1.13  oster 		}
    433   1.3  oster 		return (0);
    434   1.1  oster 	}
    435   1.1  oster }
    436