diff options
| author | oster <oster@NetBSD.org> | 2004-03-18 16:40:05 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 2004-03-18 16:40:05 +0000 |
| commit | d4fe1a2103021285632dee77ed05bde234da39a6 (patch) | |
| tree | 01ef50b395ca9216a4b5747b27511c4e778f85ac /sys/dev/raidframe | |
| parent | f72e36ac23bfa2ab130b01178b4d19955d9ee688 (diff) | |
- Introduce a 'dagnode' pool. Initialize it and allow for cleanup.
Provide rf_AllocDAGNode() and rf_FreeDAGNode() to handle
allocation/freeing.
- Introduce a "nodes" linked list of RF_DagNode_t's into the DAG header.
Initialize nodes in InitHdrNode(). Arrange for nodes cleanup in rf_FreeDAG().
- Add a "list_next" to RF_DagNode_t to keep track of nodes on the
above "nodes" list. (This is distinct from the "next" field of
RF_DagNode_t, which keeps track of the firing order of nodes.)
"list_next" gets used in the cleanup routines, and in traversing
through a set of nodes that belong to a particular set of nodes
(e.g. those belonging to xorNodes for a given DAG).
- use rf_AllocDAGNode() instead of mallocs of variable-sized arrays of
RF_DagNode_t's. Mostly mechanical changes to convert the DAG construction
from "access nodes via an array index" to "access nodes via a 'nextnode'
pointer".
- rework a couple of tricky spots where assumptions about the node order
was being abused.
- performance remains consistent with performance before these changes.
[Thanks to Simon Burge (simonb at you.know.where) for looking over
the mechanical changes to make sure I didn't biff anything.]
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_aselect.c | 5 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dag.h | 7 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dagdegrd.c | 172 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dagdegwr.c | 154 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dagffrd.c | 148 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dagffwr.c | 701 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dagutils.c | 35 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_dagutils.h | 5 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_netbsd.h | 3 |
9 files changed, 783 insertions, 447 deletions
diff --git a/sys/dev/raidframe/rf_aselect.c b/sys/dev/raidframe/rf_aselect.c index deece71d060..9661307f8fd 100644 --- a/sys/dev/raidframe/rf_aselect.c +++ b/sys/dev/raidframe/rf_aselect.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_aselect.c,v 1.16 2004/02/29 01:50:23 oster Exp $ */ +/* $NetBSD: rf_aselect.c,v 1.17 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.16 2004/02/29 01:50:23 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.17 2004/03/18 16:40:05 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -62,6 +62,7 @@ InitHdrNode(RF_DagHeader_t **hdr, RF_Raid_t *raidPtr) rf_MakeAllocList((*hdr)->allocList); (*hdr)->status = rf_enable; (*hdr)->numSuccedents = 0; + (*hdr)->nodes = NULL; (*hdr)->raidPtr = raidPtr; (*hdr)->next = NULL; } diff --git a/sys/dev/raidframe/rf_dag.h b/sys/dev/raidframe/rf_dag.h index ba6d7b3315a..0cfa3960914 100644 --- a/sys/dev/raidframe/rf_dag.h +++ b/sys/dev/raidframe/rf_dag.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dag.h,v 1.11 2004/03/04 00:56:13 oster Exp $ */ +/* $NetBSD: rf_dag.h,v 1.12 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -117,7 +117,8 @@ struct RF_DagNode_s { RF_DagHeader_t *dagHdr; /* ptr to head of dag containing this node */ void *dagFuncData; /* dag execution func uses this for whatever * it wants */ - RF_DagNode_t *next; + RF_DagNode_t *next; /* next in terms of propagating results */ + RF_DagNode_t *list_next; /* next in the list of DAG nodes for this DAG */ int nodeNum; /* used by PrintDAG for debug only */ int visited; /* used to avoid re-visiting nodes on DAG * walks */ @@ -168,7 +169,7 @@ struct RF_DagHeader_s { * completes */ void *cbArg; /* argument for cbFunc */ char *creator; /* name of function used to create this dag */ - + RF_DagNode_t *nodes; /* linked list of nodes used in this DAG */ RF_Raid_t *raidPtr; /* the descriptor for the RAID device this DAG * is for */ void *bp; /* the bp for this I/O passed down from the diff --git a/sys/dev/raidframe/rf_dagdegrd.c b/sys/dev/raidframe/rf_dagdegrd.c index bcf9dfaba25..460de7eda52 100644 --- a/sys/dev/raidframe/rf_dagdegrd.c +++ b/sys/dev/raidframe/rf_dagdegrd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagdegrd.c,v 1.19 2004/03/05 03:22:05 oster Exp $ */ +/* $NetBSD: rf_dagdegrd.c,v 1.20 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.19 2004/03/05 03:22:05 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.20 2004/03/18 16:40:05 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -117,11 +117,11 @@ rf_CreateRaidOneDegradedReadDAG(RF_Raid_t *raidPtr, RF_RaidAccessFlags_t flags, RF_AllocListElem_t *allocList) { - RF_DagNode_t *nodes, *rdNode, *blockNode, *commitNode, *termNode; + RF_DagNode_t *rdNode, *blockNode, *commitNode, *termNode; RF_StripeNum_t parityStripeID; RF_ReconUnitNum_t which_ru; RF_PhysDiskAddr_t *pda; - int useMirror, i; + int useMirror; useMirror = 0; parityStripeID = rf_RaidAddressToParityStripeID(&(raidPtr->Layout), @@ -139,16 +139,22 @@ rf_CreateRaidOneDegradedReadDAG(RF_Raid_t *raidPtr, useMirror = RF_TRUE; /* total number of nodes = 1 + (block + commit + terminator) */ - RF_MallocAndAdd(nodes, 4 * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList); - i = 0; - rdNode = &nodes[i]; - i++; - blockNode = &nodes[i]; - i++; - commitNode = &nodes[i]; - i++; - termNode = &nodes[i]; - i++; + + rdNode = rf_AllocDAGNode(); + rdNode->list_next = dag_h->nodes; + dag_h->nodes = rdNode; + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; /* this dag can not commit until the commit node is reached. errors * prior to the commit point imply the dag has failed and must be @@ -258,8 +264,9 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, RF_AllocListElem_t *allocList, const RF_RedFuncs_t *recFunc) { - RF_DagNode_t *nodes, *rudNodes, *rrdNodes, *xorNode, *blockNode; + RF_DagNode_t *rudNodes, *rrdNodes, *xorNode, *blockNode; RF_DagNode_t *commitNode, *rpNode, *termNode; + RF_DagNode_t *tmpNode, *tmprudNode, *tmprrdNode; int nNodes, nRrdNodes, nRudNodes, nXorBufs, i; int j, paramNum; RF_SectorCount_t sectorsPerSU; @@ -308,24 +315,40 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, ((new_asm_h[1]) ? new_asm_h[1]->stripeMap->numStripeUnitsAccessed : 0); nNodes = 5 + nRudNodes + nRrdNodes; /* lock, unlock, xor, Rp, Rud, * Rrd */ - RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), (RF_DagNode_t *), - allocList); - i = 0; - blockNode = &nodes[i]; - i++; - commitNode = &nodes[i]; - i++; - xorNode = &nodes[i]; - i++; - rpNode = &nodes[i]; - i++; - termNode = &nodes[i]; - i++; - rudNodes = &nodes[i]; - i += nRudNodes; - rrdNodes = &nodes[i]; - i += nRrdNodes; - RF_ASSERT(i == nNodes); + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + xorNode = rf_AllocDAGNode(); + xorNode->list_next = dag_h->nodes; + dag_h->nodes = xorNode; + + rpNode = rf_AllocDAGNode(); + rpNode->list_next = dag_h->nodes; + dag_h->nodes = rpNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; + + for (i = 0; i < nRudNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + rudNodes = dag_h->nodes; + + for (i = 0; i < nRrdNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + rrdNodes = dag_h->nodes; /* initialize nodes */ dag_h->numCommitNodes = 1; @@ -345,49 +368,56 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, recFunc->SimpleName, allocList); /* fill in the Rud nodes */ + tmprudNode = rudNodes; for (pda = asmap->physInfo, i = 0; i < nRudNodes; i++, pda = pda->next) { if (pda == failedPDA) { i--; continue; } - rf_InitNode(&rudNodes[i], rf_wait, RF_FALSE, rf_DiskReadFunc, + rf_InitNode(tmprudNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Rud", allocList); RF_ASSERT(pda); - rudNodes[i].params[0].p = pda; - rudNodes[i].params[1].p = pda->bufPtr; - rudNodes[i].params[2].v = parityStripeID; - rudNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprudNode->params[0].p = pda; + tmprudNode->params[1].p = pda->bufPtr; + tmprudNode->params[2].v = parityStripeID; + tmprudNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprudNode = tmprudNode->list_next; } /* fill in the Rrd nodes */ i = 0; + tmprrdNode = rrdNodes; if (new_asm_h[0]) { for (pda = new_asm_h[0]->stripeMap->physInfo; i < new_asm_h[0]->stripeMap->numStripeUnitsAccessed; i++, pda = pda->next) { - rf_InitNode(&rrdNodes[i], rf_wait, RF_FALSE, rf_DiskReadFunc, + rf_InitNode(tmprrdNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Rrd", allocList); RF_ASSERT(pda); - rrdNodes[i].params[0].p = pda; - rrdNodes[i].params[1].p = pda->bufPtr; - rrdNodes[i].params[2].v = parityStripeID; - rrdNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode->params[0].p = pda; + tmprrdNode->params[1].p = pda->bufPtr; + tmprrdNode->params[2].v = parityStripeID; + tmprrdNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode = tmprrdNode->list_next; } } if (new_asm_h[1]) { + /* tmprrdNode = rrdNodes; */ /* don't set this here -- old code was using i+j, which means + we need to just continue using tmprrdNode for the next 'j' elements. */ for (j = 0, pda = new_asm_h[1]->stripeMap->physInfo; j < new_asm_h[1]->stripeMap->numStripeUnitsAccessed; j++, pda = pda->next) { - rf_InitNode(&rrdNodes[i + j], rf_wait, RF_FALSE, rf_DiskReadFunc, + rf_InitNode(tmprrdNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Rrd", allocList); RF_ASSERT(pda); - rrdNodes[i + j].params[0].p = pda; - rrdNodes[i + j].params[1].p = pda->bufPtr; - rrdNodes[i + j].params[2].v = parityStripeID; - rrdNodes[i + j].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode->params[0].p = pda; + tmprrdNode->params[1].p = pda->bufPtr; + tmprrdNode->params[2].v = parityStripeID; + tmprrdNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode = tmprrdNode->list_next; } } /* make a PDA for the parity unit */ @@ -410,21 +440,25 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, * the parameters of the Xor node */ paramNum = 0; + tmprrdNode = rrdNodes; for (i = 0; i < nRrdNodes; i++) { /* all the Rrd nodes need to be xored together */ - xorNode->params[paramNum++] = rrdNodes[i].params[0]; - xorNode->params[paramNum++] = rrdNodes[i].params[1]; + xorNode->params[paramNum++] = tmprrdNode->params[0]; + xorNode->params[paramNum++] = tmprrdNode->params[1]; + tmprrdNode = tmprrdNode->list_next; } + tmprudNode = rudNodes; for (i = 0; i < nRudNodes; i++) { /* any Rud nodes that overlap the failed access need to be * xored in */ if (overlappingPDAs[i]) { RF_MallocAndAdd(pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); - memcpy((char *) pda, (char *) rudNodes[i].params[0].p, sizeof(RF_PhysDiskAddr_t)); + memcpy((char *) pda, (char *) tmprudNode->params[0].p, sizeof(RF_PhysDiskAddr_t)); rf_RangeRestrictPDA(raidPtr, failedPDA, pda, RF_RESTRICT_DOBUFFER, 0); xorNode->params[paramNum++].p = pda; xorNode->params[paramNum++].p = pda->bufPtr; } + tmprudNode = tmprudNode->list_next; } RF_Free(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char)); @@ -461,17 +495,21 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, blockNode->succedents[0] = rpNode; rpNode->antecedents[0] = blockNode; rpNode->antType[0] = rf_control; + tmprrdNode = rrdNodes; for (i = 0; i < nRrdNodes; i++) { - RF_ASSERT(rrdNodes[i].numSuccedents == 1); - blockNode->succedents[1 + i] = &rrdNodes[i]; - rrdNodes[i].antecedents[0] = blockNode; - rrdNodes[i].antType[0] = rf_control; + RF_ASSERT(tmprrdNode->numSuccedents == 1); + blockNode->succedents[1 + i] = tmprrdNode; + tmprrdNode->antecedents[0] = blockNode; + tmprrdNode->antType[0] = rf_control; + tmprrdNode = tmprrdNode->list_next; } + tmprudNode = rudNodes; for (i = 0; i < nRudNodes; i++) { - RF_ASSERT(rudNodes[i].numSuccedents == 1); - blockNode->succedents[1 + nRrdNodes + i] = &rudNodes[i]; - rudNodes[i].antecedents[0] = blockNode; - rudNodes[i].antType[0] = rf_control; + RF_ASSERT(tmprudNode->numSuccedents == 1); + blockNode->succedents[1 + nRrdNodes + i] = tmprudNode; + tmprudNode->antecedents[0] = blockNode; + tmprudNode->antType[0] = rf_control; + tmprudNode = tmprudNode->list_next; } /* connect the read nodes to the xor node */ @@ -480,17 +518,21 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, rpNode->succedents[0] = xorNode; xorNode->antecedents[0] = rpNode; xorNode->antType[0] = rf_trueData; + tmprrdNode = rrdNodes; for (i = 0; i < nRrdNodes; i++) { - RF_ASSERT(rrdNodes[i].numSuccedents == 1); - rrdNodes[i].succedents[0] = xorNode; - xorNode->antecedents[1 + i] = &rrdNodes[i]; + RF_ASSERT(rrdNode->numSuccedents == 1); + tmprrdNode->succedents[0] = xorNode; + xorNode->antecedents[1 + i] = tmprrdNode; xorNode->antType[1 + i] = rf_trueData; + tmprrdNode = tmprrdNode->list_next; } + tmprudNode = rudNodes; for (i = 0; i < nRudNodes; i++) { - RF_ASSERT(rudNodes[i].numSuccedents == 1); - rudNodes[i].succedents[0] = xorNode; - xorNode->antecedents[1 + nRrdNodes + i] = &rudNodes[i]; + RF_ASSERT(tmprudNode->numSuccedents == 1); + tmprudNode->succedents[0] = xorNode; + xorNode->antecedents[1 + nRrdNodes + i] = tmprudNode; xorNode->antType[1 + nRrdNodes + i] = rf_trueData; + tmprudNode = tmprudNode->list_next; } /* connect the xor node to the commit node */ diff --git a/sys/dev/raidframe/rf_dagdegwr.c b/sys/dev/raidframe/rf_dagdegwr.c index e5d05ec9457..a775b00ac5d 100644 --- a/sys/dev/raidframe/rf_dagdegwr.c +++ b/sys/dev/raidframe/rf_dagdegwr.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagdegwr.c,v 1.17 2004/03/06 23:34:27 oster Exp $ */ +/* $NetBSD: rf_dagdegwr.c,v 1.18 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.17 2004/03/06 23:34:27 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.18 2004/03/18 16:40:05 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -163,7 +163,8 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, int nNodes, nRrdNodes, nWndNodes, nXorBufs, i, j, paramNum, rdnodesFaked; RF_DagNode_t *blockNode, *unblockNode, *wnpNode, *wnqNode, *termNode; - RF_DagNode_t *nodes, *wndNodes, *rrdNodes, *xorNode, *commitNode; + RF_DagNode_t *wndNodes, *rrdNodes, *xorNode, *commitNode; + RF_DagNode_t *tmpNode, *tmpwndNode, *tmprrdNode; RF_SectorCount_t sectorsPerSU; RF_ReconUnitNum_t which_ru; char *xorTargetBuf = NULL; /* the target buffer for the XOR @@ -226,29 +227,50 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, } /* lock, unlock, xor, Wnd, Rrd, W(nfaults) */ nNodes = 5 + nfaults + nWndNodes + nRrdNodes; - RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); - i = 0; - blockNode = &nodes[i]; - i += 1; - commitNode = &nodes[i]; - i += 1; - unblockNode = &nodes[i]; - i += 1; - termNode = &nodes[i]; - i += 1; - xorNode = &nodes[i]; - i += 1; - wnpNode = &nodes[i]; - i += 1; - wndNodes = &nodes[i]; - i += nWndNodes; - rrdNodes = &nodes[i]; - i += nRrdNodes; + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + unblockNode = rf_AllocDAGNode(); + unblockNode->list_next = dag_h->nodes; + dag_h->nodes = unblockNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; + + xorNode = rf_AllocDAGNode(); + xorNode->list_next = dag_h->nodes; + dag_h->nodes = xorNode; + + wnpNode = rf_AllocDAGNode(); + wnpNode->list_next = dag_h->nodes; + dag_h->nodes = wnpNode; + + for (i = 0; i < nWndNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + wndNodes = dag_h->nodes; + + for (i = 0; i < nRrdNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + rrdNodes = dag_h->nodes; + #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { - wnqNode = &nodes[i]; - i += 1; + wnqNode = rf_AllocDAGNode(); + wnqNode->list_next = dag_h->nodes; + dag_h->nodes = wnqNode; } else { #endif wnqNode = NULL; @@ -282,33 +304,38 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, * same alignment within the SU. */ i = 0; + tmprrdNode = rrdNodes; if (new_asm_h[0]) { for (i = 0, pda = new_asm_h[0]->stripeMap->physInfo; i < new_asm_h[0]->stripeMap->numStripeUnitsAccessed; i++, pda = pda->next) { - rf_InitNode(&rrdNodes[i], rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, + rf_InitNode(tmprrdNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Rrd", allocList); RF_ASSERT(pda); - rrdNodes[i].params[0].p = pda; - rrdNodes[i].params[1].p = pda->bufPtr; - rrdNodes[i].params[2].v = parityStripeID; - rrdNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode->params[0].p = pda; + tmprrdNode->params[1].p = pda->bufPtr; + tmprrdNode->params[2].v = parityStripeID; + tmprrdNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode = tmprrdNode->list_next; } } /* i now equals the number of stripe units accessed in new_asm_h[0] */ + /* Note that for tmprrdNode, this means a continuation from above, so no need to + assign it anything.. */ if (new_asm_h[1]) { for (j = 0, pda = new_asm_h[1]->stripeMap->physInfo; j < new_asm_h[1]->stripeMap->numStripeUnitsAccessed; j++, pda = pda->next) { - rf_InitNode(&rrdNodes[i + j], rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, + rf_InitNode(tmprrdNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Rrd", allocList); RF_ASSERT(pda); - rrdNodes[i + j].params[0].p = pda; - rrdNodes[i + j].params[1].p = pda->bufPtr; - rrdNodes[i + j].params[2].v = parityStripeID; - rrdNodes[i + j].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmprrdNode->params[0].p = pda; + tmprrdNode->params[1].p = pda->bufPtr; + tmprrdNode->params[2].v = parityStripeID; + tmprrdNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); if (allowBufferRecycle && (pda->numSector == failedPDA->numSector)) xorTargetBuf = pda->bufPtr; + tmprrdNode = tmprrdNode->list_next; } } if (rdnodesFaked) { @@ -316,7 +343,8 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, * This is where we'll init that fake noop read node * (XXX should the wakeup func be different?) */ - rf_InitNode(&rrdNodes[0], rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, + /* node that rrdNodes will just be a single node... */ + rf_InitNode(rrdNodes, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, NULL, 1, 1, 0, 0, dag_h, "RrN", allocList); } /* @@ -371,18 +399,20 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, } #endif /* fill in the Wnd nodes */ + tmpwndNode = wndNodes; for (pda = asmap->physInfo, i = 0; i < nWndNodes; i++, pda = pda->next) { if (pda == failedPDA) { i--; continue; } - rf_InitNode(&wndNodes[i], rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, + rf_InitNode(tmpwndNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnd", allocList); RF_ASSERT(pda); - wndNodes[i].params[0].p = pda; - wndNodes[i].params[1].p = pda->bufPtr; - wndNodes[i].params[2].v = parityStripeID; - wndNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmpwndNode->params[0].p = pda; + tmpwndNode->params[1].p = pda->bufPtr; + tmpwndNode->params[2].v = parityStripeID; + tmpwndNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmpwndNode = tmpwndNode->list_next; } /* fill in the results of the xor node */ @@ -392,22 +422,26 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, paramNum = 0; if (rdnodesFaked == 0) { + tmprrdNode = rrdNodes; for (i = 0; i < nRrdNodes; i++) { /* all the Rrd nodes need to be xored together */ - xorNode->params[paramNum++] = rrdNodes[i].params[0]; - xorNode->params[paramNum++] = rrdNodes[i].params[1]; + xorNode->params[paramNum++] = tmprrdNode->params[0]; + xorNode->params[paramNum++] = tmprrdNode->params[1]; + tmprrdNode = tmprrdNode->list_next; } } + tmpwndNode = wndNodes; for (i = 0; i < nWndNodes; i++) { /* any Wnd nodes that overlap the failed access need to be * xored in */ if (overlappingPDAs[i]) { RF_MallocAndAdd(pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList); - memcpy((char *) pda, (char *) wndNodes[i].params[0].p, sizeof(RF_PhysDiskAddr_t)); + memcpy((char *) pda, (char *) tmpwndNode->params[0].p, sizeof(RF_PhysDiskAddr_t)); rf_RangeRestrictPDA(raidPtr, failedPDA, pda, RF_RESTRICT_DOBUFFER, 0); xorNode->params[paramNum++].p = pda; xorNode->params[paramNum++].p = pda->bufPtr; } + tmpwndNode = tmpwndNode->list_next; } RF_Free(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char)); @@ -438,20 +472,24 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, /* link block node to rd nodes */ RF_ASSERT(blockNode->numSuccedents == nRrdNodes); + tmprrdNode = rrdNodes; for (i = 0; i < nRrdNodes; i++) { - RF_ASSERT(rrdNodes[i].numAntecedents == 1); - blockNode->succedents[i] = &rrdNodes[i]; - rrdNodes[i].antecedents[0] = blockNode; - rrdNodes[i].antType[0] = rf_control; + RF_ASSERT(tmprrdNode->numAntecedents == 1); + blockNode->succedents[i] = tmprrdNode; + tmprrdNode->antecedents[0] = blockNode; + tmprrdNode->antType[0] = rf_control; + tmprrdNode = tmprrdNode->list_next; } /* link read nodes to xor node */ RF_ASSERT(xorNode->numAntecedents == nRrdNodes); + tmprrdNode = rrdNodes; for (i = 0; i < nRrdNodes; i++) { - RF_ASSERT(rrdNodes[i].numSuccedents == 1); - rrdNodes[i].succedents[0] = xorNode; - xorNode->antecedents[i] = &rrdNodes[i]; + RF_ASSERT(tmprrdNode->numSuccedents == 1); + tmprrdNode->succedents[0] = xorNode; + xorNode->antecedents[i] = tmprrdNode; xorNode->antType[i] = rf_trueData; + tmprrdNode = tmprrdNode->list_next; } /* link xor node to commit node */ @@ -463,11 +501,12 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, /* link commit node to wnd nodes */ RF_ASSERT(commitNode->numSuccedents == nfaults + nWndNodes); + tmpwndNode = wndNodes; for (i = 0; i < nWndNodes; i++) { - RF_ASSERT(wndNodes[i].numAntecedents == 1); - commitNode->succedents[i] = &wndNodes[i]; - wndNodes[i].antecedents[0] = commitNode; - wndNodes[i].antType[0] = rf_control; + RF_ASSERT(tmpwndNode->numAntecedents == 1); + commitNode->succedents[i] = tmpwndNode; + tmpwndNode->antecedents[0] = commitNode; + tmpwndNode->antType[0] = rf_control; } /* link the commit node to wnp, wnq nodes */ @@ -485,10 +524,11 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr, #endif /* link write new data nodes to unblock node */ RF_ASSERT(unblockNode->numAntecedents == (nWndNodes + nfaults)); + tmpwndNode = wndNodes; for (i = 0; i < nWndNodes; i++) { - RF_ASSERT(wndNodes[i].numSuccedents == 1); - wndNodes[i].succedents[0] = unblockNode; - unblockNode->antecedents[i] = &wndNodes[i]; + RF_ASSERT(tmpwndNode->numSuccedents == 1); + tmpwndNode->succedents[0] = unblockNode; + unblockNode->antecedents[i] = tmpwndNode; unblockNode->antType[i] = rf_control; } diff --git a/sys/dev/raidframe/rf_dagffrd.c b/sys/dev/raidframe/rf_dagffrd.c index 62aecd9b713..1737a6c650e 100644 --- a/sys/dev/raidframe/rf_dagffrd.c +++ b/sys/dev/raidframe/rf_dagffrd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagffrd.c,v 1.12 2004/03/05 03:22:05 oster Exp $ */ +/* $NetBSD: rf_dagffrd.c,v 1.13 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagffrd.c,v 1.12 2004/03/05 03:22:05 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagffrd.c,v 1.13 2004/03/18 16:40:05 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -130,7 +130,8 @@ rf_CreateNonredundantDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, RF_AllocListElem_t *allocList, RF_IoType_t type) { - RF_DagNode_t *nodes, *diskNodes, *blockNode, *commitNode, *termNode; + RF_DagNode_t *diskNodes, *blockNode, *commitNode, *termNode; + RF_DagNode_t *tmpNode, *tmpdiskNode; RF_PhysDiskAddr_t *pda = asmap->physInfo; int (*doFunc) (RF_DagNode_t *), (*undoFunc) (RF_DagNode_t *); int i, n, totalNumNodes; @@ -180,18 +181,25 @@ rf_CreateNonredundantDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, */ RF_ASSERT(n > 0); totalNumNodes = n + 3; - RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); - i = 0; - diskNodes = &nodes[i]; - i += n; - blockNode = &nodes[i]; - i += 1; - commitNode = &nodes[i]; - i += 1; - termNode = &nodes[i]; - i += 1; - RF_ASSERT(i == totalNumNodes); + + for (i = 0; i < n; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + diskNodes = dag_h->nodes; + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; /* initialize nodes */ switch (type) { @@ -215,16 +223,18 @@ rf_CreateNonredundantDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, RF_PANIC(); } + tmpdiskNode = diskNodes; for (i = 0; i < n; i++) { RF_ASSERT(pda != NULL); - rf_InitNode(&diskNodes[i], rf_wait, RF_FALSE, doFunc, undoFunc, rf_GenericWakeupFunc, + rf_InitNode(tmpdiskNode, rf_wait, RF_FALSE, doFunc, undoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, name, allocList); - diskNodes[i].params[0].p = pda; - diskNodes[i].params[1].p = pda->bufPtr; + tmpdiskNode->params[0].p = pda; + tmpdiskNode->params[1].p = pda->bufPtr; /* parity stripe id is not necessary */ - diskNodes[i].params[2].v = 0; - diskNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, 0); + tmpdiskNode->params[2].v = 0; + tmpdiskNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, 0); pda = pda->next; + tmpdiskNode = tmpdiskNode->list_next; } /* @@ -239,18 +249,20 @@ rf_CreateNonredundantDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* connecting a nonredundant read DAG */ RF_ASSERT(blockNode->numSuccedents == n); RF_ASSERT(commitNode->numAntecedents == n); + tmpdiskNode = diskNodes; for (i = 0; i < n; i++) { /* connect block node to each read node */ - RF_ASSERT(diskNodes[i].numAntecedents == 1); - blockNode->succedents[i] = &diskNodes[i]; - diskNodes[i].antecedents[0] = blockNode; - diskNodes[i].antType[0] = rf_control; + RF_ASSERT(tmpdiskNode->numAntecedents == 1); + blockNode->succedents[i] = tmpdiskNode; + tmpdiskNode->antecedents[0] = blockNode; + tmpdiskNode->antType[0] = rf_control; /* connect each read node to the commit node */ - RF_ASSERT(diskNodes[i].numSuccedents == 1); - diskNodes[i].succedents[0] = commitNode; - commitNode->antecedents[i] = &diskNodes[i]; + RF_ASSERT(tmpdiskNode->numSuccedents == 1); + tmpdiskNode->succedents[0] = commitNode; + commitNode->antecedents[i] = tmpdiskNode; commitNode->antType[i] = rf_control; + tmpdiskNode = tmpdiskNode->list_next; } /* connect the commit node to the term node */ RF_ASSERT(commitNode->numSuccedents == 1); @@ -271,18 +283,20 @@ rf_CreateNonredundantDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, RF_ASSERT(commitNode->numSuccedents == n); RF_ASSERT(termNode->numAntecedents == n); RF_ASSERT(termNode->numSuccedents == 0); + tmpdiskNode = diskNodes; for (i = 0; i < n; i++) { /* connect the commit node to each write node */ - RF_ASSERT(diskNodes[i].numAntecedents == 1); - commitNode->succedents[i] = &diskNodes[i]; - diskNodes[i].antecedents[0] = commitNode; - diskNodes[i].antType[0] = rf_control; + RF_ASSERT(tmpdiskNode->numAntecedents == 1); + commitNode->succedents[i] = tmpdiskNode; + tmpdiskNode->antecedents[0] = commitNode; + tmpdiskNode->antType[0] = rf_control; /* connect each write node to the term node */ - RF_ASSERT(diskNodes[i].numSuccedents == 1); - diskNodes[i].succedents[0] = termNode; - termNode->antecedents[i] = &diskNodes[i]; + RF_ASSERT(tmpdiskNode->numSuccedents == 1); + tmpdiskNode->succedents[0] = termNode; + termNode->antecedents[i] = tmpdiskNode; termNode->antType[i] = rf_control; + tmpdiskNode = tmpdiskNode->list_next; } } } @@ -310,7 +324,8 @@ CreateMirrorReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, RF_AllocListElem_t *allocList, int (*readfunc) (RF_DagNode_t * node)) { - RF_DagNode_t *readNodes, *nodes, *blockNode, *commitNode, *termNode; + RF_DagNode_t *readNodes, *blockNode, *commitNode, *termNode; + RF_DagNode_t *tmpNode, *tmpreadNode; RF_PhysDiskAddr_t *data_pda = asmap->physInfo; RF_PhysDiskAddr_t *parity_pda = asmap->parityInfo; int i, n, totalNumNodes; @@ -339,18 +354,25 @@ CreateMirrorReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, */ RF_ASSERT(n > 0); totalNumNodes = n + 3; - RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); - i = 0; - readNodes = &nodes[i]; - i += n; - blockNode = &nodes[i]; - i += 1; - commitNode = &nodes[i]; - i += 1; - termNode = &nodes[i]; - i += 1; - RF_ASSERT(i == totalNumNodes); + + for (i = 0; i < n; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + readNodes = dag_h->nodes; + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; /* initialize nodes */ rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, @@ -360,20 +382,22 @@ CreateMirrorReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, rf_TerminateUndoFunc, NULL, 0, 1, 0, 0, dag_h, "Trm", allocList); + tmpreadNode = readNodes; for (i = 0; i < n; i++) { RF_ASSERT(data_pda != NULL); RF_ASSERT(parity_pda != NULL); - rf_InitNode(&readNodes[i], rf_wait, RF_FALSE, readfunc, + rf_InitNode(tmpreadNode, rf_wait, RF_FALSE, readfunc, rf_DiskReadMirrorUndoFunc, rf_GenericWakeupFunc, 1, 1, 5, 0, dag_h, "Rmir", allocList); - readNodes[i].params[0].p = data_pda; - readNodes[i].params[1].p = data_pda->bufPtr; + tmpreadNode->params[0].p = data_pda; + tmpreadNode->params[1].p = data_pda->bufPtr; /* parity stripe id is not necessary */ - readNodes[i].params[2].p = 0; - readNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, 0); - readNodes[i].params[4].p = parity_pda; + tmpreadNode->params[2].p = 0; + tmpreadNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, 0); + tmpreadNode->params[4].p = parity_pda; data_pda = data_pda->next; parity_pda = parity_pda->next; + tmpreadNode = tmpreadNode->list_next; } /* @@ -386,20 +410,24 @@ CreateMirrorReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* connect block node to read nodes */ RF_ASSERT(blockNode->numSuccedents == n); + tmpreadNode = readNodes; for (i = 0; i < n; i++) { - RF_ASSERT(readNodes[i].numAntecedents == 1); - blockNode->succedents[i] = &readNodes[i]; - readNodes[i].antecedents[0] = blockNode; - readNodes[i].antType[0] = rf_control; + RF_ASSERT(tmpreadNode->numAntecedents == 1); + blockNode->succedents[i] = tmpreadNode; + tmpreadNode->antecedents[0] = blockNode; + tmpreadNode->antType[0] = rf_control; + tmpreadNode = tmpreadNode->list_next; } /* connect read nodes to commit node */ RF_ASSERT(commitNode->numAntecedents == n); + tmpreadNode = readNodes; for (i = 0; i < n; i++) { - RF_ASSERT(readNodes[i].numSuccedents == 1); - readNodes[i].succedents[0] = commitNode; - commitNode->antecedents[i] = &readNodes[i]; + RF_ASSERT(tmpreadNode->numSuccedents == 1); + tmpreadNode->succedents[0] = commitNode; + commitNode->antecedents[i] = tmpreadNode; commitNode->antType[i] = rf_control; + tmpreadNode = tmpreadNode->list_next; } /* connect commit node to term node */ diff --git a/sys/dev/raidframe/rf_dagffwr.c b/sys/dev/raidframe/rf_dagffwr.c index e0e9ce7c79a..ba9835086ee 100644 --- a/sys/dev/raidframe/rf_dagffwr.c +++ b/sys/dev/raidframe/rf_dagffwr.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagffwr.c,v 1.21 2004/03/06 23:52:20 oster Exp $ */ +/* $NetBSD: rf_dagffwr.c,v 1.22 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagffwr.c,v 1.21 2004/03/06 23:52:20 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagffwr.c,v 1.22 2004/03/18 16:40:05 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -165,7 +165,7 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, int nfaults, int (*redFunc) (RF_DagNode_t *), int allowBufferRecycle) { - RF_DagNode_t *nodes, *wndNodes, *rodNodes, *xorNode, *wnpNode; + RF_DagNode_t *wndNodes, *rodNodes, *xorNode, *wnpNode, *tmpNode; RF_DagNode_t *wnqNode, *blockNode, *commitNode, *termNode; int nWndNodes, nRodNodes, i, nodeNum, asmNum; RF_AccessStripeMapHeader_t *new_asm_h[2]; @@ -193,26 +193,37 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* alloc the nodes: Wnd, xor, commit, block, term, and Wnp */ nWndNodes = asmap->numStripeUnitsAccessed; - RF_MallocAndAdd(nodes, - (nWndNodes + 4 + nfaults) * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); - i = 0; - wndNodes = &nodes[i]; - i += nWndNodes; - xorNode = &nodes[i]; - i += 1; - wnpNode = &nodes[i]; - i += 1; - blockNode = &nodes[i]; - i += 1; - commitNode = &nodes[i]; - i += 1; - termNode = &nodes[i]; - i += 1; + + for (i = 0; i < nWndNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + wndNodes = dag_h->nodes; + + xorNode = rf_AllocDAGNode(); + xorNode->list_next = dag_h->nodes; + dag_h->nodes = xorNode; + + wnpNode = rf_AllocDAGNode(); + wnpNode->list_next = dag_h->nodes; + dag_h->nodes = wnpNode; + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; + #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { - wnqNode = &nodes[i]; - i += 1; + wnqNode = rf_AllocDAGNode(); } else { #endif wnqNode = NULL; @@ -223,8 +234,12 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, new_asm_h, &nRodNodes, &sosBuffer, &eosBuffer, allocList); if (nRodNodes > 0) { - RF_MallocAndAdd(rodNodes, nRodNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); + for (i = 0; i < nRodNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + rodNodes = dag_h->nodes; } else { rodNodes = NULL; } @@ -248,23 +263,25 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, dag_h, "Trm", allocList); /* initialize the Rod nodes */ + tmpNode = rodNodes; for (nodeNum = asmNum = 0; asmNum < 2; asmNum++) { if (new_asm_h[asmNum]) { pda = new_asm_h[asmNum]->stripeMap->physInfo; while (pda) { - rf_InitNode(&rodNodes[nodeNum], rf_wait, + rf_InitNode(tmpNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Rod", allocList); - rodNodes[nodeNum].params[0].p = pda; - rodNodes[nodeNum].params[1].p = pda->bufPtr; - rodNodes[nodeNum].params[2].v = parityStripeID; - rodNodes[nodeNum].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpNode->params[0].p = pda; + tmpNode->params[1].p = pda->bufPtr; + tmpNode->params[2].v = parityStripeID; + tmpNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); nodeNum++; pda = pda->next; + tmpNode = tmpNode->list_next; } } } @@ -272,17 +289,19 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* initialize the wnd nodes */ pda = asmap->physInfo; + tmpNode = wndNodes; for (i = 0; i < nWndNodes; i++) { - rf_InitNode(&wndNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnd", allocList); RF_ASSERT(pda != NULL); - wndNodes[i].params[0].p = pda; - wndNodes[i].params[1].p = pda->bufPtr; - wndNodes[i].params[2].v = parityStripeID; - wndNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmpNode->params[0].p = pda; + tmpNode->params[1].p = pda->bufPtr; + tmpNode->params[2].v = parityStripeID; + tmpNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; + tmpNode = tmpNode->list_next; } /* initialize the redundancy node */ @@ -298,17 +317,21 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, nfaults, dag_h, "Xr ", allocList); } xorNode->flags |= RF_DAGNODE_FLAG_YIELD; + tmpNode = wndNodes; for (i = 0; i < nWndNodes; i++) { /* pda */ - xorNode->params[2 * i + 0] = wndNodes[i].params[0]; + xorNode->params[2 * i + 0] = tmpNode->params[0]; /* buf ptr */ - xorNode->params[2 * i + 1] = wndNodes[i].params[1]; + xorNode->params[2 * i + 1] = tmpNode->params[1]; + tmpNode = tmpNode->list_next; } + tmpNode = rodNodes; for (i = 0; i < nRodNodes; i++) { /* pda */ - xorNode->params[2 * (nWndNodes + i) + 0] = rodNodes[i].params[0]; + xorNode->params[2 * (nWndNodes + i) + 0] = tmpNode->params[0]; /* buf ptr */ - xorNode->params[2 * (nWndNodes + i) + 1] = rodNodes[i].params[1]; + xorNode->params[2 * (nWndNodes + i) + 1] = tmpNode->params[1]; + tmpNode = tmpNode->list_next; } /* xor node needs to get at RAID information */ xorNode->params[2 * (nWndNodes + nRodNodes)].p = raidPtr; @@ -319,9 +342,11 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, * can't use a new data buffer because it will not have gotten * written when the xor occurs. */ if (allowBufferRecycle) { + tmpNode = rodNodes; for (i = 0; i < nRodNodes; i++) { - if (((RF_PhysDiskAddr_t *) rodNodes[i].params[0].p)->numSector == raidPtr->Layout.sectorsPerStripeUnit) + if (((RF_PhysDiskAddr_t *) tmpNode->params[0].p)->numSector == raidPtr->Layout.sectorsPerStripeUnit) break; + tmpNode = tmpNode->list_next; } } if ((!allowBufferRecycle) || (i == nRodNodes)) { @@ -329,7 +354,13 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), (void *), allocList); } else { - xorNode->results[0] = rodNodes[i].params[1].p; + /* this works because the only way we get here is if + allowBufferRecycle is true and we went through the + above for loop, and exited via the break before + i==nRodNodes was true. That means tmpNode will + still point to a valid node -- the one we want for + here! */ + xorNode->results[0] = tmpNode->params[1].p; } /* initialize the Wnp node */ @@ -377,17 +408,19 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* connect the block node to the Rod nodes */ RF_ASSERT(blockNode->numSuccedents == nRodNodes); RF_ASSERT(xorNode->numAntecedents == nRodNodes); + tmpNode = rodNodes; for (i = 0; i < nRodNodes; i++) { - RF_ASSERT(rodNodes[i].numAntecedents == 1); - blockNode->succedents[i] = &rodNodes[i]; - rodNodes[i].antecedents[0] = blockNode; - rodNodes[i].antType[0] = rf_control; + RF_ASSERT(tmpNode.numAntecedents == 1); + blockNode->succedents[i] = tmpNode; + tmpNode->antecedents[0] = blockNode; + tmpNode->antType[0] = rf_control; /* connect the Rod nodes to the Xor node */ - RF_ASSERT(rodNodes[i].numSuccedents == 1); - rodNodes[i].succedents[0] = xorNode; - xorNode->antecedents[i] = &rodNodes[i]; + RF_ASSERT(tmpNode.numSuccedents == 1); + tmpNode->succedents[0] = xorNode; + xorNode->antecedents[i] = tmpNode; xorNode->antType[i] = rf_trueData; + tmpNode = tmpNode->list_next; } } else { /* connect the block node to the Xor node */ @@ -407,11 +440,13 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* connect the commit node to the write nodes */ RF_ASSERT(commitNode->numSuccedents == nWndNodes + nfaults); + tmpNode = wndNodes; for (i = 0; i < nWndNodes; i++) { RF_ASSERT(wndNodes->numAntecedents == 1); - commitNode->succedents[i] = &wndNodes[i]; - wndNodes[i].antecedents[0] = commitNode; - wndNodes[i].antType[0] = rf_control; + commitNode->succedents[i] = tmpNode; + tmpNode->antecedents[0] = commitNode; + tmpNode->antType[0] = rf_control; + tmpNode = tmpNode->list_next; } RF_ASSERT(wnpNode->numAntecedents == 1); commitNode->succedents[nWndNodes] = wnpNode; @@ -428,11 +463,13 @@ rf_CommonCreateLargeWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* connect the write nodes to the term node */ RF_ASSERT(termNode->numAntecedents == nWndNodes + nfaults); RF_ASSERT(termNode->numSuccedents == 0); + tmpNode = wndNodes; for (i = 0; i < nWndNodes; i++) { RF_ASSERT(wndNodes->numSuccedents == 1); - wndNodes[i].succedents[0] = termNode; - termNode->antecedents[i] = &wndNodes[i]; + tmpNode->succedents[0] = termNode; + termNode->antecedents[i] = tmpNode; termNode->antType[i] = rf_control; + tmpNode = tmpNode->list_next; } RF_ASSERT(wnpNode->numSuccedents == 1); wnpNode->succedents[0] = termNode; @@ -489,8 +526,14 @@ rf_CommonCreateSmallWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, const RF_RedFuncs_t *qfuncs) { RF_DagNode_t *readDataNodes, *readParityNodes, *readQNodes, *termNode; - RF_DagNode_t *xorNodes, *qNodes, *blockNode, *commitNode, *nodes; + RF_DagNode_t *tmpNode, *tmpreadDataNode, *tmpreadParityNode; + RF_DagNode_t *xorNodes, *qNodes, *blockNode, *commitNode; RF_DagNode_t *writeDataNodes, *writeParityNodes, *writeQNodes; + RF_DagNode_t *tmpxorNode, *tmpqNode, *tmpwriteDataNode, *tmpreadQNode; + RF_DagNode_t *tmpwriteParityNode; +#if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) + RF_DagNode_t *tmpwriteQNode; +#endif int i, j, nNodes, totalNumNodes; RF_ReconUnitNum_t which_ru; int (*func) (RF_DagNode_t *), (*undoFunc) (RF_DagNode_t *); @@ -543,34 +586,76 @@ rf_CommonCreateSmallWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* * Step 2. create the nodes */ - RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); - i = 0; - blockNode = &nodes[i]; - i += 1; - commitNode = &nodes[i]; - i += 1; - readDataNodes = &nodes[i]; - i += numDataNodes; - readParityNodes = &nodes[i]; - i += numParityNodes; - writeDataNodes = &nodes[i]; - i += numDataNodes; - writeParityNodes = &nodes[i]; - i += numParityNodes; - xorNodes = &nodes[i]; - i += numParityNodes; - termNode = &nodes[i]; - i += 1; + + blockNode = rf_AllocDAGNode(); + blockNode->list_next = dag_h->nodes; + dag_h->nodes = blockNode; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + for (i = 0; i < numDataNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + readDataNodes = dag_h->nodes; + + for (i = 0; i < numParityNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + readParityNodes = dag_h->nodes; + + for (i = 0; i < numDataNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + writeDataNodes = dag_h->nodes; + + for (i = 0; i < numParityNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + writeParityNodes = dag_h->nodes; + + for (i = 0; i < numParityNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + xorNodes = dag_h->nodes; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { - readQNodes = &nodes[i]; - i += numParityNodes; - writeQNodes = &nodes[i]; - i += numParityNodes; - qNodes = &nodes[i]; - i += numParityNodes; + for (i = 0; i < numParityNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + readQNodes = dag_h->nodes; + + for (i = 0; i < numParityNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + writeQNodes = dag_h->nodes; + + for (i = 0; i < numParityNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + qNodes = dag_h->nodes; } else { #endif readQNodes = writeQNodes = qNodes = NULL; @@ -599,85 +684,93 @@ rf_CommonCreateSmallWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, dag_h, "Trm", allocList); /* initialize nodes which read old data (Rod) */ + tmpreadDataNode = readDataNodes; for (i = 0; i < numDataNodes; i++) { - rf_InitNode(&readDataNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpreadDataNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, (nfaults * numParityNodes), 1, 4, 0, dag_h, "Rod", allocList); RF_ASSERT(pda != NULL); /* physical disk addr desc */ - readDataNodes[i].params[0].p = pda; + tmpreadDataNode->params[0].p = pda; /* buffer to hold old data */ - readDataNodes[i].params[1].p = rf_AllocBuffer(raidPtr, pda, allocList); - readDataNodes[i].params[2].v = parityStripeID; - readDataNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpreadDataNode->params[1].p = rf_AllocBuffer(raidPtr, pda, allocList); + tmpreadDataNode->params[2].v = parityStripeID; + tmpreadDataNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; - for (j = 0; j < readDataNodes[i].numSuccedents; j++) { - readDataNodes[i].propList[j] = NULL; + for (j = 0; j < tmpreadDataNode->numSuccedents; j++) { + tmpreadDataNode->propList[j] = NULL; } + tmpreadDataNode = tmpreadDataNode->list_next; } /* initialize nodes which read old parity (Rop) */ pda = asmap->parityInfo; i = 0; + tmpreadParityNode = readParityNodes; for (i = 0; i < numParityNodes; i++) { RF_ASSERT(pda != NULL); - rf_InitNode(&readParityNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpreadParityNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, numParityNodes, 1, 4, 0, dag_h, "Rop", allocList); - readParityNodes[i].params[0].p = pda; + tmpreadParityNode->params[0].p = pda; /* buffer to hold old parity */ - readParityNodes[i].params[1].p = rf_AllocBuffer(raidPtr, pda, allocList); - readParityNodes[i].params[2].v = parityStripeID; - readParityNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpreadParityNode->params[1].p = rf_AllocBuffer(raidPtr, pda, allocList); + tmpreadParityNode->params[2].v = parityStripeID; + tmpreadParityNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; - for (j = 0; j < readParityNodes[i].numSuccedents; j++) { - readParityNodes[i].propList[0] = NULL; + for (j = 0; j < tmpreadParityNode->numSuccedents; j++) { + tmpreadParityNode->propList[0] = NULL; } + tmpreadParityNode = tmpreadParityNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) /* initialize nodes which read old Q (Roq) */ if (nfaults == 2) { pda = asmap->qInfo; + tmpreadQNode = readQNodes; for (i = 0; i < numParityNodes; i++) { RF_ASSERT(pda != NULL); - rf_InitNode(&readQNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpreadQNode, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, numParityNodes, 1, 4, 0, dag_h, "Roq", allocList); - readQNodes[i].params[0].p = pda; + tmpreadQNode->params[0].p = pda; /* buffer to hold old Q */ - readQNodes[i].params[1].p = rf_AllocBuffer(raidPtr, pda, allocList); - readQNodes[i].params[2].v = parityStripeID; - readQNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpreadQNode->params[1].p = rf_AllocBuffer(raidPtr, pda, allocList); + tmpreadQNode->params[2].v = parityStripeID; + tmpreadQNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; - for (j = 0; j < readQNodes[i].numSuccedents; j++) { - readQNodes[i].propList[0] = NULL; + for (j = 0; j < tmpreadQNode->numSuccedents; j++) { + tmpreadQNode->propList[0] = NULL; } + tmpreadQNode = tmpreadQNode->list_next; } } #endif /* initialize nodes which write new data (Wnd) */ pda = asmap->physInfo; + tmpwriteDataNode = writeDataNodes; for (i = 0; i < numDataNodes; i++) { RF_ASSERT(pda != NULL); - rf_InitNode(&writeDataNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpwriteDataNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnd", allocList); /* physical disk addr desc */ - writeDataNodes[i].params[0].p = pda; + tmpwriteDataNode->params[0].p = pda; /* buffer holding new data to be written */ - writeDataNodes[i].params[1].p = pda->bufPtr; - writeDataNodes[i].params[2].v = parityStripeID; - writeDataNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpwriteDataNode->params[1].p = pda->bufPtr; + tmpwriteDataNode->params[2].v = parityStripeID; + tmpwriteDataNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; + tmpwriteDataNode = tmpwriteDataNode->list_next; } /* @@ -722,132 +815,165 @@ rf_CommonCreateSmallWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, */ if (numParityNodes == 2) { /* double-xor case */ + tmpxorNode = xorNodes; + tmpreadDataNode = readDataNodes; + tmpreadParityNode = readParityNodes; + tmpwriteDataNode = writeDataNodes; + tmpqNode = qNodes; + tmpreadQNode = readQNodes; for (i = 0; i < numParityNodes; i++) { /* note: no wakeup func for xor */ - rf_InitNode(&xorNodes[i], rf_wait, RF_FALSE, func, + rf_InitNode(tmpxorNode, rf_wait, RF_FALSE, func, undoFunc, NULL, 1, (numDataNodes + numParityNodes), 7, 1, dag_h, name, allocList); - xorNodes[i].flags |= RF_DAGNODE_FLAG_YIELD; - xorNodes[i].params[0] = readDataNodes[i].params[0]; - xorNodes[i].params[1] = readDataNodes[i].params[1]; - xorNodes[i].params[2] = readParityNodes[i].params[0]; - xorNodes[i].params[3] = readParityNodes[i].params[1]; - xorNodes[i].params[4] = writeDataNodes[i].params[0]; - xorNodes[i].params[5] = writeDataNodes[i].params[1]; - xorNodes[i].params[6].p = raidPtr; + tmpxorNode->flags |= RF_DAGNODE_FLAG_YIELD; + tmpxorNode->params[0] = tmpreadDataNode->params[0]; + tmpxorNode->params[1] = tmpreadDataNode->params[1]; + tmpxorNode->params[2] = tmpreadParityNode->params[0]; + tmpxorNode->params[3] = tmpreadParityNode->params[1]; + tmpxorNode->params[4] = tmpwriteDataNode->params[0]; + tmpxorNode->params[5] = tmpwriteDataNode->params[1]; + tmpxorNode->params[6].p = raidPtr; /* use old parity buf as target buf */ - xorNodes[i].results[0] = readParityNodes[i].params[1].p; + tmpxorNode->results[0] = tmpreadParityNode->params[1].p; #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { /* note: no wakeup func for qor */ - rf_InitNode(&qNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpqNode, rf_wait, RF_FALSE, qfunc, undoFunc, NULL, 1, (numDataNodes + numParityNodes), 7, 1, dag_h, qname, allocList); - qNodes[i].params[0] = readDataNodes[i].params[0]; - qNodes[i].params[1] = readDataNodes[i].params[1]; - qNodes[i].params[2] = readQNodes[i].params[0]; - qNodes[i].params[3] = readQNodes[i].params[1]; - qNodes[i].params[4] = writeDataNodes[i].params[0]; - qNodes[i].params[5] = writeDataNodes[i].params[1]; - qNodes[i].params[6].p = raidPtr; + tmpqNode->params[0] = tmpreadDataNode->params[0]; + tmpqNode->params[1] = tmpreadDataNode->params[1]; + tmpqNode->params[2] = tmpreadQNode->.params[0]; + tmpqNode->params[3] = tmpreadQNode->params[1]; + tmpqNode->params[4] = tmpwriteDataNode->params[0]; + tmpqNode->params[5] = tmpwriteDataNode->params[1]; + tmpqNode->params[6].p = raidPtr; /* use old Q buf as target buf */ - qNodes[i].results[0] = readQNodes[i].params[1].p; + tmpqNode->results[0] = tmpreadQNode->params[1].p; + tmpqNode = tmpqNode->list_next; + tmpreadQNodes = tmpreadQNodes->list_next; } #endif + tmpxorNode = tmpxorNode->list_next; + tmpreadDataNode = tmpreadDataNode->list_next; + tmpreadParityNode = tmpreadParityNode->list_next; + tmpwriteDataNode = tmpwriteDataNode->list_next; } } else { /* there is only one xor node in this case */ - rf_InitNode(&xorNodes[0], rf_wait, RF_FALSE, func, + rf_InitNode(xorNodes, rf_wait, RF_FALSE, func, undoFunc, NULL, 1, (numDataNodes + numParityNodes), (2 * (numDataNodes + numDataNodes + 1) + 1), 1, dag_h, name, allocList); - xorNodes[0].flags |= RF_DAGNODE_FLAG_YIELD; - for (i = 0; i < numDataNodes + 1; i++) { - /* set up params related to Rod and Rop nodes */ - xorNodes[0].params[2 * i + 0] = readDataNodes[i].params[0]; /* pda */ - xorNodes[0].params[2 * i + 1] = readDataNodes[i].params[1]; /* buffer ptr */ + xorNodes->flags |= RF_DAGNODE_FLAG_YIELD; + tmpreadDataNode = readDataNodes; + for (i = 0; i < numDataNodes; i++) { /* used to be"numDataNodes + 1" until we factored + out the "+1" into the "deal with Rop separately below */ + /* set up params related to Rod nodes */ + xorNodes->params[2 * i + 0] = tmpreadDataNode->params[0]; /* pda */ + xorNodes->params[2 * i + 1] = tmpreadDataNode->params[1]; /* buffer ptr */ + tmpreadDataNode = tmpreadDataNode->list_next; } + /* deal with Rop separately */ + xorNodes->params[2 * numDataNodes + 0] = readParityNodes->params[0]; /* pda */ + xorNodes->params[2 * numDataNodes + 1] = readParityNodes->params[1]; /* buffer ptr */ + + tmpwriteDataNode = writeDataNodes; for (i = 0; i < numDataNodes; i++) { /* set up params related to Wnd and Wnp nodes */ - xorNodes[0].params[2 * (numDataNodes + 1 + i) + 0] = /* pda */ - writeDataNodes[i].params[0]; - xorNodes[0].params[2 * (numDataNodes + 1 + i) + 1] = /* buffer ptr */ - writeDataNodes[i].params[1]; + xorNodes->params[2 * (numDataNodes + 1 + i) + 0] = /* pda */ + tmpwriteDataNode->params[0]; + xorNodes->params[2 * (numDataNodes + 1 + i) + 1] = /* buffer ptr */ + tmpwriteDataNode->params[1]; + tmpwriteDataNode = tmpwriteDataNode->list_next; } /* xor node needs to get at RAID information */ - xorNodes[0].params[2 * (numDataNodes + numDataNodes + 1)].p = raidPtr; - xorNodes[0].results[0] = readParityNodes[0].params[1].p; + xorNodes->params[2 * (numDataNodes + numDataNodes + 1)].p = raidPtr; + xorNodes->results[0] = readParityNodes->params[1].p; #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { - rf_InitNode(&qNodes[0], rf_wait, RF_FALSE, qfunc, + rf_InitNode(qNodes, rf_wait, RF_FALSE, qfunc, undoFunc, NULL, 1, (numDataNodes + numParityNodes), (2 * (numDataNodes + numDataNodes + 1) + 1), 1, dag_h, qname, allocList); + tmpreadDataNode = readDataNodes; for (i = 0; i < numDataNodes; i++) { /* set up params related to Rod */ - qNodes[0].params[2 * i + 0] = readDataNodes[i].params[0]; /* pda */ - qNodes[0].params[2 * i + 1] = readDataNodes[i].params[1]; /* buffer ptr */ + qNodes->params[2 * i + 0] = tmpreadDataNode->params[0]; /* pda */ + qNodes->params[2 * i + 1] = tmpreadDataNode->params[1]; /* buffer ptr */ + tmpreadDataNode = tmpreadDataNode->list_next; } /* and read old q */ - qNodes[0].params[2 * numDataNodes + 0] = /* pda */ - readQNodes[0].params[0]; - qNodes[0].params[2 * numDataNodes + 1] = /* buffer ptr */ - readQNodes[0].params[1]; + qNodes->params[2 * numDataNodes + 0] = /* pda */ + readQNodes->params[0]; + qNodes->params[2 * numDataNodes + 1] = /* buffer ptr */ + readQNodes->params[1]; + tmpwriteDataNode = writeDataNodes; for (i = 0; i < numDataNodes; i++) { /* set up params related to Wnd nodes */ - qNodes[0].params[2 * (numDataNodes + 1 + i) + 0] = /* pda */ - writeDataNodes[i].params[0]; - qNodes[0].params[2 * (numDataNodes + 1 + i) + 1] = /* buffer ptr */ - writeDataNodes[i].params[1]; + qNodes->params[2 * (numDataNodes + 1 + i) + 0] = /* pda */ + tmpwriteDataNode->params[0]; + qNodes->params[2 * (numDataNodes + 1 + i) + 1] = /* buffer ptr */ + tmpwriteDataNode->params[1]; + tmpwriteDataNode = tmpwriteDataNode->list_next; } /* xor node needs to get at RAID information */ - qNodes[0].params[2 * (numDataNodes + numDataNodes + 1)].p = raidPtr; - qNodes[0].results[0] = readQNodes[0].params[1].p; + qNodes->params[2 * (numDataNodes + numDataNodes + 1)].p = raidPtr; + qNodes->results[0] = readQNodes->params[1].p; } #endif } /* initialize nodes which write new parity (Wnp) */ pda = asmap->parityInfo; + tmpwriteParityNode = writeParityNodes; + tmpxorNode = xorNodes; for (i = 0; i < numParityNodes; i++) { - rf_InitNode(&writeParityNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpwriteParityNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnp", allocList); RF_ASSERT(pda != NULL); - writeParityNodes[i].params[0].p = pda; /* param 1 (bufPtr) - * filled in by xor node */ - writeParityNodes[i].params[1].p = xorNodes[i].results[0]; /* buffer pointer for - * parity write - * operation */ - writeParityNodes[i].params[2].v = parityStripeID; - writeParityNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpwriteParityNode->params[0].p = pda; /* param 1 (bufPtr) + * filled in by xor node */ + tmpwriteParityNode->params[1].p = tmpxorNode->results[0]; /* buffer pointer for + * parity write + * operation */ + tmpwriteParityNode->params[2].v = parityStripeID; + tmpwriteParityNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; + tmpwriteParityNode = tmpwriteParityNode->list_next; + tmpxorNode = tmpxorNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) /* initialize nodes which write new Q (Wnq) */ if (nfaults == 2) { pda = asmap->qInfo; + tmpwriteQNode = writeQNodes; + tmpqNode = qNodes; for (i = 0; i < numParityNodes; i++) { - rf_InitNode(&writeQNodes[i], rf_wait, RF_FALSE, + rf_InitNode(tmpwriteQNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnq", allocList); RF_ASSERT(pda != NULL); - writeQNodes[i].params[0].p = pda; /* param 1 (bufPtr) + tmpwriteQNode->params[0].p = pda; /* param 1 (bufPtr) * filled in by xor node */ - writeQNodes[i].params[1].p = qNodes[i].results[0]; /* buffer pointer for + tmpwriteQNode->params[1].p = tmpqNode->results[0]; /* buffer pointer for * parity write * operation */ - writeQNodes[i].params[2].v = parityStripeID; - writeQNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, + tmpwriteQNode->params[2].v = parityStripeID; + tmpwriteQNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; + tmpwriteQNode = tmpwriteQNode->list_next; + tmpqNode = tmpqNode->list_next; } } #endif @@ -860,148 +986,188 @@ rf_CommonCreateSmallWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* connect block node to read old data nodes */ RF_ASSERT(blockNode->numSuccedents == (numDataNodes + (numParityNodes * nfaults))); + tmpreadDataNode = readDataNodes; for (i = 0; i < numDataNodes; i++) { - blockNode->succedents[i] = &readDataNodes[i]; - RF_ASSERT(readDataNodes[i].numAntecedents == 1); - readDataNodes[i].antecedents[0] = blockNode; - readDataNodes[i].antType[0] = rf_control; + blockNode->succedents[i] = tmpreadDataNode; + RF_ASSERT(tmpreadDataNode->numAntecedents == 1); + tmpreadDataNode->antecedents[0] = blockNode; + tmpreadDataNode->antType[0] = rf_control; + tmpreadDataNode = tmpreadDataNode->list_next; } /* connect block node to read old parity nodes */ + tmpreadParityNode = readParityNodes; for (i = 0; i < numParityNodes; i++) { - blockNode->succedents[numDataNodes + i] = &readParityNodes[i]; - RF_ASSERT(readParityNodes[i].numAntecedents == 1); - readParityNodes[i].antecedents[0] = blockNode; - readParityNodes[i].antType[0] = rf_control; + blockNode->succedents[numDataNodes + i] = tmpreadParityNode; + RF_ASSERT(tmpreadParityNode->numAntecedents == 1); + tmpreadParityNode->antecedents[0] = blockNode; + tmpreadParityNode->antType[0] = rf_control; + tmpreadParityNode = tmpreadParityNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) /* connect block node to read old Q nodes */ if (nfaults == 2) { + tmpreadQNode = readQNodes; for (i = 0; i < numParityNodes; i++) { - blockNode->succedents[numDataNodes + numParityNodes + i] = &readQNodes[i]; - RF_ASSERT(readQNodes[i].numAntecedents == 1); - readQNodes[i].antecedents[0] = blockNode; - readQNodes[i].antType[0] = rf_control; + blockNode->succedents[numDataNodes + numParityNodes + i] = tmpreadQNode; + RF_ASSERT(tmpreadQNode->numAntecedents == 1); + tmpreadQNode->antecedents[0] = blockNode; + tmpreadQNode->antType[0] = rf_control; + tmpreadQNode = tmpreadQNode->list_next; } } #endif /* connect read old data nodes to xor nodes */ + tmpreadDataNode = readDataNodes; for (i = 0; i < numDataNodes; i++) { - RF_ASSERT(readDataNodes[i].numSuccedents == (nfaults * numParityNodes)); + RF_ASSERT(tmpreadDataNode->numSuccedents == (nfaults * numParityNodes)); + tmpxorNode = xorNodes; for (j = 0; j < numParityNodes; j++) { - RF_ASSERT(xorNodes[j].numAntecedents == numDataNodes + numParityNodes); - readDataNodes[i].succedents[j] = &xorNodes[j]; - xorNodes[j].antecedents[i] = &readDataNodes[i]; - xorNodes[j].antType[i] = rf_trueData; + RF_ASSERT(tmpxorNode->numAntecedents == numDataNodes + numParityNodes); + tmpreadDataNode->succedents[j] = tmpxorNode; + tmpxorNode->antecedents[i] = tmpreadDataNode; + tmpxorNode->antType[i] = rf_trueData; + tmpxorNode = tmpxorNode->list_next; } + tmpreadDataNode = tmpreadDataNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) /* connect read old data nodes to q nodes */ if (nfaults == 2) { + tmpreadDataNode = readDataNodes; for (i = 0; i < numDataNodes; i++) { + tmpqNode = qNodes; for (j = 0; j < numParityNodes; j++) { - RF_ASSERT(qNodes[j].numAntecedents == numDataNodes + numParityNodes); - readDataNodes[i].succedents[numParityNodes + j] = &qNodes[j]; - qNodes[j].antecedents[i] = &readDataNodes[i]; - qNodes[j].antType[i] = rf_trueData; + RF_ASSERT(tmpqNode->numAntecedents == numDataNodes + numParityNodes); + tmpreadDataNode->succedents[numParityNodes + j] = tmpqNode; + tmpqNode->antecedents[i] = tmpreadDataNode; + tmpqNode->antType[i] = rf_trueData; + tmpqNode = tmpqNode->list_next; } + tmpreadDataNode = tmpreadDataNode->list_next; } } #endif /* connect read old parity nodes to xor nodes */ + tmpreadParityNode = readParityNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(readParityNodes[i].numSuccedents == numParityNodes); + RF_ASSERT(tmpreadParityNode->numSuccedents == numParityNodes); + tmpxorNode = xorNodes; for (j = 0; j < numParityNodes; j++) { - readParityNodes[i].succedents[j] = &xorNodes[j]; - xorNodes[j].antecedents[numDataNodes + i] = &readParityNodes[i]; - xorNodes[j].antType[numDataNodes + i] = rf_trueData; + tmpreadParityNode->succedents[j] = tmpxorNode; + tmpxorNode->antecedents[numDataNodes + i] = tmpreadParityNode; + tmpxorNode->antType[numDataNodes + i] = rf_trueData; + tmpxorNode = tmpxorNode->list_next; } + tmpreadParityNode = tmpreadParityNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) /* connect read old q nodes to q nodes */ if (nfaults == 2) { + tmpreadParityNode = readParityNodes; + tmpreadQNode = readQNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(readParityNodes[i].numSuccedents == numParityNodes); + RF_ASSERT(tmpreadParityNode->numSuccedents == numParityNodes); + tmpqNode = qNodes; for (j = 0; j < numParityNodes; j++) { - readQNodes[i].succedents[j] = &qNodes[j]; - qNodes[j].antecedents[numDataNodes + i] = &readQNodes[i]; - qNodes[j].antType[numDataNodes + i] = rf_trueData; + tmpreadQNode->succedents[j] = tmpqNode; + tmpqNode->antecedents[numDataNodes + i] = tmpreadQNodes; + tmpqNode->antType[numDataNodes + i] = rf_trueData; + tmpqNode = tmpqNode->list_next; } + tmpreadParityNode = tmpreadParityNode->list_next; + tmpreadQNode = tmpreadQNode->list_next; } } #endif /* connect xor nodes to commit node */ RF_ASSERT(commitNode->numAntecedents == (nfaults * numParityNodes)); + tmpxorNode = xorNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(xorNodes[i].numSuccedents == 1); - xorNodes[i].succedents[0] = commitNode; - commitNode->antecedents[i] = &xorNodes[i]; + RF_ASSERT(tmpxorNode->numSuccedents == 1); + tmpxorNode->succedents[0] = commitNode; + commitNode->antecedents[i] = tmpxorNode; commitNode->antType[i] = rf_control; + tmpxorNode = tmpxorNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) /* connect q nodes to commit node */ if (nfaults == 2) { + tmpqNode = qNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(qNodes[i].numSuccedents == 1); - qNodes[i].succedents[0] = commitNode; - commitNode->antecedents[i + numParityNodes] = &qNodes[i]; + RF_ASSERT(tmpqNode->numSuccedents == 1); + tmpqNode->succedents[0] = commitNode; + commitNode->antecedents[i + numParityNodes] = tmpqNode; commitNode->antType[i + numParityNodes] = rf_control; + tmpqNode = tmpqNode->list_next; } } #endif /* connect commit node to write nodes */ RF_ASSERT(commitNode->numSuccedents == (numDataNodes + (nfaults * numParityNodes))); + tmpwriteDataNode = writeDataNodes; for (i = 0; i < numDataNodes; i++) { - RF_ASSERT(writeDataNodes[i].numAntecedents == 1); - commitNode->succedents[i] = &writeDataNodes[i]; - writeDataNodes[i].antecedents[0] = commitNode; - writeDataNodes[i].antType[0] = rf_trueData; + RF_ASSERT(tmpwriteDataNodes->numAntecedents == 1); + commitNode->succedents[i] = tmpwriteDataNode; + tmpwriteDataNode->antecedents[0] = commitNode; + tmpwriteDataNode->antType[0] = rf_trueData; + tmpwriteDataNode = tmpwriteDataNode->list_next; } + tmpwriteParityNode = writeParityNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(writeParityNodes[i].numAntecedents == 1); - commitNode->succedents[i + numDataNodes] = &writeParityNodes[i]; - writeParityNodes[i].antecedents[0] = commitNode; - writeParityNodes[i].antType[0] = rf_trueData; + RF_ASSERT(tmpwriteParityNode->numAntecedents == 1); + commitNode->succedents[i + numDataNodes] = tmpwriteParityNode; + tmpwriteParityNode->antecedents[0] = commitNode; + tmpwriteParityNode->antType[0] = rf_trueData; + tmpwriteParityNode = tmpwriteParityNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { + tmpwriteQNode = writeQNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(writeQNodes[i].numAntecedents == 1); - commitNode->succedents[i + numDataNodes + numParityNodes] = &writeQNodes[i]; - writeQNodes[i].antecedents[0] = commitNode; - writeQNodes[i].antType[0] = rf_trueData; + RF_ASSERT(tmpwriteQNode->numAntecedents == 1); + commitNode->succedents[i + numDataNodes + numParityNodes] = tmpwriteQNode; + tmpwriteQNode->antecedents[0] = commitNode; + tmpwriteQNode->antType[0] = rf_trueData; + tmpwriteQNode = tmpwriteQNode->list_next; } } #endif RF_ASSERT(termNode->numAntecedents == (numDataNodes + (nfaults * numParityNodes))); RF_ASSERT(termNode->numSuccedents == 0); + tmpwriteDataNode = writeDataNodes; for (i = 0; i < numDataNodes; i++) { /* connect write new data nodes to term node */ - RF_ASSERT(writeDataNodes[i].numSuccedents == 1); + RF_ASSERT(tmpwriteDataNode->numSuccedents == 1); RF_ASSERT(termNode->numAntecedents == (numDataNodes + (nfaults * numParityNodes))); - writeDataNodes[i].succedents[0] = termNode; - termNode->antecedents[i] = &writeDataNodes[i]; + tmpwriteDataNode->succedents[0] = termNode; + termNode->antecedents[i] = tmpwriteDataNode; termNode->antType[i] = rf_control; + tmpwriteDataNode = tmpwriteDataNode->list_next; } + tmpwriteParityNode = writeParityNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(writeParityNodes[i].numSuccedents == 1); - writeParityNodes[i].succedents[0] = termNode; - termNode->antecedents[numDataNodes + i] = &writeParityNodes[i]; + RF_ASSERT(tmpwriteParityNode->numSuccedents == 1); + tmpwriteParityNode->succedents[0] = termNode; + termNode->antecedents[numDataNodes + i] = tmpwriteParityNode; termNode->antType[numDataNodes + i] = rf_control; + tmpwriteParityNode = tmpwriteParityNode->list_next; } #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) if (nfaults == 2) { + tmpwriteQNode = writeQNodes; for (i = 0; i < numParityNodes; i++) { - RF_ASSERT(writeQNodes[i].numSuccedents == 1); - writeQNodes[i].succedents[0] = termNode; - termNode->antecedents[numDataNodes + numParityNodes + i] = &writeQNodes[i]; + RF_ASSERT(tmpwriteQNode->numSuccedents == 1); + tmpwriteQNode->succedents[0] = termNode; + termNode->antecedents[numDataNodes + numParityNodes + i] = tmpwriteQNode; termNode->antType[numDataNodes + numParityNodes + i] = rf_control; + tmpwriteQNode = tmpwriteQNode->list_next; } } #endif @@ -1031,7 +1197,8 @@ rf_CreateRaidOneWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, RF_AllocListElem_t *allocList) { RF_DagNode_t *unblockNode, *termNode, *commitNode; - RF_DagNode_t *nodes, *wndNode, *wmirNode; + RF_DagNode_t *wndNode, *wmirNode; + RF_DagNode_t *tmpNode, *tmpwndNode, *tmpwmirNode; int nWndNodes, nWmirNodes, i; RF_ReconUnitNum_t which_ru; RF_PhysDiskAddr_t *pda, *pdaP; @@ -1058,21 +1225,31 @@ rf_CreateRaidOneWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* total number of nodes = nWndNodes + nWmirNodes + (commit + unblock * + terminator) */ - RF_MallocAndAdd(nodes, - (nWndNodes + nWmirNodes + 3) * sizeof(RF_DagNode_t), - (RF_DagNode_t *), allocList); - i = 0; - wndNode = &nodes[i]; - i += nWndNodes; - wmirNode = &nodes[i]; - i += nWmirNodes; - commitNode = &nodes[i]; - i += 1; - unblockNode = &nodes[i]; - i += 1; - termNode = &nodes[i]; - i += 1; - RF_ASSERT(i == (nWndNodes + nWmirNodes + 3)); + for (i = 0; i < nWndNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + wndNode = dag_h->nodes; + + for (i = 0; i < nWmirNodes; i++) { + tmpNode = rf_AllocDAGNode(); + tmpNode->list_next = dag_h->nodes; + dag_h->nodes = tmpNode; + } + wmirNode = dag_h->nodes; + + commitNode = rf_AllocDAGNode(); + commitNode->list_next = dag_h->nodes; + dag_h->nodes = commitNode; + + unblockNode = rf_AllocDAGNode(); + unblockNode->list_next = dag_h->nodes; + dag_h->nodes = unblockNode; + + termNode = rf_AllocDAGNode(); + termNode->list_next = dag_h->nodes; + dag_h->nodes = termNode; /* this dag can commit immediately */ dag_h->numCommitNodes = 1; @@ -1093,17 +1270,19 @@ rf_CreateRaidOneWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* initialize the wnd nodes */ if (nWndNodes > 0) { pda = asmap->physInfo; + tmpwndNode = wndNode; for (i = 0; i < nWndNodes; i++) { - rf_InitNode(&wndNode[i], rf_wait, RF_FALSE, + rf_InitNode(tmpwndNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wpd", allocList); RF_ASSERT(pda != NULL); - wndNode[i].params[0].p = pda; - wndNode[i].params[1].p = pda->bufPtr; - wndNode[i].params[2].v = parityStripeID; - wndNode[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmpwndNode->params[0].p = pda; + tmpwndNode->params[1].p = pda->bufPtr; + tmpwndNode->params[2].v = parityStripeID; + tmpwndNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; + tmpwndNode = tmpwndNode->list_next; } RF_ASSERT(pda == NULL); } @@ -1111,18 +1290,20 @@ rf_CreateRaidOneWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, if (nWmirNodes > 0) { pda = asmap->physInfo; pdaP = asmap->parityInfo; + tmpwmirNode = wmirNode; for (i = 0; i < nWmirNodes; i++) { - rf_InitNode(&wmirNode[i], rf_wait, RF_FALSE, + rf_InitNode(tmpwmirNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wsd", allocList); RF_ASSERT(pda != NULL); - wmirNode[i].params[0].p = pdaP; - wmirNode[i].params[1].p = pda->bufPtr; - wmirNode[i].params[2].v = parityStripeID; - wmirNode[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); + tmpwmirNode->params[0].p = pdaP; + tmpwmirNode->params[1].p = pda->bufPtr; + tmpwmirNode->params[2].v = parityStripeID; + tmpwmirNode->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru); pda = pda->next; pdaP = pdaP->next; + tmpwmirNode = tmpwmirNode->list_next; } RF_ASSERT(pda == NULL); RF_ASSERT(pdaP == NULL); @@ -1134,32 +1315,40 @@ rf_CreateRaidOneWriteDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap, /* link the commit node to the write nodes */ RF_ASSERT(commitNode->numSuccedents == (nWndNodes + nWmirNodes)); + tmpwndNode = wndNode; for (i = 0; i < nWndNodes; i++) { - RF_ASSERT(wndNode[i].numAntecedents == 1); - commitNode->succedents[i] = &wndNode[i]; - wndNode[i].antecedents[0] = commitNode; - wndNode[i].antType[0] = rf_control; + RF_ASSERT(tmpwndNode->numAntecedents == 1); + commitNode->succedents[i] = tmpwndNode; + tmpwndNode->antecedents[0] = commitNode; + tmpwndNode->antType[0] = rf_control; + tmpwndNode = tmpwndNode->list_next; } + tmpwmirNode = wmirNode; for (i = 0; i < nWmirNodes; i++) { - RF_ASSERT(wmirNode[i].numAntecedents == 1); - commitNode->succedents[i + nWndNodes] = &wmirNode[i]; - wmirNode[i].antecedents[0] = commitNode; - wmirNode[i].antType[0] = rf_control; + RF_ASSERT(tmpwmirNode->numAntecedents == 1); + commitNode->succedents[i + nWndNodes] = tmpwmirNode; + tmpwmirNode->antecedents[0] = commitNode; + tmpwmirNode->antType[0] = rf_control; + tmpwmirNode = tmpwmirNode->list_next; } /* link the write nodes to the unblock node */ RF_ASSERT(unblockNode->numAntecedents == (nWndNodes + nWmirNodes)); + tmpwndNode = wndNode; for (i = 0; i < nWndNodes; i++) { - RF_ASSERT(wndNode[i].numSuccedents == 1); - wndNode[i].succedents[0] = unblockNode; - unblockNode->antecedents[i] = &wndNode[i]; + RF_ASSERT(tmpwndNode->numSuccedents == 1); + tmpwndNode->succedents[0] = unblockNode; + unblockNode->antecedents[i] = tmpwndNode; unblockNode->antType[i] = rf_control; + tmpwndNode = tmpwndNode->list_next; } + tmpwmirNode = wmirNode; for (i = 0; i < nWmirNodes; i++) { - RF_ASSERT(wmirNode[i].numSuccedents == 1); - wmirNode[i].succedents[0] = unblockNode; - unblockNode->antecedents[i + nWndNodes] = &wmirNode[i]; + RF_ASSERT(tmpwmirNode->numSuccedents == 1); + tmpwmirNode->succedents[0] = unblockNode; + unblockNode->antecedents[i + nWndNodes] = tmpwmirNode; unblockNode->antType[i + nWndNodes] = rf_control; + tmpwmirNode = tmpwmirNode->list_next; } /* link the unblock node to the term node */ diff --git a/sys/dev/raidframe/rf_dagutils.c b/sys/dev/raidframe/rf_dagutils.c index b1c77db522c..505aa29a192 100644 --- a/sys/dev/raidframe/rf_dagutils.c +++ b/sys/dev/raidframe/rf_dagutils.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagutils.c,v 1.37 2004/03/07 22:15:19 oster Exp $ */ +/* $NetBSD: rf_dagutils.c,v 1.38 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.37 2004/03/07 22:15:19 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.38 2004/03/18 16:40:05 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -97,6 +97,9 @@ rf_InitNode(RF_DagNode_t *node, RF_NodeStatus_t initstatus, int commit, node->numAntecedents = nAnte; node->numAntDone = 0; node->next = NULL; + /* node->list_next = NULL */ /* Don't touch this here! + It may already be + in use by the caller! */ node->numSuccedents = nSucc; node->name = name; node->dagHdr = hdr; @@ -152,6 +155,7 @@ void rf_FreeDAG(RF_DagHeader_t *dag_h) { RF_AccessStripeMapHeader_t *asmap, *t_asmap; + RF_DagNode_t *tmpnode; RF_DagHeader_t *nextDag; while (dag_h) { @@ -162,6 +166,11 @@ rf_FreeDAG(RF_DagHeader_t *dag_h) asmap = asmap->next; rf_FreeAccessStripeMap(t_asmap); } + while(dag_h->nodes) { + tmpnode = dag_h->nodes; + dag_h->nodes = dag_h->nodes->list_next; + rf_FreeDAGNode(tmpnode); + } rf_FreeDAGHeader(dag_h); dag_h = nextDag; } @@ -170,6 +179,9 @@ rf_FreeDAG(RF_DagHeader_t *dag_h) #define RF_MAX_FREE_DAGH 128 #define RF_MIN_FREE_DAGH 32 +#define RF_MAX_FREE_DAGNODE 512 /* XXX Tune this... */ +#define RF_MIN_FREE_DAGNODE 128 /* XXX Tune this... */ + #define RF_MAX_FREE_DAGLIST 128 #define RF_MIN_FREE_DAGLIST 32 @@ -181,6 +193,7 @@ static void rf_ShutdownDAGs(void *ignored) { pool_destroy(&rf_pools.dagh); + pool_destroy(&rf_pools.dagnode); pool_destroy(&rf_pools.daglist); pool_destroy(&rf_pools.funclist); } @@ -189,6 +202,8 @@ int rf_ConfigureDAGs(RF_ShutdownList_t **listp) { + rf_pool_init(&rf_pools.dagnode, sizeof(RF_DagNode_t), + "rf_dagnode_pl", RF_MIN_FREE_DAGNODE, RF_MAX_FREE_DAGNODE); rf_pool_init(&rf_pools.dagh, sizeof(RF_DagHeader_t), "rf_dagh_pl", RF_MIN_FREE_DAGH, RF_MAX_FREE_DAGH); rf_pool_init(&rf_pools.daglist, sizeof(RF_DagList_t), @@ -216,6 +231,22 @@ rf_FreeDAGHeader(RF_DagHeader_t * dh) pool_put(&rf_pools.dagh, dh); } +RF_DagNode_t * +rf_AllocDAGNode() +{ + RF_DagNode_t *node; + + node = pool_get(&rf_pools.dagnode, PR_WAITOK); + memset(node, 0, sizeof(RF_DagNode_t)); + return (node); +} + +void +rf_FreeDAGNode(RF_DagNode_t *node) +{ + pool_put(&rf_pools.dagnode, node); +} + RF_DagList_t * rf_AllocDAGList() { diff --git a/sys/dev/raidframe/rf_dagutils.h b/sys/dev/raidframe/rf_dagutils.h index 1766c2d7721..95d96ebd5c5 100644 --- a/sys/dev/raidframe/rf_dagutils.h +++ b/sys/dev/raidframe/rf_dagutils.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_dagutils.h,v 1.10 2004/03/06 23:52:20 oster Exp $ */ +/* $NetBSD: rf_dagutils.h,v 1.11 2004/03/18 16:40:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -73,6 +73,9 @@ RF_DagHeader_t *rf_AllocDAGHeader(void); void rf_FreeDAGHeader(RF_DagHeader_t * dh); +RF_DagNode_t *rf_AllocDAGNode(void); +void rf_FreeDAGNode(RF_DagNode_t *); + RF_DagList_t *rf_AllocDAGList(void); void rf_FreeDAGList(RF_DagList_t *); diff --git a/sys/dev/raidframe/rf_netbsd.h b/sys/dev/raidframe/rf_netbsd.h index e80c32ef78d..b015e0eb4e8 100644 --- a/sys/dev/raidframe/rf_netbsd.h +++ b/sys/dev/raidframe/rf_netbsd.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsd.h,v 1.15 2004/03/08 02:25:27 oster Exp $ */ +/* $NetBSD: rf_netbsd.h,v 1.16 2004/03/18 16:40:05 oster Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -69,6 +69,7 @@ struct RF_Pools_s { struct pool callback; /* Callback descriptors */ struct pool cbuf; /* Component buffers */ struct pool dagh; /* DAG headers */ + struct pool dagnode; /* DAG nodes */ struct pool daglist; /* DAG lists */ struct pool dqd; /* Disk Queue Data */ struct pool funclist; /* Function Lists */ |
