diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-02-16 00:03:34 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-02-16 00:03:34 +0000 |
commit | 086450a69044f3ede65845d9a616116db9a6d006 (patch) | |
tree | a91a7d8f967737b7eed23cb127849d08e3af4d63 /sys/dev/raidframe/rf_dagffrd.c | |
parent | 41fb84abc5659cc1a368cd59d7929ddf756c3297 (diff) |
Merge from NetBSD, mostly indentation
Diffstat (limited to 'sys/dev/raidframe/rf_dagffrd.c')
-rw-r--r-- | sys/dev/raidframe/rf_dagffrd.c | 664 |
1 files changed, 302 insertions, 362 deletions
diff --git a/sys/dev/raidframe/rf_dagffrd.c b/sys/dev/raidframe/rf_dagffrd.c index b831980cb0e..09df06c22e6 100644 --- a/sys/dev/raidframe/rf_dagffrd.c +++ b/sys/dev/raidframe/rf_dagffrd.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rf_dagffrd.c,v 1.1 1999/01/11 14:29:08 niklas Exp $ */ -/* $NetBSD: rf_dagffrd.c,v 1.1 1998/11/13 04:20:27 oster Exp $ */ +/* $OpenBSD: rf_dagffrd.c,v 1.2 1999/02/16 00:02:30 niklas Exp $ */ +/* $NetBSD: rf_dagffrd.c,v 1.3 1999/02/05 00:06:07 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -32,78 +32,6 @@ * * code for creating fault-free read DAGs * - * : - * Log: rf_dagffrd.c,v - * Revision 1.14 1996/07/28 20:31:39 jimz - * i386netbsd port - * true/false fixup - * - * Revision 1.13 1996/07/22 19:52:16 jimz - * switched node params to RF_DagParam_t, a union of - * a 64-bit int and a void *, for better portability - * attempted hpux port, but failed partway through for - * lack of a single C compiler capable of compiling all - * source files - * - * Revision 1.12 1996/06/09 02:36:46 jimz - * lots of little crufty cleanup- fixup whitespace - * issues, comment #ifdefs, improve typing in some - * places (esp size-related) - * - * Revision 1.11 1996/06/06 17:30:44 jimz - * turn old Raid1 mirror read creation into a more generic function - * parameterized by an addtional parameter: type of mirrored read - * this is now used by other dag creation routines so chained declustering - * and raid1 can share dag creation code, but have different mirroring - * policies - * - * Revision 1.10 1996/05/31 22:26:54 jimz - * fix a lot of mapping problems, memory allocation problems - * found some weird lock issues, fixed 'em - * more code cleanup - * - * Revision 1.9 1996/05/30 11:29:41 jimz - * Numerous bug fixes. Stripe lock release code disagreed with the taking code - * about when stripes should be locked (I made it consistent: no parity, no lock) - * There was a lot of extra serialization of I/Os which I've removed- a lot of - * it was to calculate values for the cache code, which is no longer with us. - * More types, function, macro cleanup. Added code to properly quiesce the array - * on shutdown. Made a lot of stuff array-specific which was (bogusly) general - * before. Fixed memory allocation, freeing bugs. - * - * Revision 1.8 1996/05/27 18:56:37 jimz - * more code cleanup - * better typing - * compiles in all 3 environments - * - * Revision 1.7 1996/05/24 22:17:04 jimz - * continue code + namespace cleanup - * typed a bunch of flags - * - * Revision 1.6 1996/05/24 04:28:55 jimz - * release cleanup ckpt - * - * Revision 1.5 1996/05/23 21:46:35 jimz - * checkpoint in code cleanup (release prep) - * lots of types, function names have been fixed - * - * Revision 1.4 1996/05/23 00:33:23 jimz - * code cleanup: move all debug decls to rf_options.c, all extern - * debug decls to rf_options.h, all debug vars preceded by rf_ - * - * Revision 1.3 1996/05/18 19:51:34 jimz - * major code cleanup- fix syntax, make some types consistent, - * add prototypes, clean out dead code, et cetera - * - * Revision 1.2 1996/05/08 21:01:24 jimz - * fixed up enum type names that were conflicting with other - * enums and function names (ie, "panic") - * future naming trends will be towards RF_ and rf_ for - * everything raidframe-related - * - * Revision 1.1 1996/05/03 19:19:20 wvcii - * Initial revision - * */ #include "rf_types.h" @@ -120,7 +48,7 @@ /****************************************************************************** * * General comments on DAG creation: - * + * * All DAGs in this file use roll-away error recovery. Each DAG has a single * commit node, usually called "Cmt." If an error occurs before the Cmt node * is reached, the execution engine will halt forward execution and work @@ -144,16 +72,17 @@ * the DAG creation routines to be replaced at this single point. */ -void rf_CreateFaultFreeReadDAG( - RF_Raid_t *raidPtr, - RF_AccessStripeMap_t *asmap, - RF_DagHeader_t *dag_h, - void *bp, - RF_RaidAccessFlags_t flags, - RF_AllocListElem_t *allocList) +void +rf_CreateFaultFreeReadDAG( + RF_Raid_t * raidPtr, + RF_AccessStripeMap_t * asmap, + RF_DagHeader_t * dag_h, + void *bp, + RF_RaidAccessFlags_t flags, + RF_AllocListElem_t * allocList) { - rf_CreateNonredundantDAG(raidPtr, asmap, dag_h, bp, flags, allocList, - RF_IO_TYPE_READ); + rf_CreateNonredundantDAG(raidPtr, asmap, dag_h, bp, flags, allocList, + RF_IO_TYPE_READ); } @@ -168,13 +97,13 @@ void rf_CreateFaultFreeReadDAG( * stripe. * For reads, this DAG is as follows: * - * /---- read ----\ + * /---- read ----\ * Header -- Block ---- read ---- Commit -- Terminate * \---- read ----/ * * For writes, this DAG is as follows: * - * /---- write ----\ + * /---- write ----\ * Header -- Commit ---- write ---- Block -- Terminate * \---- write ----/ * @@ -196,163 +125,168 @@ void rf_CreateFaultFreeReadDAG( * *****************************************************************************/ -void rf_CreateNonredundantDAG( - RF_Raid_t *raidPtr, - RF_AccessStripeMap_t *asmap, - RF_DagHeader_t *dag_h, - void *bp, - RF_RaidAccessFlags_t flags, - RF_AllocListElem_t *allocList, - RF_IoType_t type) +void +rf_CreateNonredundantDAG( + RF_Raid_t * raidPtr, + RF_AccessStripeMap_t * asmap, + RF_DagHeader_t * dag_h, + void *bp, + RF_RaidAccessFlags_t flags, + RF_AllocListElem_t * allocList, + RF_IoType_t type) { - RF_DagNode_t *nodes, *diskNodes, *blockNode, *commitNode, *termNode; - RF_PhysDiskAddr_t *pda = asmap->physInfo; - int (*doFunc)(RF_DagNode_t *), (*undoFunc)(RF_DagNode_t *); - int i, n, totalNumNodes; - char *name; - - n = asmap->numStripeUnitsAccessed; - dag_h->creator = "NonredundantDAG"; - - RF_ASSERT(RF_IO_IS_R_OR_W(type)); - switch (type) { - case RF_IO_TYPE_READ: - doFunc = rf_DiskReadFunc; - undoFunc = rf_DiskReadUndoFunc; - name = "R "; - if (rf_dagDebug) printf("[Creating non-redundant read DAG]\n"); - break; - case RF_IO_TYPE_WRITE: - doFunc = rf_DiskWriteFunc; - undoFunc = rf_DiskWriteUndoFunc; - name = "W "; - if (rf_dagDebug) printf("[Creating non-redundant write DAG]\n"); - break; - default: - RF_PANIC(); - } - - /* - * For reads, the dag can not commit until the block node is reached. - * for writes, the dag commits immediately. - */ - dag_h->numCommitNodes = 1; - dag_h->numCommits = 0; - dag_h->numSuccedents = 1; - - /* - * Node count: - * 1 block node - * n data reads (or writes) - * 1 commit node - * 1 terminator node - */ - RF_ASSERT(n > 0); - totalNumNodes = n + 3; - RF_CallocAndAdd(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); - - /* initialize nodes */ - switch (type) { - case RF_IO_TYPE_READ: - rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, - NULL, n, 0, 0, 0, dag_h, "Nil", allocList); - rf_InitNode(commitNode, rf_wait, RF_TRUE, rf_NullNodeFunc, rf_NullNodeUndoFunc, - NULL, 1, n, 0, 0, dag_h, "Cmt", allocList); - rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, rf_TerminateUndoFunc, - NULL, 0, 1, 0, 0, dag_h, "Trm", allocList); - break; - case RF_IO_TYPE_WRITE: - rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, - NULL, 1, 0, 0, 0, dag_h, "Nil", allocList); - rf_InitNode(commitNode, rf_wait, RF_TRUE, rf_NullNodeFunc, rf_NullNodeUndoFunc, - NULL, n, 1, 0, 0, dag_h, "Cmt", allocList); - rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, rf_TerminateUndoFunc, - NULL, 0, n, 0, 0, dag_h, "Trm", allocList); - break; - default: - RF_PANIC(); - } - - for (i = 0; i < n; i++) { - RF_ASSERT(pda != NULL); - rf_InitNode(&diskNodes[i], 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; - /* 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, 0, 0); - pda = pda->next; - } - - /* - * Connect nodes. - */ - - /* connect hdr to block node */ - RF_ASSERT(blockNode->numAntecedents == 0); - dag_h->succedents[0] = blockNode; - - if (type == RF_IO_TYPE_READ) { - /* connecting a nonredundant read DAG */ - RF_ASSERT(blockNode->numSuccedents == n); - RF_ASSERT(commitNode->numAntecedents == n); - 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; - - /* connect each read node to the commit node */ - RF_ASSERT(diskNodes[i].numSuccedents == 1); - diskNodes[i].succedents[0] = commitNode; - commitNode->antecedents[i] = &diskNodes[i]; - commitNode->antType[i] = rf_control; - } - /* connect the commit node to the term node */ - RF_ASSERT(commitNode->numSuccedents == 1); - RF_ASSERT(termNode->numAntecedents == 1); - RF_ASSERT(termNode->numSuccedents == 0); - commitNode->succedents[0] = termNode; - termNode->antecedents[0] = commitNode; - termNode->antType[0] = rf_control; - } - else { - /* connecting a nonredundant write DAG */ - /* connect the block node to the commit node */ - RF_ASSERT(blockNode->numSuccedents == 1); - RF_ASSERT(commitNode->numAntecedents == 1); - blockNode->succedents[0] = commitNode; - commitNode->antecedents[0] = blockNode; - commitNode->antType[0] = rf_control; - - RF_ASSERT(commitNode->numSuccedents == n); - RF_ASSERT(termNode->numAntecedents == n); - RF_ASSERT(termNode->numSuccedents == 0); - 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; - - /* connect each write node to the term node */ - RF_ASSERT(diskNodes[i].numSuccedents == 1); - diskNodes[i].succedents[0] = termNode; - termNode->antecedents[i] = &diskNodes[i]; - termNode->antType[i] = rf_control; - } - } + RF_DagNode_t *nodes, *diskNodes, *blockNode, *commitNode, *termNode; + RF_PhysDiskAddr_t *pda = asmap->physInfo; + int (*doFunc) (RF_DagNode_t *), (*undoFunc) (RF_DagNode_t *); + int i, n, totalNumNodes; + char *name; + + n = asmap->numStripeUnitsAccessed; + dag_h->creator = "NonredundantDAG"; + + RF_ASSERT(RF_IO_IS_R_OR_W(type)); + switch (type) { + case RF_IO_TYPE_READ: + doFunc = rf_DiskReadFunc; + undoFunc = rf_DiskReadUndoFunc; + name = "R "; + if (rf_dagDebug) + printf("[Creating non-redundant read DAG]\n"); + break; + case RF_IO_TYPE_WRITE: + doFunc = rf_DiskWriteFunc; + undoFunc = rf_DiskWriteUndoFunc; + name = "W "; + if (rf_dagDebug) + printf("[Creating non-redundant write DAG]\n"); + break; + default: + RF_PANIC(); + } + + /* + * For reads, the dag can not commit until the block node is reached. + * for writes, the dag commits immediately. + */ + dag_h->numCommitNodes = 1; + dag_h->numCommits = 0; + dag_h->numSuccedents = 1; + + /* + * Node count: + * 1 block node + * n data reads (or writes) + * 1 commit node + * 1 terminator node + */ + RF_ASSERT(n > 0); + totalNumNodes = n + 3; + RF_CallocAndAdd(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); + + /* initialize nodes */ + switch (type) { + case RF_IO_TYPE_READ: + rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, + NULL, n, 0, 0, 0, dag_h, "Nil", allocList); + rf_InitNode(commitNode, rf_wait, RF_TRUE, rf_NullNodeFunc, rf_NullNodeUndoFunc, + NULL, 1, n, 0, 0, dag_h, "Cmt", allocList); + rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, rf_TerminateUndoFunc, + NULL, 0, 1, 0, 0, dag_h, "Trm", allocList); + break; + case RF_IO_TYPE_WRITE: + rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, + NULL, 1, 0, 0, 0, dag_h, "Nil", allocList); + rf_InitNode(commitNode, rf_wait, RF_TRUE, rf_NullNodeFunc, rf_NullNodeUndoFunc, + NULL, n, 1, 0, 0, dag_h, "Cmt", allocList); + rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, rf_TerminateUndoFunc, + NULL, 0, n, 0, 0, dag_h, "Trm", allocList); + break; + default: + RF_PANIC(); + } + + for (i = 0; i < n; i++) { + RF_ASSERT(pda != NULL); + rf_InitNode(&diskNodes[i], 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; + /* 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, 0, 0); + pda = pda->next; + } + + /* + * Connect nodes. + */ + + /* connect hdr to block node */ + RF_ASSERT(blockNode->numAntecedents == 0); + dag_h->succedents[0] = blockNode; + + if (type == RF_IO_TYPE_READ) { + /* connecting a nonredundant read DAG */ + RF_ASSERT(blockNode->numSuccedents == n); + RF_ASSERT(commitNode->numAntecedents == n); + 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; + + /* connect each read node to the commit node */ + RF_ASSERT(diskNodes[i].numSuccedents == 1); + diskNodes[i].succedents[0] = commitNode; + commitNode->antecedents[i] = &diskNodes[i]; + commitNode->antType[i] = rf_control; + } + /* connect the commit node to the term node */ + RF_ASSERT(commitNode->numSuccedents == 1); + RF_ASSERT(termNode->numAntecedents == 1); + RF_ASSERT(termNode->numSuccedents == 0); + commitNode->succedents[0] = termNode; + termNode->antecedents[0] = commitNode; + termNode->antType[0] = rf_control; + } else { + /* connecting a nonredundant write DAG */ + /* connect the block node to the commit node */ + RF_ASSERT(blockNode->numSuccedents == 1); + RF_ASSERT(commitNode->numAntecedents == 1); + blockNode->succedents[0] = commitNode; + commitNode->antecedents[0] = blockNode; + commitNode->antType[0] = rf_control; + + RF_ASSERT(commitNode->numSuccedents == n); + RF_ASSERT(termNode->numAntecedents == n); + RF_ASSERT(termNode->numSuccedents == 0); + 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; + + /* connect each write node to the term node */ + RF_ASSERT(diskNodes[i].numSuccedents == 1); + diskNodes[i].succedents[0] = termNode; + termNode->antecedents[i] = &diskNodes[i]; + termNode->antType[i] = rf_control; + } + } } - /****************************************************************************** * Create a fault-free read DAG for RAID level 1 * @@ -366,135 +300,141 @@ void rf_CreateNonredundantDAG( * Parameters: raidPtr - description of the physical array * asmap - logical & physical addresses for this access * bp - buffer ptr (for holding read data) - * flags - general flags (e.g. disk locking) + * flags - general flags (e.g. disk locking) * allocList - list of memory allocated in DAG creation *****************************************************************************/ -static void CreateMirrorReadDAG( - RF_Raid_t *raidPtr, - RF_AccessStripeMap_t *asmap, - RF_DagHeader_t *dag_h, - void *bp, - RF_RaidAccessFlags_t flags, - RF_AllocListElem_t *allocList, - int (*readfunc)(RF_DagNode_t *node)) +static void +CreateMirrorReadDAG( + RF_Raid_t * raidPtr, + RF_AccessStripeMap_t * asmap, + RF_DagHeader_t * dag_h, + void *bp, + RF_RaidAccessFlags_t flags, + RF_AllocListElem_t * allocList, + int (*readfunc) (RF_DagNode_t * node)) { - RF_DagNode_t *readNodes, *nodes, *blockNode, *commitNode, *termNode; - RF_PhysDiskAddr_t *data_pda = asmap->physInfo; - RF_PhysDiskAddr_t *parity_pda = asmap->parityInfo; - int i, n, totalNumNodes; - - n = asmap->numStripeUnitsAccessed; - dag_h->creator = "RaidOneReadDAG"; - if (rf_dagDebug) { - printf("[Creating RAID level 1 read DAG]\n"); - } - - /* - * This dag can not commit until the commit node is reached - * errors prior to the commit point imply the dag has failed. - */ - dag_h->numCommitNodes = 1; - dag_h->numCommits = 0; - dag_h->numSuccedents = 1; - - /* - * Node count: - * n data reads - * 1 block node - * 1 commit node - * 1 terminator node - */ - RF_ASSERT(n > 0); - totalNumNodes = n + 3; - RF_CallocAndAdd(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); - - /* initialize nodes */ - rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, - rf_NullNodeUndoFunc, NULL, n, 0, 0, 0, dag_h, "Nil", allocList); - rf_InitNode(commitNode, rf_wait, RF_TRUE, rf_NullNodeFunc, - rf_NullNodeUndoFunc, NULL, 1, n, 0, 0, dag_h, "Cmt", allocList); - rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, - rf_TerminateUndoFunc, NULL, 0, 1, 0, 0, dag_h, "Trm", allocList); - - 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_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; - /* 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, 0, 0); - readNodes[i].params[4].p = parity_pda; - data_pda = data_pda->next; - parity_pda = parity_pda->next; - } - - /* - * Connect nodes - */ - - /* connect hdr to block node */ - RF_ASSERT(blockNode->numAntecedents == 0); - dag_h->succedents[0] = blockNode; - - /* connect block node to read nodes */ - RF_ASSERT(blockNode->numSuccedents == n); - 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; - } - - /* connect read nodes to commit node */ - RF_ASSERT(commitNode->numAntecedents == n); - for (i=0; i < n; i++) { - RF_ASSERT(readNodes[i].numSuccedents == 1); - readNodes[i].succedents[0] = commitNode; - commitNode->antecedents[i] = &readNodes[i]; - commitNode->antType[i] = rf_control; - } - - /* connect commit node to term node */ - RF_ASSERT(commitNode->numSuccedents == 1); - RF_ASSERT(termNode->numAntecedents == 1); - RF_ASSERT(termNode->numSuccedents == 0); - commitNode->succedents[0] = termNode; - termNode->antecedents[0] = commitNode; - termNode->antType[0] = rf_control; + RF_DagNode_t *readNodes, *nodes, *blockNode, *commitNode, *termNode; + RF_PhysDiskAddr_t *data_pda = asmap->physInfo; + RF_PhysDiskAddr_t *parity_pda = asmap->parityInfo; + int i, n, totalNumNodes; + + n = asmap->numStripeUnitsAccessed; + dag_h->creator = "RaidOneReadDAG"; + if (rf_dagDebug) { + printf("[Creating RAID level 1 read DAG]\n"); + } + /* + * This dag can not commit until the commit node is reached + * errors prior to the commit point imply the dag has failed. + */ + dag_h->numCommitNodes = 1; + dag_h->numCommits = 0; + dag_h->numSuccedents = 1; + + /* + * Node count: + * n data reads + * 1 block node + * 1 commit node + * 1 terminator node + */ + RF_ASSERT(n > 0); + totalNumNodes = n + 3; + RF_CallocAndAdd(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); + + /* initialize nodes */ + rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, + rf_NullNodeUndoFunc, NULL, n, 0, 0, 0, dag_h, "Nil", allocList); + rf_InitNode(commitNode, rf_wait, RF_TRUE, rf_NullNodeFunc, + rf_NullNodeUndoFunc, NULL, 1, n, 0, 0, dag_h, "Cmt", allocList); + rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, + rf_TerminateUndoFunc, NULL, 0, 1, 0, 0, dag_h, "Trm", allocList); + + 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_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; + /* 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, 0, 0); + readNodes[i].params[4].p = parity_pda; + data_pda = data_pda->next; + parity_pda = parity_pda->next; + } + + /* + * Connect nodes + */ + + /* connect hdr to block node */ + RF_ASSERT(blockNode->numAntecedents == 0); + dag_h->succedents[0] = blockNode; + + /* connect block node to read nodes */ + RF_ASSERT(blockNode->numSuccedents == n); + 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; + } + + /* connect read nodes to commit node */ + RF_ASSERT(commitNode->numAntecedents == n); + for (i = 0; i < n; i++) { + RF_ASSERT(readNodes[i].numSuccedents == 1); + readNodes[i].succedents[0] = commitNode; + commitNode->antecedents[i] = &readNodes[i]; + commitNode->antType[i] = rf_control; + } + + /* connect commit node to term node */ + RF_ASSERT(commitNode->numSuccedents == 1); + RF_ASSERT(termNode->numAntecedents == 1); + RF_ASSERT(termNode->numSuccedents == 0); + commitNode->succedents[0] = termNode; + termNode->antecedents[0] = commitNode; + termNode->antType[0] = rf_control; } -void rf_CreateMirrorIdleReadDAG( - RF_Raid_t *raidPtr, - RF_AccessStripeMap_t *asmap, - RF_DagHeader_t *dag_h, - void *bp, - RF_RaidAccessFlags_t flags, - RF_AllocListElem_t *allocList) +void +rf_CreateMirrorIdleReadDAG( + RF_Raid_t * raidPtr, + RF_AccessStripeMap_t * asmap, + RF_DagHeader_t * dag_h, + void *bp, + RF_RaidAccessFlags_t flags, + RF_AllocListElem_t * allocList) { - CreateMirrorReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, - rf_DiskReadMirrorIdleFunc); + CreateMirrorReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, + rf_DiskReadMirrorIdleFunc); } -void rf_CreateMirrorPartitionReadDAG( - RF_Raid_t *raidPtr, - RF_AccessStripeMap_t *asmap, - RF_DagHeader_t *dag_h, - void *bp, - RF_RaidAccessFlags_t flags, - RF_AllocListElem_t *allocList) +void +rf_CreateMirrorPartitionReadDAG( + RF_Raid_t * raidPtr, + RF_AccessStripeMap_t * asmap, + RF_DagHeader_t * dag_h, + void *bp, + RF_RaidAccessFlags_t flags, + RF_AllocListElem_t * allocList) { - CreateMirrorReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, - rf_DiskReadMirrorPartitionFunc); + CreateMirrorReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, + rf_DiskReadMirrorPartitionFunc); } |