📄 rf_loopscript.c
字号:
/* * Copyright (c) 1996 Carnegie-Mellon University. * All rights reserved. * * Author: Mark Holland, Jim Zelenka * * 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. */#include "rf_threadstuff.h"#include "rf_types.h"#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <unistd.h>#include <sys/file.h>#include "rf_raid.h"#include "rf_dag.h"#include "rf_threadid.h"#include "rf_randmacros.h"#include "rf_parityscan.h"#include "rf_etimer.h"#include "rf_script.h"#include "rf_mcpair.h"#include "rf_configure.h"#include "rf_stripelocks.h"#include "rf_general.h"#include "rf_utils.h"#include "rf_testcode.h"#include "rf_driver.h"#include "rf_cpuutil.h"#include "rf_map.h"#include "rf_dagutils.h"#include "rf_copyback.h"#ifdef SIMULATE#include "rf_desc.h"#include "rf_owner.h"#include "rf_diskevent.h"#include "rf_diskthreads.h"#endif /* SIMULATE *//* * JimZ punishment test for repeatedly running the same script over * and over. It's kind of tuned to a particular notion of what * must be done. YMMV. Copied from other code, and hacked * without even attempting readability, modularity, reuse, or anything * else warm and fuzzy. This shouldn't be in the release. It's a pimple * on the otherwise sunny complexion of RAIDframe. */static RF_Raid_t raidDescriptor; /* the primary RAID descriptor used at user level */static RF_Config_t globalConfig;int main(argc,argv) int argc; char **argv;{ char *cmdname = argv[0], cbuf[100]; RF_ShutdownList_t *shutdownList; char *configname, *scriptname; int status, rc; int run_num=0; scriptname = "scripts/r30.rst"; configname = "config5.user"; if (argc > 1) { configname = argv[1]; if (argc > 2) { scriptname = argv[2]; } } while(1) { printf("\n\n\n\n\n\n\n"); printf("***********************************\n"); printf("**** Run number %4d commences ****\n", ++run_num); printf("**** Config: %17s ****\n", configname); printf("**** Script: %17s ****\n", scriptname); printf("***********************************\n"); printf("\n\n"); shutdownList = NULL; rf_BootRaidframe(); /* initialize some stuff */ status = rf_MakeConfig(configname, &globalConfig); if (status) { printf("Unable to create configuration. Exiting.\n"); exit(1); } status = rf_Configure(&raidDescriptor, &globalConfig); free(globalConfig.layoutSpecific); /* we had to use malloc(), not Malloc() */ if (status) { RF_ERRORMSG("Unable to configure RAID device for the above reason(s). Exiting...\n"); exit(1); } globalRaidPtr = &raidDescriptor; /* debug only -- allows cleanup after ^C */ rf_TestcodeInit(&raidDescriptor); loopScriptTest(&raidDescriptor, scriptname, &shutdownList); rf_test_running = 0; rf_ShutdownList(&shutdownList); rf_Shutdown(&raidDescriptor); rf_UnbootRaidframe(); /* XXX debugging, really */ } return(0);}int loopScriptTest(raidPtr, scriptname, listp) RF_Raid_t *raidPtr; char *scriptname; RF_ShutdownList_t **listp;{ RF_Script_t *script; RF_GRpair_t *grp, *fgrp; int rc; long nthreads;#ifndef SIMULATE RF_Thread_t *threads, fthread; RF_ThreadAttr_t attr;#endif /* !SIMULATE */ int status, i; char buf[10]; grp = rf_GetGrpair(listp); if (grp == NULL) { RF_PANIC(); } grp->raidPtr = raidPtr; fgrp = rf_GetGrpair(listp); if (fgrp == NULL) { RF_PANIC(); } fgrp->raidPtr = raidPtr; nthreads =0; script = ConfigureScript(scriptname, raidPtr->totalSectors, &nthreads); if (script == NULL) { printf("bad script %s\n", scriptname); exit(1); } grp->script = script; rf_testcode_degr_mode_type = 'n'; if ((rf_testcode_degr_mode_type == 'c') || (rf_testcode_degr_mode_type == '2')) { rf_FailDisk(raidPtr, 0, 0, 0); if (rf_testcode_degr_mode_type == '2') { rf_FailDisk(raidPtr, 0, 1, 0); } }#ifdef SIMULATE RF_INIT_RANDOM(1); RunScriptTestFunc(grp, nthreads);#else /* SIMULATE */ RF_Malloc(threads, nthreads*sizeof(RF_Thread_t), (RF_Thread_t *)); for (i=0; i<nthreads; i++) { if (RF_CREATE_THREAD(threads[i], ScriptTestFunc, grp)) { RF_ERRORMSG("Unable to create ScriptTestFunc thread!\n"); exit(1); } RF_THREADGROUP_STARTED(&grp->group); } RF_THREADGROUP_WAIT_START(&grp->group); rf_start_cpu_monitor(); if (rf_testcode_degr_mode_type == 'r' || rf_testcode_degr_mode_type == 'a' ) { if (RF_CREATE_THREAD(fthread, DiskFailingThread, fgrp)) { RF_ERRORMSG("Unable to create disk failing thread\n"); exit(1); } RF_THREADGROUP_STARTED(&fgrp->group); RF_THREADGROUP_WAIT_START(&fgrp->group); RF_THREADGROUP_WAIT_STOP(&fgrp->group); rf_terminate_script_test = 1; } else { rf_start_cpu_monitor(); } RF_THREADGROUP_WAIT_STOP(&grp->group); if (rf_testcode_degr_mode_type != 'r') { rf_stop_cpu_monitor(); rf_print_cpu_util("script run"); } RF_Free(threads, nthreads*sizeof(RF_Thread_t));#endif /* SIMULATE */ ShutdownScript(script);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -