📄 rf_driver.c
字号:
* Revision 1.46.50.2 1995/06/21 17:48:30 robby * test * * Revision 1.46.50.1 1995/06/21 17:34:49 robby * branching to work on "meta-dag" capabilities * * Revision 1.46.10.5 1995/07/03 21:58:34 holland * added support for suppressing both stripe locks & large writes * * Revision 1.46.10.4 1995/06/27 03:42:48 holland * typo fix * * Revision 1.46.10.3 1995/06/27 03:31:42 holland * prototypes * * Revision 1.46.10.2 1995/06/27 03:17:57 holland * fixed callback bug in kernel rf_DoAccess * * Revision 1.46.10.1 1995/06/25 14:32:44 holland * initial checkin on new branch * * Revision 1.46 1995/06/13 17:52:41 holland * added UserStats stuff * * Revision 1.45 1995/06/13 16:03:41 rachad * *** empty log message *** * * Revision 1.44 1995/06/12 15:54:40 rachad * Added garbege collection for log structured storage * * Revision 1.43 1995/06/09 18:01:09 holland * various changes related to in-kernel recon, multiple-row arrays, * trace extraction from kernel, etc. * * Revision 1.42 1995/06/08 19:52:28 rachad * *** empty log message *** * * Revision 1.41 1995/06/08 00:11:49 robby * added a debug variable -- showVirtualSizeRequirements * * Revision 1.40 1995/06/05 00:33:30 holland * protectedSectors bug fix * * Revision 1.39 1995/06/01 22:45:03 holland * made compilation of parity logging and virtual striping * stuff conditional on some constants defined in rf_archs.h * * Revision 1.38 1995/06/01 21:52:37 holland * replaced NULL sizes in calls to Free() by -1, and caused this * to suppress the size-mismatch error * * Revision 1.37 1995/05/26 20:04:54 wvcii * modified parity logging debug vars * * Revision 1.36 95/05/21 15:32:41 wvcii * added debug vars: parityLogDebug, numParityRegions, numParityLogs, * numReintegrationThreads * * Revision 1.35 95/05/19 20:58:21 holland * cleanups on error cases in rf_DoAccess * * Revision 1.34 1995/05/16 17:35:53 holland * added rf_copyback_in_progress. this is debug-only. * * Revision 1.33 1995/05/15 12:25:35 holland * bug fix in test code: no stripe locks were getting acquired in RAID0 mode * * Revision 1.32 1995/05/10 18:54:12 holland * bug fixes related to deadlock problem at time of disk failure * eliminated read-op-write code * beefed up parity checking in loop test * various small changes & new ASSERTs * * Revision 1.31 1995/05/02 22:49:02 holland * add shutdown calls for each architecture * * Revision 1.30 1995/05/01 14:43:37 holland * merged changes from Bill * * Revision 1.29 1995/05/01 13:28:00 holland * parity range locks, locking disk requests, recon+parityscan in kernel, etc. * * Revision 1.28 1995/04/24 13:25:51 holland * rewrite to move disk queues, recon, & atomic RMW to kernel * * Revision 1.27 1995/04/06 14:47:56 rachad * merge completed * * Revision 1.26 1995/04/03 20:32:35 rachad * added reconstruction to simulator * * Revision 1.25.10.2 1995/04/03 20:41:00 holland * misc changes related to distributed sparing * * Revision 1.25.10.1 1995/03/17 20:04:01 holland * initial checkin on new branch * * Revision 1.25 1995/03/15 20:34:30 holland * changes for distributed sparing. * * Revision 1.24 1995/03/09 19:53:05 rachad * *** empty log message *** * * Revision 1.23 1995/03/03 18:36:16 rachad * Simulator mechanism added * * Revision 1.22 1995/03/01 20:25:48 holland * kernelization changes * * Revision 1.21 1995/02/17 19:39:56 holland * added size param to all calls to Free(). * this is ignored at user level, but necessary in the kernel. * * Revision 1.20 1995/02/17 13:37:49 holland * kernelization changes -- not yet complete * * Revision 1.19 1995/02/10 18:08:07 holland * fixed a few things I broke during kernelization * * Revision 1.18 1995/02/10 17:34:10 holland * kernelization changes * * Revision 1.17 1995/02/04 15:51:35 holland * kernelization changes * * Revision 1.16 1995/02/03 22:31:36 holland * many changes related to kernelization * * Revision 1.15 1995/02/01 15:13:05 holland * moved #include of general.h out of raid.h and into each file * * Revision 1.14 1995/02/01 14:25:19 holland * began changes for kernelization: * changed all instances of mutex_t and cond_t to DECLARE macros * converted configuration code to use config structure * * Revision 1.13 1995/01/30 14:53:46 holland * extensive changes related to making DoIO non-blocking * * Revision 1.12 1995/01/25 00:26:21 holland * eliminated support for aio * * Revision 1.11 1995/01/24 23:58:46 holland * multi-way recon XOR, plus various small changes * * Revision 1.10 1995/01/11 19:27:02 holland * various changes related to performance tuning * * Revision 1.9 1994/12/05 15:29:09 holland * added trace run time limitation (maxTraceRunTimeSec) * * Revision 1.8 1994/12/05 04:18:12 holland * various new control vars in the config file * * Revision 1.7 1994/11/29 23:11:36 holland * tracerec bug on dag retry fixed * * Revision 1.6 1994/11/29 22:11:38 danner * holland updates * * Revision 1.5 1994/11/29 21:09:47 danner * Detailed tracing support (holland). * * Revision 1.4 1994/11/29 20:36:02 danner * Added suppressAtomicRMW option. * * Revision 1.3 1994/11/21 15:34:06 danner * Added ConfigureAllocList() call. * */#ifdef KERNEL#include <dkusage.h>#include <dfstrace.h>#endif /* KERNEL */#include "rf_archs.h"#include "rf_threadstuff.h"#ifndef KERNEL#include <stdio.h>#include <stdlib.h>#endif /* KERNEL */#include <sys/errno.h>#include "rf_raid.h"#include "rf_dag.h"#include "rf_aselect.h"#include "rf_diskqueue.h"#include "rf_parityscan.h"#include "rf_alloclist.h"#include "rf_threadid.h"#include "rf_dagutils.h"#include "rf_utils.h"#include "rf_etimer.h"#include "rf_acctrace.h"#include "rf_configure.h"#include "rf_general.h"#include "rf_desc.h"#include "rf_states.h"#include "rf_freelist.h"#include "rf_decluster.h"#include "rf_map.h"#include "rf_diskthreads.h"#include "rf_revent.h"#include "rf_callback.h"#include "rf_engine.h"#include "rf_memchunk.h"#include "rf_mcpair.h"#include "rf_nwayxor.h"#include "rf_debugprint.h"#include "rf_copyback.h"#include "rf_camlayer.h"#include "rf_driver.h"#include "rf_options.h"#include "rf_shutdown.h"#include "rf_sys.h"#include "rf_cpuutil.h"#ifdef SIMULATE#include "rf_diskevent.h"#endif /* SIMULATE */#ifdef KERNEL#include <sys/buf.h>#include <io/common/devdriver.h>#if DFSTRACE > 0#include <sys/dfs_log.h>#include <sys/dfstracebuf.h>#endif /* DFSTRACE > 0 */#if DKUSAGE > 0#include <sys/dkusage.h>#include <io/common/iotypes.h>#include <io/cam/dec_cam.h>#include <io/cam/cam.h>#include <io/cam/pdrv.h>#endif /* DKUSAGE > 0 */#endif /* KERNEL */#if RF_DEMO > 0#include "rf_demo.h"#endif /* RF_DEMO > 0 *//* rad == RF_RaidAccessDesc_t */static RF_FreeList_t *rf_rad_freelist;#define RF_MAX_FREE_RAD 128#define RF_RAD_INC 16#define RF_RAD_INITIAL 32/* debug variables */char rf_panicbuf[2048]; /* a buffer to hold an error msg when we panic */ /* main configuration routines */static int raidframe_booted = 0;static void rf_ConfigureDebug(RF_Config_t *cfgPtr);static void set_debug_option(char *name, long val);RF_DECLARE_MUTEX(rf_printf_mutex) /* debug only: avoids interleaved printfs by different stripes */RF_DECLARE_GLOBAL_THREADID /* declarations for threadid.h */#if !defined(KERNEL) && !defined(SIMULATE)static int rf_InitThroughputStats(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr, RF_Config_t *cfgPtr);static void rf_StopThroughputStats(RF_Raid_t *raidPtr);static void rf_PrintThroughputStats(RF_Raid_t *raidPtr);#endif /* !KERNEL && !SIMULATE */#ifdef KERNEL#define SIGNAL_QUIESCENT_COND(_raid_) wakeup(&((_raid_)->accesses_suspended))#define WAIT_FOR_QUIESCENCE(_raid_) \ mpsleep(&((_raid_)->accesses_suspended), PZERO, "raidframe quiesce", 0, \ (void *) simple_lock_addr((_raid_)->access_suspend_mutex), MS_LOCK_SIMPLE)#define IO_BUF_ERR(bp, err, unit) { \ bp->b_flags |= B_ERROR; \ bp->b_resid = bp->b_bcount; \ bp->b_error = err; \ RF_DKU_END_IO(unit, bp); \ biodone(bp); \}#else /* KERNEL */#define SIGNAL_QUIESCENT_COND(_raid_) RF_SIGNAL_COND((_raid_)->quiescent_cond)#define WAIT_FOR_QUIESCENCE(_raid_) RF_WAIT_COND((_raid_)->quiescent_cond, (_raid_)->access_suspend_mutex)#define IO_BUF_ERR(bp, err, unit)#endif /* KERNEL */static int configureCount=0; /* number of active configurations */static int isconfigged=0; /* is basic raidframe (non per-array) stuff configged */RF_DECLARE_STATIC_MUTEX(configureMutex) /* used to lock the configuration stuff */static RF_ShutdownList_t *globalShutdown; /* non array-specific stuff */static int rf_ConfigureRDFreeList(RF_ShutdownList_t **listp);/* called at system boot time */int rf_BootRaidframe(){ long stacksize; int rc; if (raidframe_booted) return(EBUSY); raidframe_booted = 1;#if RF_DEBUG_ATOMIC > 0 rf_atent_init();#endif /* RF_DEBUG_ATOMIC > 0 */ rf_setup_threadid(); rf_assign_threadid();#if !defined(KERNEL) && !defined(SIMULATE) if (RF_THREAD_ATTR_CREATE(raidframe_attr_default)) { fprintf(stderr, "Unable to create default thread attr\n"); exit(1); }#if 0 stacksize = RF_THREAD_ATTR_GETSTACKSIZE(raidframe_attr_default); if (stacksize < 0) { fprintf(stderr, "Unable to get stack size of default thread attr\n"); exit(1); } stacksize += 16384; rc = RF_THREAD_ATTR_SETSTACKSIZE(raidframe_attr_default, stacksize); if (rc) { fprintf(stderr, "Unable to set stack size of default thread attr\n"); exit(1); }#endif /* 0 */#endif /* !KERNEL && !SIMULATE */ rc = rf_mutex_init(&configureMutex); if (rc) { RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, __LINE__, rc); RF_PANIC(); } configureCount = 0; isconfigged = 0; globalShutdown = NULL; return(0);}/* * This function is really just for debugging user-level stuff: it * frees up all memory, other RAIDframe resources which might otherwise * be kept around. This is used with systems like "sentinel" to detect * memory leaks. */int rf_UnbootRaidframe(){ int rc; RF_LOCK_MUTEX(configureMutex); if (configureCount) { RF_UNLOCK_MUTEX(configureMutex); return(EBUSY); } raidframe_booted = 0; RF_UNLOCK_MUTEX(configureMutex); rc = rf_mutex_destroy(&configureMutex); if (rc) { RF_ERRORMSG3("Unable to destroy mutex file %s line %d rc=%d\n", __FILE__, __LINE__, rc); RF_PANIC(); }#if RF_DEBUG_ATOMIC > 0 rf_atent_shutdown();#endif /* RF_DEBUG_ATOMIC > 0 */ return(0);}/* * Called whenever an array is shutdown */static void rf_UnconfigureArray(){ int rc; RF_LOCK_MUTEX(configureMutex); if (--configureCount == 0) { /* if no active configurations, shut everything down */ isconfigged = 0; rc = rf_ShutdownList(&globalShutdown); if (rc) { RF_ERRORMSG1("RAIDFRAME: unable to do global shutdown, rc=%d\n", rc); } rf_shutdown_threadid(); /* * We must wait until now, because the AllocList module * uses the DebugMem module. */ if (rf_memDebug) rf_print_unfreed(); } RF_UNLOCK_MUTEX(configureMutex);}/* * Called to shut down an array. */int rf_Shutdown(raidPtr) RF_Raid_t *raidPtr;{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -