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

📄 rf_diskthreads.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Mark Holland, Rachad Youssef, Daniel Stodolsky * * 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_diskthreads.c -- thread routines to execute disk requests * **************************************************************//* * $Log: rf_diskthreads.c,v $ * Revision 1.59  1996/08/20  23:06:02  jimz * print number of reads and writes per disk in simulator * * Revision 1.58  1996/07/28  20:31:39  jimz * i386netbsd port * true/false fixup * * Revision 1.57  1996/07/17  21:00:58  jimz * clean up timer interface, tracing * * Revision 1.56  1996/06/17  14:38:33  jimz * properly #if out RF_DEMO code * fix bug in MakeConfig that was causing weird behavior * in configuration routines (config was not zeroed at start) * clean up genplot handling of stacks * * Revision 1.55  1996/06/14  23:15:38  jimz * attempt to deal with thread GC problem * * Revision 1.54  1996/06/11  01:40:41  jimz * fix minor cut-n-paste bug in disk thread shutdown * * Revision 1.53  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.52  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.51  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.50  1996/06/07  21:33:04  jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.49  1996/06/06  01:14:49  jimz * initialize raidPtr for spare disks * * Revision 1.48  1996/06/05  21:10:57  jimz * fix up termination locking for disk threads * * Revision 1.47  1996/06/05  19:38:32  jimz * fixed up disk queueing types config * added sstf disk queueing * fixed exit bug on diskthreads (ref-ing bad mem) * * Revision 1.46  1996/06/05  18:06:02  jimz * Major code cleanup. The Great Renaming is now done. * Better modularity. Better typing. Fixed a bunch of * synchronization bugs. Made a lot of global stuff * per-desc or per-array. Removed dead code. * * Revision 1.45  1996/05/30  23:22:16  jimz * bugfixes of serialization, timing problems * more cleanup * * Revision 1.44  1996/05/30  12:59:18  jimz * make etimer happier, more portable * * Revision 1.43  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.42  1996/05/27  18:56:37  jimz * more code cleanup * better typing * compiles in all 3 environments * * Revision 1.41  1996/05/24  22:17:04  jimz * continue code + namespace cleanup * typed a bunch of flags * * Revision 1.40  1996/05/23  21:46:35  jimz * checkpoint in code cleanup (release prep) * lots of types, function names have been fixed * * Revision 1.39  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.38  1996/05/20  16:14:33  jimz * switch to rf_{mutex,cond}_{init,destroy} * * Revision 1.37  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.36  1996/05/07  17:41:54  jimz * add doDebug, which prints beginnings and ends of user-level disk * accesses * * Revision 1.35  1996/05/06  18:46:12  jimz * minor legibility cleanup * * Revision 1.34  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.33  1995/12/01  15:56:33  root * added copyright info * * Revision 1.32  1995/11/17  01:37:36  amiri * fixed bug related to detecting dead disks * * Revision 1.31  1995/11/16  19:14:59  wvcii * added call to FailDisk in disk_rw_func so that failed disk ops * result in a disk being marked as failed (user/kernel) * * Revision 1.30  1995/10/09  23:37:08  amiri * suppressed failure/warning msgs in demo mode * * Revision 1.29  1995/10/05  06:18:59  jimz * Changed DDEventRequest() to take additional arg, used by simulator * to cache diskid so queue length can be decremented on io complete * (this is a hack to get around the fact that the event mechanism * assumes it can dereference arbitrary handles on enqueued events) * * Revision 1.28  1995/10/04  20:14:11  wvcii * added asserts to monitor numOutstanding queueLength * * Revision 1.27  1995/10/04  07:07:44  wvcii * queue->numOutstanding now valid for user & sim * user tested & verified, sim untested * * Revision 1.26  1995/10/02  13:07:26  wvcii * fixed misspellings in output, cleaned up format * * Revision 1.25  1995/07/25  20:15:37  rachad * *** empty log message *** * * Revision 1.24  1995/07/06  13:06:18  robby * checked for divide by zero * * Revision 1.23  1995/05/23  17:21:11  rachad * *** empty log message *** * * Revision 1.22  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.21  1995/05/09  17:07:43  holland * bug fixes related to hanging problem in the engine * * Revision 1.20  1995/05/08  17:32:40  holland * bug fix: release disk arm locks when a locking op fails, rather * than in the dag error handler * * Revision 1.19  1995/05/01  13:28:00  holland * parity range locks, locking disk requests, recon+parityscan in kernel, etc. * * Revision 1.18  1995/04/24  13:25:51  holland * rewrite to move disk queues, recon, & atomic RMW to kernel * * Revision 1.17  1995/04/06  14:47:56  rachad * merge completed * * Revision 1.16  1995/04/03  20:40:19  holland * misc changes related to distributed sparing * * Revision 1.15  1995/03/09  19:54:11  rachad * Added suport for threadless simulator * * Revision 1.14  1995/03/03  18:36:16  rachad *  Simulator mechanism added * * Revision 1.13  1995/03/01  20:25:48  holland * kernelization changes * * Revision 1.12  1995/02/03  22:31:36  holland * many changes related to kernelization * * Revision 1.11  1995/02/01  15:13:05  holland * moved #include of general.h out of raid.h and into each file * * Revision 1.10  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.9  1995/01/24  23:58:46  holland * multi-way recon XOR, plus various small changes * * Revision 1.8  1994/12/05  04:18:12  holland * cam layer I/Os stuff * * Revision 1.7  1994/11/30  16:06:34  danner * Corrected I/O accounting for read-modify-writes * * Revision 1.6  1994/11/29  23:11:18  holland * disk utilization computation fix * * Revision 1.5  1994/11/29  22:11:38  danner * holland updates * * Revision 1.4  1994/11/29  20:36:02  danner * Added support for read-op-write * * Revision 1.3  1994/11/28  22:14:43  danner * Offset read and write calls by protected sectors. * */#include "rf_types.h"#include "rf_threadstuff.h"#include <fcntl.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include "rf_raid.h"#include "rf_threadid.h"#include "rf_etimer.h"#include "rf_acctrace.h"#include "rf_general.h"#include "rf_utils.h"#include "rf_camlayer.h"#include "rf_diskthreads.h"#include "rf_driver.h"#if RF_DEMO > 0#include "rf_demo.h"#endif /* RF_DEMO > 0 */#ifdef SIMULATE#include "rf_diskevent.h"#define RF_IDLE  0#define RF_BUSY  1#endif /* SIMULATE */#ifndef KERNEL#ifdef SIMULATEstatic int disk_rw_func(struct RF_DiskId_s *id);#else /* SIMULATE */static void disk_rw_func(struct RF_DiskId_s *id);#endif /* SIMULATE */#endif /* !KERNEL *//* the disk queues have already been told to shut down.  This will cause the * disk threads to exit, so just wait for that to happen */int rf_ShutdownDiskThreads(raidPtr)  RF_Raid_t  *raidPtr;{  if (rf_dtDebug) {    int tid;    rf_get_threadid(tid);    printf("[%d] waiting for diskthreads to complete\n", tid);  }  #ifndef SIMULATE  RF_LOCK_MUTEX(raidPtr->diskthread_count_mutex);  while(raidPtr->diskthreads_shutdown < raidPtr->diskthreads_created) {    RF_WAIT_COND(raidPtr->diskthread_count_cond, raidPtr->diskthread_count_mutex);  }  RF_UNLOCK_MUTEX(raidPtr->diskthread_count_mutex);#endif /* !SIMULATE */  if (rf_dtDebug) {

⌨️ 快捷键说明

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