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

📄 rf_dagfuncs.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Mark Holland, William V. Courtright II * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU *  School of Computer Science *  Carnegie Mellon University *  Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. *//* * dagfuncs.c -- DAG node execution routines * * Rules: * 1. Every DAG execution function must eventually cause node->status to *    get set to "good" or "bad", and "FinishNode" to be called. In the *    case of nodes that complete immediately (xor, NullNodeFunc, etc), *    the node execution function can do these two things directly. In *    the case of nodes that have to wait for some event (a disk read to *    complete, a lock to be released, etc) to occur before they can *    complete, this is typically achieved by having whatever module *    is doing the operation call GenericWakeupFunc upon completion. * 2. DAG execution functions should check the status in the DAG header *    and NOP out their operations if the status is not "enable". However, *    execution functions that release resources must be sure to release *    them even when they NOP out the function that would use them. *    Functions that acquire resources should go ahead and acquire them *    even when they NOP, so that a downstream release node will not have *    to check to find out whether or not the acquire was suppressed. *//* $Locker:  $ * $Log: rf_dagfuncs.c,v $ * Revision 1.64  1996/07/31  16:29:26  jimz * LONGSHIFT -> RF_LONGSHIFT, defined in rf_types.h * * Revision 1.63  1996/07/30  04:00:20  jimz * define LONGSHIFT for mips * * Revision 1.62  1996/07/28  20:31:39  jimz * i386netbsd port * true/false fixup * * Revision 1.61  1996/07/27  23:36:08  jimz * Solaris port of simulator * * Revision 1.60  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.59  1996/07/18  22:57:14  jimz * port simulator to AIX * * Revision 1.58  1996/07/17  21:00:58  jimz * clean up timer interface, tracing * * Revision 1.57  1996/07/15  17:22:18  jimz * nit-pick code cleanup * resolve stdlib problems on DEC OSF * * Revision 1.56  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.55  1996/06/10  22:23:18  wvcii * disk and xor funcs now optionally support undo logging * for backward error recovery experiments * * Revision 1.54  1996/06/10  11:55:47  jimz * Straightened out some per-array/not-per-array distinctions, fixed * a couple bugs related to confusion. Added shutdown lists. Removed * layout shutdown function (now subsumed by shutdown lists). * * Revision 1.53  1996/06/07  21:33:04  jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.52  1996/06/06  17:28:44  jimz * add new read mirror partition func, rename old read mirror * to rf_DiskReadMirrorIdleFunc * * Revision 1.51  1996/06/03  23:28:26  jimz * more bugfixes * check in tree to sync for IPDS runs with current bugfixes * there still may be a problem with threads in the script test * getting I/Os stuck- not trivially reproducible (runs ~50 times * in a row without getting stuck) * * Revision 1.50  1996/06/02  17:31:48  jimz * Moved a lot of global stuff into array structure, where it belongs. * Fixed up paritylogging, pss modules in this manner. Some general * code cleanup. Removed lots of dead code, some dead files. * * Revision 1.49  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.48  1996/05/30  12:59:18  jimz * make etimer happier, more portable * * Revision 1.47  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.46  1996/05/24  22:17:04  jimz * continue code + namespace cleanup * typed a bunch of flags * * Revision 1.45  1996/05/24  04:28:55  jimz * release cleanup ckpt * * Revision 1.44  1996/05/23  21:46:35  jimz * checkpoint in code cleanup (release prep) * lots of types, function names have been fixed * * Revision 1.43  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.42  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.41  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.40  1996/05/08  15:24:14  wvcii * modified GenericWakeupFunc to use recover, undone, and panic node states * * Revision 1.39  1996/05/02  17:18:01  jimz * fix up headers for user-land, following ccmn cleanup * * Revision 1.38  1996/05/01  16:26:51  jimz * don't include rf_ccmn.h (get ready to phase out) * * Revision 1.37  1995/12/12  18:10:06  jimz * MIN -> RF_MIN, MAX -> RF_MAX, ASSERT -> RF_ASSERT * fix 80-column brain damage in comments * * Revision 1.36  1995/12/04  19:19:09  wvcii * modified DiskReadMirrorFunc *  - added fifth parameter, physical disk address of mirror copy *  - SelectIdleDisk conditionally swaps parameters 0 & 4 * * Revision 1.35  1995/12/01  15:58:33  root * added copyright info * * Revision 1.34  1995/11/17  18:12:17  amiri * Changed DiskReadMirrorFunc to use the generic mapping routines * to find the mirror of the data, function was assuming RAID level 1. * * Revision 1.33  1995/11/17  15:15:59  wvcii * changes in DiskReadMirrorFunc *   - added ASSERTs *   - added call to MapParityRAID1 * * Revision 1.32  1995/11/07  16:25:50  wvcii * added DiskUnlockFuncForThreads * general debugging of undo functions (first time they were used) * * Revision 1.31  1995/09/06  19:23:36  wvcii * fixed tracing for parity logging nodes * * Revision 1.30  95/07/07  00:13:01  wvcii * added 4th parameter to ParityLogAppend *  */#ifndef KERNEL#include <errno.h>#endif /* !KERNEL */#include <sys/ioctl.h>#include <sys/param.h>#include "rf_archs.h"#include "rf_raid.h"#include "rf_dag.h"#include "rf_layout.h"#include "rf_etimer.h"#include "rf_acctrace.h"#include "rf_diskqueue.h"#include "rf_dagfuncs.h"#include "rf_general.h"#include "rf_engine.h"#include "rf_dagutils.h"#ifdef KERNEL#include "rf_kintf.h"#endif /* KERNEL */#if RF_INCLUDE_PARITYLOGGING > 0#include "rf_paritylog.h"#endif /* RF_INCLUDE_PARITYLOGGING > 0 */int (*rf_DiskReadFunc)(), (*rf_DiskWriteFunc)();int (*rf_DiskReadUndoFunc)(), (*rf_DiskWriteUndoFunc)();int (*rf_DiskUnlockFunc)(), (*rf_DiskUnlockUndoFunc)();int (*rf_RegularXorUndoFunc)();int (*rf_SimpleXorUndoFunc)();int (*rf_RecoveryXorUndoFunc)();/***************************************************************************************** * main (only) configuration routine for this module ****************************************************************************************/int rf_ConfigureDAGFuncs(listp)  RF_ShutdownList_t  **listp;{  RF_ASSERT( ((sizeof(long)==8) && RF_LONGSHIFT==3) || ((sizeof(long)==4)  && RF_LONGSHIFT==2) );  rf_DiskReadFunc  = rf_DiskReadFuncForThreads;  rf_DiskReadUndoFunc = rf_DiskUndoFunc;  rf_DiskWriteFunc = rf_DiskWriteFuncForThreads;  rf_DiskWriteUndoFunc = rf_DiskUndoFunc;  rf_DiskUnlockFunc = rf_DiskUnlockFuncForThreads;  rf_DiskUnlockUndoFunc = rf_NullNodeUndoFunc;  rf_RegularXorUndoFunc = rf_NullNodeUndoFunc;  rf_SimpleXorUndoFunc = rf_NullNodeUndoFunc;  rf_RecoveryXorUndoFunc = rf_NullNodeUndoFunc;  return(0);}/***************************************************************************************** * the execution function associated with a terminate node ****************************************************************************************/int rf_TerminateFunc(node)  RF_DagNode_t  *node;{  RF_ASSERT(node->dagHdr->numCommits == node->dagHdr->numCommitNodes);  node->status = rf_good;  return(rf_FinishNode(node, RF_THREAD_CONTEXT));}int rf_TerminateUndoFunc(node)  RF_DagNode_t  *node;{  return(0);}/***************************************************************************************** * execution functions associated with a mirror node * * parameters: * * 0 - physical disk addres of data * 1 - buffer for holding read data * 2 - parity stripe ID * 3 - flags * 4 - physical disk address of mirror (parity) * ****************************************************************************************/int rf_DiskReadMirrorIdleFunc(node)  RF_DagNode_t  *node;{  /* select the mirror copy with the shortest queue and fill in node parameters     with physical disk address */  rf_SelectMirrorDiskIdle(node);  return(rf_DiskReadFunc(node));}int rf_DiskReadMirrorPartitionFunc(node)  RF_DagNode_t  *node;{  /* select the mirror copy with the shortest queue and fill in node parameters     with physical disk address */  rf_SelectMirrorDiskPartition(node);  return(rf_DiskReadFunc(node));}int rf_DiskReadMirrorUndoFunc(node)  RF_DagNode_t  *node;{  return(0);}#if RF_INCLUDE_PARITYLOGGING > 0/***************************************************************************************** * the execution function associated with a parity log update node ****************************************************************************************/int rf_ParityLogUpdateFunc(node)  RF_DagNode_t  *node;{  RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;  caddr_t buf = (caddr_t) node->params[1].p;  RF_ParityLogData_t *logData;  RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;  RF_Etimer_t timer;  if (node->dagHdr->status == rf_enable)    {      RF_ETIMER_START(timer);      logData = rf_CreateParityLogData(RF_UPDATE, pda, buf, (RF_Raid_t *) (node->dagHdr->raidPtr),				    node->wakeFunc, (void *) node, node->dagHdr->tracerec, timer);      if (logData)

⌨️ 快捷键说明

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