2006-03-23 06:43:54 +03:00
|
|
|
/* $NetBSD: rf_aselect.c,v 1.24 2006/03/23 03:43:54 oster Exp $ */
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Mark Holland, William V. Courtright II
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* aselect.c -- algorithm selection code
|
1999-02-05 03:06:06 +03:00
|
|
|
*
|
1998-11-13 07:20:26 +03:00
|
|
|
*****************************************************************************/
|
1999-01-26 05:33:49 +03:00
|
|
|
|
2001-11-13 10:11:12 +03:00
|
|
|
#include <sys/cdefs.h>
|
2006-03-23 06:43:54 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.24 2006/03/23 03:43:54 oster Exp $");
|
2001-11-13 10:11:12 +03:00
|
|
|
|
2001-10-04 19:58:51 +04:00
|
|
|
#include <dev/raidframe/raidframevar.h>
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
#include "rf_archs.h"
|
|
|
|
#include "rf_raid.h"
|
|
|
|
#include "rf_dag.h"
|
|
|
|
#include "rf_dagutils.h"
|
|
|
|
#include "rf_dagfuncs.h"
|
|
|
|
#include "rf_general.h"
|
|
|
|
#include "rf_desc.h"
|
|
|
|
#include "rf_map.h"
|
|
|
|
|
2004-04-10 03:10:16 +04:00
|
|
|
static void InitHdrNode(RF_DagHeader_t **, RF_Raid_t *, RF_RaidAccessDesc_t *);
|
1999-02-05 03:06:06 +03:00
|
|
|
int rf_SelectAlgorithm(RF_RaidAccessDesc_t *, RF_RaidAccessFlags_t);
|
1998-11-13 07:20:26 +03:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Create and Initialiaze a dag header and termination node
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2004-02-29 04:50:23 +03:00
|
|
|
static void
|
2004-04-10 03:10:16 +04:00
|
|
|
InitHdrNode(RF_DagHeader_t **hdr, RF_Raid_t *raidPtr, RF_RaidAccessDesc_t *desc)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
/* create and initialize dag hdr */
|
|
|
|
*hdr = rf_AllocDAGHeader();
|
|
|
|
rf_MakeAllocList((*hdr)->allocList);
|
|
|
|
(*hdr)->status = rf_enable;
|
|
|
|
(*hdr)->numSuccedents = 0;
|
2004-03-18 19:40:05 +03:00
|
|
|
(*hdr)->nodes = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
(*hdr)->raidPtr = raidPtr;
|
|
|
|
(*hdr)->next = NULL;
|
2004-04-10 03:10:16 +04:00
|
|
|
(*hdr)->desc = desc;
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Create a DAG to do a read or write operation.
|
|
|
|
*
|
2004-02-27 05:55:17 +03:00
|
|
|
* create a list of dagLists, one list per parity stripe.
|
|
|
|
* return the lists in the desc->dagList (which is a list of lists).
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* Normally, each list contains one dag for the entire stripe. In some
|
|
|
|
* tricky cases, we break this into multiple dags, either one per stripe
|
|
|
|
* unit or one per block (sector). When this occurs, these dags are returned
|
|
|
|
* as a linked list (dagList) which is executed sequentially (to preserve
|
|
|
|
* atomic parity updates in the stripe).
|
1999-02-05 03:06:06 +03:00
|
|
|
*
|
1998-11-13 07:20:26 +03:00
|
|
|
* dags which operate on independent parity goups (stripes) are returned in
|
|
|
|
* independent dagLists (distinct elements in desc->dagArray) and may be
|
|
|
|
* executed concurrently.
|
|
|
|
*
|
|
|
|
* Finally, if the SelectionFunc fails to create a dag for a block, we punt
|
|
|
|
* and return 1.
|
|
|
|
*
|
|
|
|
* The above process is performed in two phases:
|
|
|
|
* 1) create an array(s) of creation functions (eg stripeFuncs)
|
|
|
|
* 2) create dags and concatenate/merge to form the final dag.
|
|
|
|
*
|
|
|
|
* Because dag's are basic blocks (single entry, single exit, unconditional
|
|
|
|
* control flow, we can add the following optimizations (future work):
|
|
|
|
* first-pass optimizer to allow max concurrency (need all data dependencies)
|
|
|
|
* second-pass optimizer to eliminate common subexpressions (need true
|
|
|
|
* data dependencies)
|
|
|
|
* third-pass optimizer to eliminate dead code (need true data dependencies)
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#define MAXNSTRIPES 50
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-31 00:59:03 +03:00
|
|
|
rf_SelectAlgorithm(RF_RaidAccessDesc_t *desc, RF_RaidAccessFlags_t flags)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_AccessStripeMapHeader_t *asm_h = desc->asmap;
|
|
|
|
RF_IoType_t type = desc->type;
|
|
|
|
RF_Raid_t *raidPtr = desc->raidPtr;
|
|
|
|
void *bp = desc->bp;
|
|
|
|
|
|
|
|
RF_AccessStripeMap_t *asmap = asm_h->stripeMap;
|
|
|
|
RF_AccessStripeMap_t *asm_p;
|
|
|
|
RF_DagHeader_t *dag_h = NULL, *tempdag_h, *lastdag_h;
|
2004-02-27 05:55:17 +03:00
|
|
|
RF_DagList_t *dagList, *dagListend;
|
1999-02-05 03:06:06 +03:00
|
|
|
int i, j, k;
|
2004-02-29 04:24:34 +03:00
|
|
|
RF_FuncList_t *stripeFuncsList, *stripeFuncs, *stripeFuncsEnd, *temp;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_AccessStripeMap_t *asm_up, *asm_bp;
|
|
|
|
RF_AccessStripeMapHeader_t ***asmh_u, *endASMList;
|
|
|
|
RF_AccessStripeMapHeader_t ***asmh_b;
|
2004-03-19 05:27:44 +03:00
|
|
|
RF_ASMHeaderListElem_t *asmhle, *tmpasmhle;
|
|
|
|
RF_VoidFunctionPointerListElem_t *vfple, *tmpvfple;
|
|
|
|
RF_FailedStripe_t *failed_stripes_list, *failed_stripes_list_end;
|
|
|
|
RF_FailedStripe_t *tmpfailed_stripe, *failed_stripe = NULL;
|
|
|
|
RF_ASMHeaderListElem_t *failed_stripes_asmh_u_end = NULL;
|
|
|
|
RF_ASMHeaderListElem_t *failed_stripes_asmh_b_end = NULL;
|
|
|
|
RF_VoidFunctionPointerListElem_t *failed_stripes_vfple_end = NULL;
|
|
|
|
RF_VoidFunctionPointerListElem_t *failed_stripes_bvfple_end = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_VoidFuncPtr **stripeUnitFuncs, uFunc;
|
|
|
|
RF_VoidFuncPtr **blockFuncs, bFunc;
|
|
|
|
int numStripesBailed = 0, cantCreateDAGs = RF_FALSE;
|
|
|
|
int numStripeUnitsBailed = 0;
|
|
|
|
int stripeNum, numUnitDags = 0, stripeUnitNum, numBlockDags = 0;
|
|
|
|
RF_StripeNum_t numStripeUnits;
|
|
|
|
RF_SectorNum_t numBlocks;
|
|
|
|
RF_RaidAddr_t address;
|
|
|
|
int length;
|
|
|
|
RF_PhysDiskAddr_t *physPtr;
|
|
|
|
caddr_t buffer;
|
|
|
|
|
|
|
|
lastdag_h = NULL;
|
|
|
|
asmh_u = asmh_b = NULL;
|
|
|
|
stripeUnitFuncs = NULL;
|
|
|
|
blockFuncs = NULL;
|
|
|
|
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncsList = NULL;
|
|
|
|
stripeFuncsEnd = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripes_list = NULL;
|
|
|
|
failed_stripes_list_end = NULL;
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/* walk through the asm list once collecting information */
|
|
|
|
/* attempt to find a single creation function for each stripe */
|
|
|
|
desc->numStripes = 0;
|
|
|
|
for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
|
|
|
|
desc->numStripes++;
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = rf_AllocFuncList();
|
|
|
|
|
|
|
|
if (stripeFuncsEnd == NULL) {
|
|
|
|
stripeFuncsList = stripeFuncs;
|
|
|
|
} else {
|
|
|
|
stripeFuncsEnd->next = stripeFuncs;
|
|
|
|
}
|
|
|
|
stripeFuncsEnd = stripeFuncs;
|
|
|
|
|
|
|
|
(raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_p, &(stripeFuncs->fp));
|
1999-02-05 03:06:06 +03:00
|
|
|
/* check to see if we found a creation func for this stripe */
|
2004-02-29 04:24:34 +03:00
|
|
|
if (stripeFuncs->fp == NULL) {
|
1999-02-05 03:06:06 +03:00
|
|
|
/* could not find creation function for entire stripe
|
|
|
|
* so, let's see if we can find one for each stripe
|
|
|
|
* unit in the stripe */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
/* create a failed stripe structure to attempt to deal with the failure */
|
|
|
|
failed_stripe = rf_AllocFailedStripeStruct();
|
|
|
|
if (failed_stripes_list == NULL) {
|
|
|
|
failed_stripes_list = failed_stripe;
|
|
|
|
failed_stripes_list_end = failed_stripe;
|
|
|
|
} else {
|
|
|
|
failed_stripes_list_end->next = failed_stripe;
|
|
|
|
failed_stripes_list_end = failed_stripe;
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2004-03-19 05:27:44 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/* create an array of creation funcs (called
|
|
|
|
* stripeFuncs) for this stripe */
|
|
|
|
numStripeUnits = asm_p->numStripeUnitsAccessed;
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
/* lookup array of stripeUnitFuncs for this stripe */
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripes_asmh_u_end = NULL;
|
|
|
|
failed_stripes_vfple_end = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
|
|
|
|
/* remap for series of single stripe-unit
|
|
|
|
* accesses */
|
|
|
|
address = physPtr->raidAddress;
|
|
|
|
length = physPtr->numSector;
|
|
|
|
buffer = physPtr->bufPtr;
|
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle = rf_AllocASMHeaderListElem();
|
|
|
|
if (failed_stripe->asmh_u == NULL) {
|
|
|
|
failed_stripe->asmh_u = asmhle; /* we're the head... */
|
|
|
|
failed_stripes_asmh_u_end = asmhle; /* and the tail */
|
|
|
|
} else {
|
|
|
|
/* tack us onto the end of the list */
|
|
|
|
failed_stripes_asmh_u_end->next = asmhle;
|
|
|
|
failed_stripes_asmh_u_end = asmhle;
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle->asmh = rf_MapAccess(raidPtr, address, length, buffer, RF_DONT_REMAP);
|
|
|
|
asm_up = asmhle->asmh->stripeMap;
|
|
|
|
|
|
|
|
vfple = rf_AllocVFPListElem();
|
|
|
|
if (failed_stripe->vfple == NULL) {
|
|
|
|
failed_stripe->vfple = vfple;
|
|
|
|
failed_stripes_vfple_end = vfple;
|
|
|
|
} else {
|
|
|
|
failed_stripes_vfple_end->next = vfple;
|
|
|
|
failed_stripes_vfple_end = vfple;
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/* get the creation func for this stripe unit */
|
2004-03-19 05:27:44 +03:00
|
|
|
(raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_up, &(vfple->fn));
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/* check to see if we found a creation func
|
|
|
|
* for this stripe unit */
|
2004-03-19 05:27:44 +03:00
|
|
|
|
|
|
|
if (vfple->fn == (RF_VoidFuncPtr) NULL) {
|
1999-02-05 03:06:06 +03:00
|
|
|
/* could not find creation function
|
|
|
|
* for stripe unit so, let's see if we
|
|
|
|
* can find one for each block in the
|
|
|
|
* stripe unit */
|
2004-03-19 05:27:44 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
numBlocks = physPtr->numSector;
|
|
|
|
numBlockDags += numBlocks;
|
|
|
|
|
|
|
|
/* lookup array of blockFuncs for this
|
|
|
|
* stripe unit */
|
|
|
|
for (k = 0; k < numBlocks; k++) {
|
|
|
|
/* remap for series of single
|
|
|
|
* stripe-unit accesses */
|
|
|
|
address = physPtr->raidAddress + k;
|
|
|
|
length = 1;
|
|
|
|
buffer = physPtr->bufPtr + (k * (1 << raidPtr->logBytesPerSector));
|
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle = rf_AllocASMHeaderListElem();
|
|
|
|
if (failed_stripe->asmh_b == NULL) {
|
|
|
|
failed_stripe->asmh_b = asmhle;
|
|
|
|
failed_stripes_asmh_b_end = asmhle;
|
|
|
|
} else {
|
|
|
|
failed_stripes_asmh_b_end->next = asmhle;
|
|
|
|
failed_stripes_asmh_b_end = asmhle;
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle->asmh = rf_MapAccess(raidPtr, address, length, buffer, RF_DONT_REMAP);
|
|
|
|
asm_bp = asmhle->asmh->stripeMap;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
vfple = rf_AllocVFPListElem();
|
|
|
|
if (failed_stripe->bvfple == NULL) {
|
|
|
|
failed_stripe->bvfple = vfple;
|
|
|
|
failed_stripes_bvfple_end = vfple;
|
|
|
|
} else {
|
|
|
|
failed_stripes_bvfple_end->next = vfple;
|
|
|
|
failed_stripes_bvfple_end = vfple;
|
|
|
|
}
|
|
|
|
(raidPtr->Layout.map->SelectionFunc) (raidPtr, type, asm_bp, &(vfple->fn));
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
/* check to see if we found a
|
|
|
|
* creation func for this
|
|
|
|
* stripe unit */
|
2004-03-19 05:27:44 +03:00
|
|
|
|
|
|
|
if (vfple->fn == NULL)
|
1999-02-05 03:06:06 +03:00
|
|
|
cantCreateDAGs = RF_TRUE;
|
|
|
|
}
|
|
|
|
numStripeUnitsBailed++;
|
|
|
|
} else {
|
|
|
|
numUnitDags++;
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(j == numStripeUnits);
|
|
|
|
numStripesBailed++;
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
|
|
|
|
if (cantCreateDAGs) {
|
|
|
|
/* free memory and punt */
|
|
|
|
if (numStripesBailed > 0) {
|
|
|
|
stripeNum = 0;
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = stripeFuncsList;
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripe = failed_stripes_list;
|
2004-02-29 04:24:34 +03:00
|
|
|
for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
|
|
|
|
if (stripeFuncs->fp == NULL) {
|
2004-03-19 05:27:44 +03:00
|
|
|
|
|
|
|
asmhle = failed_stripe->asmh_u;
|
|
|
|
while (asmhle) {
|
|
|
|
tmpasmhle= asmhle;
|
|
|
|
asmhle = tmpasmhle->next;
|
|
|
|
rf_FreeAccessStripeMap(tmpasmhle->asmh);
|
|
|
|
rf_FreeASMHeaderListElem(tmpasmhle);
|
|
|
|
}
|
|
|
|
|
|
|
|
asmhle = failed_stripe->asmh_b;
|
|
|
|
while (asmhle) {
|
|
|
|
tmpasmhle= asmhle;
|
|
|
|
asmhle = tmpasmhle->next;
|
|
|
|
rf_FreeAccessStripeMap(tmpasmhle->asmh);
|
|
|
|
rf_FreeASMHeaderListElem(tmpasmhle);
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
vfple = failed_stripe->vfple;
|
|
|
|
while (vfple) {
|
|
|
|
tmpvfple = vfple;
|
|
|
|
vfple = tmpvfple->next;
|
|
|
|
rf_FreeVFPListElem(tmpvfple);
|
|
|
|
}
|
|
|
|
|
|
|
|
vfple = failed_stripe->bvfple;
|
|
|
|
while (vfple) {
|
|
|
|
tmpvfple = vfple;
|
|
|
|
vfple = tmpvfple->next;
|
|
|
|
rf_FreeVFPListElem(tmpvfple);
|
|
|
|
}
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
stripeNum++;
|
2004-03-19 05:27:44 +03:00
|
|
|
/* only move to the next failed stripe slot if the current one was used */
|
|
|
|
tmpfailed_stripe = failed_stripe;
|
|
|
|
failed_stripe = failed_stripe->next;
|
|
|
|
rf_FreeFailedStripeStruct(tmpfailed_stripe);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = stripeFuncs->next;
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(stripeNum == numStripesBailed);
|
|
|
|
}
|
2004-02-29 04:24:34 +03:00
|
|
|
while (stripeFuncsList != NULL) {
|
|
|
|
temp = stripeFuncsList;
|
|
|
|
stripeFuncsList = stripeFuncsList->next;
|
|
|
|
rf_FreeFuncList(temp);
|
|
|
|
}
|
2004-01-03 00:41:08 +03:00
|
|
|
desc->numStripes = 0;
|
1999-02-05 03:06:06 +03:00
|
|
|
return (1);
|
|
|
|
} else {
|
|
|
|
/* begin dag creation */
|
|
|
|
stripeNum = 0;
|
|
|
|
stripeUnitNum = 0;
|
|
|
|
|
2004-02-27 05:55:17 +03:00
|
|
|
/* create a list of dagLists and fill them in */
|
|
|
|
|
|
|
|
dagListend = NULL;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = stripeFuncsList;
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripe = failed_stripes_list;
|
1999-02-05 03:06:06 +03:00
|
|
|
for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
|
|
|
|
/* grab dag header for this stripe */
|
|
|
|
dag_h = NULL;
|
2004-02-27 05:55:17 +03:00
|
|
|
|
|
|
|
dagList = rf_AllocDAGList();
|
|
|
|
|
|
|
|
/* always tack the new dagList onto the end of the list... */
|
|
|
|
if (dagListend == NULL) {
|
|
|
|
desc->dagList = dagList;
|
|
|
|
} else {
|
|
|
|
dagListend->next = dagList;
|
|
|
|
}
|
|
|
|
dagListend = dagList;
|
|
|
|
|
|
|
|
dagList->desc = desc;
|
1999-02-05 03:06:06 +03:00
|
|
|
|
2004-02-29 04:24:34 +03:00
|
|
|
if (stripeFuncs->fp == NULL) {
|
1999-02-05 03:06:06 +03:00
|
|
|
/* use bailout functions for this stripe */
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle = failed_stripe->asmh_u;
|
|
|
|
vfple = failed_stripe->vfple;
|
|
|
|
/* the following two may contain asm headers and
|
|
|
|
block function pointers for multiple asm within
|
|
|
|
this access. We initialize tmpasmhle and tmpvfple
|
|
|
|
here in order to allow for that, and for correct
|
|
|
|
operation below */
|
|
|
|
tmpasmhle = failed_stripe->asmh_b;
|
|
|
|
tmpvfple = failed_stripe->bvfple;
|
1999-02-05 03:06:06 +03:00
|
|
|
for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
|
2004-03-19 05:27:44 +03:00
|
|
|
uFunc = vfple->fn; /* stripeUnitFuncs[stripeNum][j]; */
|
1999-02-05 03:06:06 +03:00
|
|
|
if (uFunc == (RF_VoidFuncPtr) NULL) {
|
|
|
|
/* use bailout functions for
|
|
|
|
* this stripe unit */
|
|
|
|
for (k = 0; k < physPtr->numSector; k++) {
|
|
|
|
/* create a dag for
|
|
|
|
* this block */
|
2004-04-10 03:10:16 +04:00
|
|
|
InitHdrNode(&tempdag_h, raidPtr, desc);
|
2004-02-27 05:55:17 +03:00
|
|
|
dagList->numDags++;
|
1999-02-05 03:06:06 +03:00
|
|
|
if (dag_h == NULL) {
|
|
|
|
dag_h = tempdag_h;
|
|
|
|
} else {
|
|
|
|
lastdag_h->next = tempdag_h;
|
|
|
|
}
|
|
|
|
lastdag_h = tempdag_h;
|
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
bFunc = tmpvfple->fn; /* blockFuncs[stripeUnitNum][k]; */
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(bFunc);
|
2004-03-19 05:27:44 +03:00
|
|
|
asm_bp = tmpasmhle->asmh->stripeMap; /* asmh_b[stripeUnitNum][k]->stripeMap; */
|
1999-02-05 03:06:06 +03:00
|
|
|
(*bFunc) (raidPtr, asm_bp, tempdag_h, bp, flags, tempdag_h->allocList);
|
2004-03-19 05:27:44 +03:00
|
|
|
|
|
|
|
tmpasmhle = tmpasmhle->next;
|
|
|
|
tmpvfple = tmpvfple->next;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
stripeUnitNum++;
|
|
|
|
} else {
|
|
|
|
/* create a dag for this unit */
|
2004-04-10 03:10:16 +04:00
|
|
|
InitHdrNode(&tempdag_h, raidPtr, desc);
|
2004-02-27 05:55:17 +03:00
|
|
|
dagList->numDags++;
|
1999-02-05 03:06:06 +03:00
|
|
|
if (dag_h == NULL) {
|
|
|
|
dag_h = tempdag_h;
|
|
|
|
} else {
|
|
|
|
lastdag_h->next = tempdag_h;
|
|
|
|
}
|
|
|
|
lastdag_h = tempdag_h;
|
|
|
|
|
2004-03-19 05:27:44 +03:00
|
|
|
asm_up = asmhle->asmh->stripeMap; /* asmh_u[stripeNum][j]->stripeMap; */
|
1999-02-05 03:06:06 +03:00
|
|
|
(*uFunc) (raidPtr, asm_up, tempdag_h, bp, flags, tempdag_h->allocList);
|
|
|
|
}
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle = asmhle->next;
|
|
|
|
vfple = vfple->next;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
RF_ASSERT(j == asm_p->numStripeUnitsAccessed);
|
|
|
|
/* merge linked bailout dag to existing dag
|
|
|
|
* collection */
|
|
|
|
stripeNum++;
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripe = failed_stripe->next;
|
1999-02-05 03:06:06 +03:00
|
|
|
} else {
|
|
|
|
/* Create a dag for this parity stripe */
|
2004-04-10 03:10:16 +04:00
|
|
|
InitHdrNode(&tempdag_h, raidPtr, desc);
|
2004-02-27 05:55:17 +03:00
|
|
|
dagList->numDags++;
|
2006-03-18 20:34:31 +03:00
|
|
|
dag_h = tempdag_h;
|
1999-02-05 03:06:06 +03:00
|
|
|
lastdag_h = tempdag_h;
|
|
|
|
|
2004-02-29 04:24:34 +03:00
|
|
|
(stripeFuncs->fp) (raidPtr, asm_p, tempdag_h, bp, flags, tempdag_h->allocList);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2004-02-27 05:55:17 +03:00
|
|
|
dagList->dags = dag_h;
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = stripeFuncs->next;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
RF_ASSERT(i == desc->numStripes);
|
|
|
|
|
|
|
|
/* free memory */
|
|
|
|
if ((numStripesBailed > 0) || (numStripeUnitsBailed > 0)) {
|
|
|
|
stripeNum = 0;
|
|
|
|
stripeUnitNum = 0;
|
|
|
|
/* walk through io, stripe by stripe */
|
2004-03-19 05:27:44 +03:00
|
|
|
/* here we build up dag_h->asmList for this dag...
|
|
|
|
we need all of these asm's to do the IO, and
|
|
|
|
want them in a convenient place for freeing at a
|
|
|
|
later time */
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = stripeFuncsList;
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripe = failed_stripes_list;
|
2006-03-23 06:43:54 +03:00
|
|
|
dagList = desc->dagList;
|
|
|
|
|
2004-02-29 04:24:34 +03:00
|
|
|
for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
|
2006-03-23 06:43:54 +03:00
|
|
|
|
|
|
|
dag_h = dagList->dags;
|
|
|
|
if (dag_h->asmList) {
|
|
|
|
endASMList = dag_h->asmList;
|
|
|
|
while (endASMList->next)
|
|
|
|
endASMList = endASMList->next;
|
|
|
|
} else
|
|
|
|
endASMList = NULL;
|
|
|
|
|
|
|
|
if (stripeFuncs->fp == NULL) {
|
1999-02-05 03:06:06 +03:00
|
|
|
numStripeUnits = asm_p->numStripeUnitsAccessed;
|
|
|
|
/* walk through stripe, stripe unit by
|
|
|
|
* stripe unit */
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle = failed_stripe->asmh_u;
|
|
|
|
vfple = failed_stripe->vfple;
|
|
|
|
/* this contains all of the asm headers for block funcs,
|
|
|
|
so we have to initialize this here instead of below.*/
|
|
|
|
tmpasmhle = failed_stripe->asmh_b;
|
1999-02-05 03:06:06 +03:00
|
|
|
for (j = 0, physPtr = asm_p->physInfo; physPtr; physPtr = physPtr->next, j++) {
|
2004-03-19 05:27:44 +03:00
|
|
|
if (vfple->fn == NULL) {
|
1999-02-05 03:06:06 +03:00
|
|
|
numBlocks = physPtr->numSector;
|
|
|
|
/* walk through stripe
|
|
|
|
* unit, block by
|
|
|
|
* block */
|
2004-03-19 05:27:44 +03:00
|
|
|
for (k = 0; k < numBlocks; k++) {
|
1999-02-05 03:06:06 +03:00
|
|
|
if (dag_h->asmList == NULL) {
|
2004-03-19 05:27:44 +03:00
|
|
|
dag_h->asmList = tmpasmhle->asmh; /* asmh_b[stripeUnitNum][k];*/
|
1999-02-05 03:06:06 +03:00
|
|
|
endASMList = dag_h->asmList;
|
|
|
|
} else {
|
2004-03-19 05:27:44 +03:00
|
|
|
endASMList->next = tmpasmhle->asmh;
|
1999-02-05 03:06:06 +03:00
|
|
|
endASMList = endASMList->next;
|
|
|
|
}
|
2004-03-19 05:27:44 +03:00
|
|
|
tmpasmhle = tmpasmhle->next;
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
stripeUnitNum++;
|
|
|
|
}
|
|
|
|
if (dag_h->asmList == NULL) {
|
2004-03-19 05:27:44 +03:00
|
|
|
dag_h->asmList = asmhle->asmh;
|
1999-02-05 03:06:06 +03:00
|
|
|
endASMList = dag_h->asmList;
|
|
|
|
} else {
|
2004-03-19 05:27:44 +03:00
|
|
|
endASMList->next = asmhle->asmh;
|
1999-02-05 03:06:06 +03:00
|
|
|
endASMList = endASMList->next;
|
|
|
|
}
|
2004-03-19 05:27:44 +03:00
|
|
|
asmhle = asmhle->next;
|
|
|
|
vfple = vfple->next;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
stripeNum++;
|
2004-03-19 05:27:44 +03:00
|
|
|
failed_stripe = failed_stripe->next;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2006-03-23 06:43:54 +03:00
|
|
|
dagList = dagList->next; /* need to move in stride with stripeFuncs */
|
2004-02-29 04:24:34 +03:00
|
|
|
stripeFuncs = stripeFuncs->next;
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(stripeNum == numStripesBailed);
|
2004-03-21 00:25:55 +03:00
|
|
|
RF_ASSERT(stripeUnitNum == numStripeUnitsBailed);
|
2004-03-19 05:27:44 +03:00
|
|
|
|
2004-03-21 00:25:55 +03:00
|
|
|
failed_stripe = failed_stripes_list;
|
|
|
|
while (failed_stripe) {
|
2004-03-19 05:27:44 +03:00
|
|
|
|
2004-03-21 00:25:55 +03:00
|
|
|
asmhle = failed_stripe->asmh_u;
|
|
|
|
while (asmhle) {
|
|
|
|
tmpasmhle= asmhle;
|
|
|
|
asmhle = tmpasmhle->next;
|
|
|
|
rf_FreeASMHeaderListElem(tmpasmhle);
|
|
|
|
}
|
2004-03-19 05:27:44 +03:00
|
|
|
|
2004-03-21 00:25:55 +03:00
|
|
|
asmhle = failed_stripe->asmh_b;
|
|
|
|
while (asmhle) {
|
|
|
|
tmpasmhle= asmhle;
|
|
|
|
asmhle = tmpasmhle->next;
|
|
|
|
rf_FreeASMHeaderListElem(tmpasmhle);
|
2004-03-19 05:27:44 +03:00
|
|
|
}
|
2004-03-21 00:25:55 +03:00
|
|
|
vfple = failed_stripe->vfple;
|
|
|
|
while (vfple) {
|
|
|
|
tmpvfple = vfple;
|
|
|
|
vfple = tmpvfple->next;
|
|
|
|
rf_FreeVFPListElem(tmpvfple);
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-03-21 00:25:55 +03:00
|
|
|
vfple = failed_stripe->bvfple;
|
|
|
|
while (vfple) {
|
|
|
|
tmpvfple = vfple;
|
|
|
|
vfple = tmpvfple->next;
|
|
|
|
rf_FreeVFPListElem(tmpvfple);
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-03-21 00:25:55 +03:00
|
|
|
tmpfailed_stripe = failed_stripe;
|
|
|
|
failed_stripe = tmpfailed_stripe->next;
|
|
|
|
rf_FreeFailedStripeStruct(tmpfailed_stripe);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
}
|
2004-02-29 04:24:34 +03:00
|
|
|
while (stripeFuncsList != NULL) {
|
|
|
|
temp = stripeFuncsList;
|
|
|
|
stripeFuncsList = stripeFuncsList->next;
|
|
|
|
rf_FreeFuncList(temp);
|
|
|
|
}
|
1999-02-05 03:06:06 +03:00
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
}
|