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

📄 iozone.c

📁 硬盘速度测试 linux下 源码 c/c
💻 C
📖 第 1 页 / 共 5 页
字号:
long long max_rec_size = RECLEN_END;long long orig_min_rec_size = RECLEN_START;long long orig_max_rec_size = RECLEN_END;long long xover = CROSSOVER;char *throughput_tests[] = {"Initial write","Rewrite","Read","Re-read",	"Reverse Read","Stride read","Random read","Mixed workload","Random write","Pwrite","Pread"};char command_line[1024] = "\0";#ifdef unixdouble sc_clk_tck;#endifint argcsave;char **argvsave;char splash[80][80];int splash_line;char client_filename[256];char remote_shell[256];/*  * Host ports used to listen, and handle errors. */#define HOST_LIST_PORT 20000#define HOST_ESEND_PORT (HOST_LIST_PORT+MAXSTREAMS)#define HOST_ASEND_PORT (HOST_ESEND_PORT+MAXSTREAMS)/*  * Childs ports used to listen, and handle errors. */#define CHILD_ESEND_PORT (HOST_ASEND_PORT+MAXSTREAMS)#define CHILD_LIST_PORT (CHILD_ESEND_PORT+MAXSTREAMS)/* Childs async message port. Used for stop flag and terminate */#define CHILD_ALIST_PORT (CHILD_LIST_PORT+MAXSTREAMS)/* Ports for the network speed code */#define SP_CHILD_LISTEN_PORT 31000#define SP_CHILD_ESEND_PORT (SP_CHILD_LISTEN_PORT+10)#define SP_MASTER_LISTEN_PORT (SP_CHILD_ESEND_PORT+10)#define SP_MASTER_ESEND_PORT (SP_MASTER_LISTEN_PORT+10)#define SP_MASTER_RESULTS_PORT (SP_MASTER_ESEND_PORT+10)#define THREAD_WRITE_TEST 1#define THREAD_REWRITE_TEST 2#define THREAD_READ_TEST 3#define THREAD_REREAD_TEST 4#define THREAD_STRIDE_TEST 5#define THREAD_RANDOM_READ_TEST 6#define THREAD_RANDOM_WRITE_TEST 7#define THREAD_REVERSE_READ_TEST 8#define THREAD_RANDOM_MIX_TEST 9#define THREAD_PWRITE_TEST 10#define THREAD_PREAD_TEST 11#define THREAD_CLEANUP_TEST 12/* * Child states that the master is tracking. * The master uses these to determine how to shutdown * the clients when some fool hits control-C. */#define C_STATE_ZERO 1#define C_STATE_WAIT_WHO 2#define C_STATE_WAIT_BARRIER 3int c_port,a_port; /* port number */int child_port; /* Virtualized due to fork */int child_async_port; /* Virtualized due to fork */int client_listen_pid; /* Virtualized due to fork */int master_join_count; /* How many children have joined */int l_sock,s_sock,l_async_sock; /* Sockets for listening */char master_rcv_buf[4096]; /* Master's receive buffer */int master_listen_pid; /* Pid of the master's async listener proc */char master_send_buf[4096]; /* Master's send buffer */char child_rcv_buf[4096]; /* Child's receive buffer */char child_async_rcv_buf[4096]; /* Child's async recieve buffer */char child_send_buf[4096]; /* Child's send buffer */int child_send_socket; /* Child's send socket */int child_listen_socket; /* Child's listener socket */int child_listen_socket_async; /* Child's async listener socket */int master_send_socket; /* Needs to be an array. One for each child*/int master_send_sockets[MAXSTREAMS]; /* Needs to be an array. One for each child*/int master_send_async_sockets[MAXSTREAMS]; /* Needs to be an array. One for each child*/int master_listen_port; /* Master's listener port number */int master_listen_socket; /* Master's listener socket */int clients_found; /* Number of clients found in the client file */FILE *newstdin, *newstdout, *newstderr; /* used for debug in cluster mode.*/char toutput[20][20]; /* Used to help format the output */int toutputindex; /* Index to the current output line */int cdebug = 0; /* Use to turn on child/client debugging in cluster mode. */int mdebug = 0; /* Use to turn on master debug in cluster mode */int aggflag; /* Used to indicate constant aggregate data set size */struct sockaddr_in child_sync_sock, child_async_sock;/* * Change this whenever you change the message format of master or client. */int proto_version = 20;/******************************************************************************//* Tele-port zone. These variables are updated on the clients when one is     *//* using cluster mode. (-+m)                                                  *//* Do not touch these unless you have become one with the universe !!         *//******************************************************************************/char controlling_host_name[100];struct child_ident {	char child_name[100];	char workdir[200];	char execute_path[200];	char file_name[200];	int state;	int child_number;	int child_port;	int child_async_port;	int master_socket_num;	int master_async_socket_num;}child_idents[MAXSTREAMS];int Kplus_readers;char write_traj_filename [MAXNAMESIZE];     /* name of write telemetry file */char read_traj_filename [MAXNAMESIZE];    /* name of read telemetry file  */char oflag,jflag,k_flag,h_flag,mflag,pflag,unbuffered,Kplus_flag;char noretest;char async_flag,stride_flag,mmapflag,mmapasflag,mmapssflag,mmapnsflag,mmap_mix;char verify = 1;int restf;char sverify = 1;char odsync = 0;char Q_flag,OPS_flag;char L_flag=0;char no_copy_flag,include_close,include_flush;char disrupt_flag,compute_flag,xflag,Z_flag, X_flag;int no_unlink = 0;int r_traj_flag,w_traj_flag;char MS_flag;int advise_op,advise_flag;int direct_flag;int current_client_number;long long chid;int file_lock;unsigned int pattern;long long stride = STRIDE;long long delay,purge,fetchon;off64_t  numrecs64 = (off64_t)NUMRECS;long long reclen = RECLEN;long long delay_start,depth;VOLATILE char *stop_flag;		/* Used to stop all children */float compute_time;int multiplier = MULTIPLIER;long long rest_val;#if defined(Windows)	HANDLE hand;#endif/******************************************************************************//* End of Tele-port zone.                                                     *//******************************************************************************//*  * Prototypes * Sort of... Full prototypes break non-ansi C compilers. No protos is  * a bit sloppy, so the compromise is this. */void child_send();int start_child_send();int start_child_listen();int start_child_listen_async();void start_child_listen_loop();void child_listen();void child_listen_async();void stop_child_send();void stop_child_listen();void cleanup_comm();void master_send();int start_master_send();int start_master_listen();int check_filename();void master_listen();void stop_master_send();void stop_master_listen();long long start_child_proc();int parse_client_line();void wait_dist_join();void tell_children_begin();void start_master_listen_loop();void wait_for_master_go();void tell_master_ready();void stop_master_listen_loop();void tell_master_stats();void become_client();int pick_client();long long start_child_proc();int start_master_send();void child_listen();int start_child_listen();void stop_master_send();void stop_master_listen();void stop_child_send();void stop_child_listen();int start_child_send();void master_send();void child_send();void master_listen();int start_master_listen();void child_remove_files();void terminate_child_async();void distribute_stop();void send_stop();void cleanup_children();/****************************************************************//*								*//*   MAIN () 							*//*								*//****************************************************************/intmain(argc,argv) int argc;char **argv;{	long long fileindx,i,tval;	long long ind;	int ret;	FILE *pi;	char reply[IBUFSIZE];	unsigned char inp_pat;	time_t time_run;	char *port,*m,*subarg;	int num_child1;	int cret;	int anwser,bind_cpu;	anwser=bind_cpu=0;	/* Used to make fread/fwrite do something better than their defaults */	setvbuf( stdout, NULL, _IONBF, (size_t) NULL );	setvbuf( stderr, NULL, _IONBF, (size_t) NULL );		/* Save the master's name */	gethostname(controlling_host_name,256);	/* Try to find the actual VM page size, if possible */#if defined (solaris) || defined (_HPUX_SOURCE) || defined (linux) || defined(IRIX) || defined (IRIX64)#ifndef __convex_spp	page_size=getpagesize();#endif#endif	/* Try to find the actual number of ticks per second */#ifdef unix	sc_clk_tck = clk_tck();#endif	for(ind=0;ind<MAXSTREAMS;ind++)		filearray[ind]=(char *)tfile;	base_time=(long)time_so_far();	myid=(long long)getpid(); 	/* save the master's PID */	get_resolution(); 		/* Get clock resolution */	time_run = time(0);		/* Start a timer */	(void)find_external_mon(imon_start, imon_stop);	/* 	 * Save the splash screen for later display. When in distributed network	 * mode this output does not get displayed on the clients.	 */	sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n");    	sprintf(splash[splash_line++],"\t%s\n\t%s\n", THISVERSION,MODE);    	sprintf(splash[splash_line++],"\t\tBuild: %s \n\n",build_name);    	sprintf(splash[splash_line++],"\tContributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins\n");	sprintf(splash[splash_line++],"\t             Al Slater, Scott Rhine, Mike Wisner, Ken Goss\n");    	sprintf(splash[splash_line++],"\t             Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,\n");    	sprintf(splash[splash_line++],"\t             Randy Dunlap, Mark Montague, Dan Million, \n");    	sprintf(splash[splash_line++],"\t             Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy,\n");    	sprintf(splash[splash_line++],"\t             Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root.\n\n");	sprintf(splash[splash_line++],"\tRun began: %s\n",ctime(&time_run));	argcsave=argc;	argvsave=argv;    	signal(SIGINT, signal_handler);	 	/* handle user interrupt */    	signal(SIGTERM, signal_handler);	/* handle kill from shell */        /********************************************************/        /* Allocate and align buffer with beginning of the 	*/        /* on chip data cache. 					*/        /********************************************************/     	buffer = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0);	if(buffer == 0) {        	perror("Memory allocation failed:");        	exit(1);        }#ifdef _64BIT_ARCH_     	buffer = (char *) ((long long )(buffer + cache_size ) & 		~(cache_size-1));#else     	buffer = (char *) ((long)(buffer + cache_size ) & 		~((long)cache_size-1));#endif	mainbuffer = buffer;	/* de-dup input buf */     	buffer1 = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0);	if(buffer1 == 0) {        	perror("Memory allocation failed:");        	exit(1);        }#ifdef _64BIT_ARCH_     	buffer1 = (char *) ((long long )(buffer1 + cache_size ) & 		~(cache_size-1));#else     	buffer1 = (char *) ((long)(buffer1 + cache_size ) & 		~((long)cache_size-1));#endif	dedup_ibuf = buffer1;	touch_dedup(buffer1, MAXBUFFERSIZE);	/* de-dup temp buf */     	buffer1 = (char *) alloc_mem((long long)(MAXBUFFERSIZE + (2 * cache_size)),(int)0);	if(buffer1 == 0) {        	perror("Memory allocation failed:");        	exit(1);        }#ifdef _64BIT_ARCH_     	buffer1 = (char *) ((long long )(buffer1 + cache_size ) & 		~(cache_size-1));#else     	buffer1 = (char *) ((long)(buffer1 + cache_size ) & 		~((long)cache_size-1));#endif	dedup_temp = buffer1;	fetchon++;  /* By default, prefetch the CPU cache lines associated with the buffer */  	strcpy(filename,default_filename); 	/* Init default filename */  	sprintf(dummyfile[0],"%s.DUMMY",default_filename);	if(argc <=1){		printf(USAGE);		exit(0);	}	auto_mode = 0; 		/* Default is to disable auto mode */	inp_pat = PATTERN; 	/* Init default pattern for verification */	/* Fill the entire pattern variable with the same character */	pattern = ((inp_pat << 24) | (inp_pat << 16) | (inp_pat << 8) | inp_pat);	/*	 * Parse all of the options that the user specified.	 */	while((cret = getopt(argc,argv,"ZQNIBDGCTOMREWovAxamwphcezKJ:j:k:V:r:t:s:f:F:d:l:u:U:S:L:H:+:P:i:b:X:Y:g:n:y:q: ")) != EOF){		switch(cret){		case 'k':	/* Async I/O with no bcopys */			depth = (long long)(atoi(optarg));			if(depth <0)				depth=0;			/*			if(depth > 60)				depth=60;			*/#ifdef NO_PRINT_LLD			sprintf(splash[splash_line++],"\tPOSIX Async I/O (no bcopy). Depth %ld \n",depth);#else			sprintf(splash[splash_line++],"\tPOSIX Async I/O (no bcopy). Depth %lld \n",depth);#endif			no_copy_flag=1;			async_flag++;			k_flag++;			break;		case 'T':	/* Switch to POSIX thread based */#ifndef NO_THREADS			use_thread++;#else			printf("\tThreads not supported in this version\n");			exit(2);#endif			break;		case 'H':	/* Use POSIX async_io */			h_flag++;			depth = (long long)(atoi(optarg));			if(depth <0)				depth=0;			/*			 * Hmmm. many systems fail is strange ways when the maximum			 * number of async I/Os per user or proc is exceeded.			 */			/*			if(depth > 60)				depth=60;			*/#ifdef NO_PRINT_LLD			sprintf(splash[splash_line++],"\tPOSIX async I/O (with bcopy). Depth %ld\n",depth);#else			sprintf(splash[splash_line++],"\tPOSIX async I/O (with bcopy). Depth %lld\n",depth);#endif			async_flag++;			break;		case 'I':	/* Use VXFS direct advisory or O_DIRECT from Linux or AIX , or O_DIRECTIO for TRU64 */#ifdef VXFS			direct_flag++;			sprintf(splash[splash_line++],"\tVxFS advanced feature SET_CACHE, VX_DIRECT enabled\n");			break;#endif#if ! defined(DONT_HAVE_O_DIRECT)#if defined(linux) || defined(__AIX__) || defined(IRIX) || defined(IRIX64) || defined(Windows)			direct_flag++;			sprintf(splash[splash_line++],"\tO_DIRECT feature enabled\n");			break;#endif#if defined(TRU64)			direct_flag++;			sprintf(splash[splash_line++],"\tO_DIRECTIO feature enabled\n");			break;#endif#else			break;#endif#if defined(Windows)			sprintf(splash[splash_line++],"\tO_DIRECTIO feature not available in Windows version.\n");			break;#endif		case 'B':	/* Use mmap file for test file */			sprintf(splash[splash_line++],"\tUsing mmap files\n");			mmapflag++;			mmapnsflag++;			break;		case 'D':	/* Use async msync mmap file */			sprintf(splash[splash_line++],"\tUsing msync(MS_ASYNC) on mmap files\n");			mmapflag++;			mmapasflag++;			mmapnsflag=0;

⌨️ 快捷键说明

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