⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf_dagffwr.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Mark Holland, Daniel Stodolsky, William V. Courtright II * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU *  School of Computer Science *  Carnegie Mellon University *  Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. *//* * rf_dagff.c * * code for creating fault-free DAGs * * $Locker:  $ * $Log: rf_dagffwr.c,v $ * Revision 1.19  1996/07/31  15:35:24  jimz * evenodd changes; bugfixes for double-degraded archs, generalize * some formerly PQ-only functions * * Revision 1.18  1996/07/28  20:31:39  jimz * i386netbsd port * true/false fixup * * Revision 1.17  1996/07/27  18:40:24  jimz * cleanup sweep * * Revision 1.16  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.15  1996/06/11  01:27:50  jimz * Fixed bug where diskthread shutdown would crash or hang. This * turned out to be two distinct bugs: * (1) [crash] The thread shutdown code wasn't properly waiting for * all the diskthreads to complete. This caused diskthreads that were * exiting+cleaning up to unlock a destroyed mutex. * (2) [hang] TerminateDiskQueues wasn't locking, and DiskIODequeue * only checked for termination _after_ a wakeup if the queues were * empty. This was a race where the termination wakeup could be lost * by the dequeueing thread, and the system would hang waiting for the * thread to exit, while the thread waited for an I/O or a signal to * check the termination flag. * * Revision 1.14  1996/06/10  22:24:01  wvcii * added write dags which do not have a commit node and are * used in forward and backward error recovery experiments. * * Revision 1.13  1996/06/07  22:26:27  jimz * type-ify which_ru (RF_ReconUnitNum_t) * * Revision 1.12  1996/06/07  21:33:04  jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.11  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.10  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.9  1996/05/27  18:56:37  jimz * more code cleanup * better typing * compiles in all 3 environments * * Revision 1.8  1996/05/24  22:17:04  jimz * continue code + namespace cleanup * typed a bunch of flags * * Revision 1.7  1996/05/24  04:28:55  jimz * release cleanup ckpt * * Revision 1.6  1996/05/23  21:46:35  jimz * checkpoint in code cleanup (release prep) * lots of types, function names have been fixed * * Revision 1.5  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.4  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.3  1996/05/15  23:23:12  wvcii * fixed bug in small write read old q node succedent initialization * * 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:20:45  wvcii * Initial revision * */#include "rf_types.h"#include "rf_raid.h"#include "rf_dag.h"#include "rf_dagutils.h"#include "rf_dagfuncs.h"#include "rf_threadid.h"#include "rf_debugMem.h"#include "rf_dagffrd.h"#include "rf_memchunk.h"#include "rf_general.h"#include "rf_dagffwr.h"/****************************************************************************** * * 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 * backward through the graph, executing the undo functions.  Assuming that * each node in the graph prior to the Cmt node are undoable and atomic - or - * does not make changes to permanent state, the graph will fail atomically. * If an error occurs after the Cmt node executes, the engine will roll-forward * through the graph, blindly executing nodes until it reaches the end. * If a graph reaches the end, it is assumed to have completed successfully. * * A graph has only 1 Cmt node. * *//****************************************************************************** * * The following wrappers map the standard DAG creation interface to the * DAG creation routines.  Additionally, these wrappers enable experimentation * with new DAG structures by providing an extra level of indirection, allowing * the DAG creation routines to be replaced at this single point. */void rf_CreateNonRedundantWriteDAG(  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_CreateNonredundantDAG(raidPtr, asmap, dag_h, bp, flags, allocList,    RF_IO_TYPE_WRITE);}void rf_CreateRAID0WriteDAG(  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_CreateNonredundantDAG(raidPtr, asmap, dag_h, bp, flags, allocList,    RF_IO_TYPE_WRITE);}void rf_CreateSmallWriteDAG(  RF_Raid_t             *raidPtr,  RF_AccessStripeMap_t  *asmap,  RF_DagHeader_t        *dag_h,  void                  *bp,  RF_RaidAccessFlags_t   flags,  RF_AllocListElem_t    *allocList){#if RF_FORWARD > 0  rf_CommonCreateSmallWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,    &rf_xorFuncs, NULL);#else /* RF_FORWARD > 0 */#if RF_BACKWARD > 0  rf_CommonCreateSmallWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,    &rf_xorFuncs, NULL);#else /* RF_BACKWARD > 0 */  /* "normal" rollaway */  rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,    &rf_xorFuncs, NULL);#endif /* RF_BACKWARD > 0 */#endif /* RF_FORWARD > 0 */}void rf_CreateLargeWriteDAG(  RF_Raid_t             *raidPtr,  RF_AccessStripeMap_t  *asmap,  RF_DagHeader_t        *dag_h,  void                  *bp,  RF_RaidAccessFlags_t   flags,  RF_AllocListElem_t    *allocList){#if RF_FORWARD > 0  rf_CommonCreateLargeWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,    1, rf_RegularXorFunc, RF_TRUE);#else /* RF_FORWARD > 0 */#if RF_BACKWARD > 0  rf_CommonCreateLargeWriteDAGFwd(raidPtr, asmap, dag_h, bp, flags, allocList,    1, rf_RegularXorFunc, RF_TRUE);#else /* RF_BACKWARD > 0 */  /* "normal" rollaway */  rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,    1, rf_RegularXorFunc, RF_TRUE);#endif /* RF_BACKWARD > 0 */#endif /* RF_FORWARD > 0 */}/****************************************************************************** * * DAG creation code begins here *//****************************************************************************** * * creates a DAG to perform a large-write operation: * *           / Rod \           / Wnd \ * H -- block- Rod - Xor - Cmt - Wnd --- T *           \ Rod /          \  Wnp / *                             \[Wnq]/ * * The XOR node also does the Q calculation in the P+Q architecture. * All nodes are before the commit node (Cmt) are assumed to be atomic and * undoable - or - they make no changes to permanent state. * * Rod = read old data * Cmt = commit node * Wnp = write new parity * Wnd = write new data * Wnq = write new "q" * [] denotes optional segments in the graph * * Parameters:  raidPtr   - description of the physical array *              asmap     - logical & physical addresses for this access *              bp        - buffer ptr (holds write data) *              flags     - general flags (e.g. disk locking)  *              allocList - list of memory allocated in DAG creation *              nfaults   - number of faults array can tolerate *                          (equal to # redundancy units in stripe) *              redfuncs  - list of redundancy generating functions * *****************************************************************************/void rf_CommonCreateLargeWriteDAG(  RF_Raid_t             *raidPtr,  RF_AccessStripeMap_t  *asmap,  RF_DagHeader_t        *dag_h,  void                  *bp,  RF_RaidAccessFlags_t   flags,  RF_AllocListElem_t    *allocList,  int                    nfaults,  int                  (*redFunc)(),  int                    allowBufferRecycle){  RF_DagNode_t *nodes, *wndNodes, *rodNodes, *xorNode, *wnpNode;  RF_DagNode_t *wnqNode, *blockNode, *commitNode, *termNode;  int nWndNodes, nRodNodes, i, nodeNum, asmNum;  RF_AccessStripeMapHeader_t *new_asm_h[2];  RF_StripeNum_t parityStripeID;  char *sosBuffer, *eosBuffer;  RF_ReconUnitNum_t which_ru;  RF_RaidLayout_t *layoutPtr;  RF_PhysDiskAddr_t *pda;  layoutPtr = &(raidPtr->Layout);  parityStripeID = rf_RaidAddressToParityStripeID(layoutPtr, asmap->raidAddress,    &which_ru);  if (rf_dagDebug) {    printf("[Creating large-write DAG]\n");  }  dag_h->creator = "LargeWriteDAG";  dag_h->numCommitNodes = 1;  dag_h->numCommits = 0;  dag_h->numSuccedents = 1;  /* alloc the nodes: Wnd, xor, commit, block, term, and  Wnp */  nWndNodes = asmap->numStripeUnitsAccessed;  RF_CallocAndAdd(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;  if (nfaults == 2) {    wnqNode   = &nodes[i]; i += 1;  }  else {    wnqNode = NULL;  }  rf_MapUnaccessedPortionOfStripe(raidPtr, layoutPtr, asmap, dag_h, new_asm_h,    &nRodNodes, &sosBuffer, &eosBuffer, allocList);  if (nRodNodes > 0) {    RF_CallocAndAdd(rodNodes, nRodNodes, sizeof(RF_DagNode_t),      (RF_DagNode_t *), allocList);  }  else {    rodNodes = NULL;  }  /* begin node initialization */  if (nRodNodes > 0) {    rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc,      NULL, nRodNodes, 0, 0, 0, dag_h, "Nil", allocList);  }  else {    rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -