Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 317505 Details for
Bug 463497
gfs file locking is extremely slow ( gfs_controld vs cluster locking )
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
wire_test.c
write_test.c (text/plain), 7.34 KB, created by
Everett Bennett
on 2008-09-23 18:29:35 UTC
(
hide
)
Description:
wire_test.c
Filename:
MIME Type:
Creator:
Everett Bennett
Created:
2008-09-23 18:29:35 UTC
Size:
7.34 KB
patch
obsolete
>/* > >Reads random records from a file. See usage below. For large files, this >eliminates Unix cache from the result and essentially measures physical >I/O performance of a disk. > >Build: > gcc -g -I. /src/dcs/uio/src/write_test.c -o /obj/dcs/uio/bin/write_test > >On SUN: add -lrt > >*/ >/* >$log >minor >$log >*/ >char usage_msg[] = "\ >write_test options\n\ >Options:\n\ >-create - create new file vs open existing one\n\ >-size n - record size \n\ >-max n - number of records to write \n\ >-file name - file name\n\ >-fwrite - use fwrite instead of write\n\ >-sync - sync every write\n\ >-lock - lock/unlcok every read/write\n\ >-direct - Use direct I/O (i.e. O_DIRECT)\n\ >-reads n - perform this many reads at random places in the file\n\ >-rdwr - used with -reads, do read/writes at random places in the file\n\ >-verbose - produce progress report\n\ >\n\ >Examples:\n\ > write_test -create -size 512 -max 500000 -reads 100000 -rdwr -lock -file \n\ > /dcs/appl01_loc/DISAM_TEST/tmp/x.tmp\n\ > write_test -size 512 -max 50000 -reads 1000000 -rdwr -create -file tmp/wtest\n\ >"; >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <malloc.h> >#include <ctype.h> >#include <time.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <errno.h> >#include <string.h> >#include <fcntl.h> >#include <sys/time.h> > >#ifndef offsetof >#define offsetof(a, b) ((char *)&(((a *)0)->b) - (char *)0) >#endif > >static double get_time(void); >static int mem_same(unsigned char * in, int val, int size); >static void lock_file(int fd, int cmd); > ># define O_DIRECT 040000 // experimental, comes from bits/fcntl.h >static int o_direct = 0; > > >void usage (char * progname) >{ > printf ("%s", usage_msg); > exit(1); >} > >static FILE * fp; >static int fildes; >static int prime_num = 137143; > >int main (int argc, char * argv[]) >{ > > int i, rec_size=0, mod, max, records_added, records_read, ioffset ; > int key_value_mod ; > int status; > int direct=0; > int verbose=0; > int create=0; > int reads=0; > int rdwr=0; > int passes=0; > int pass=0; > int create_file = 0; > double result = 0; > char * parm; > char * file_name = NULL; > double stime, etime; > double incr_stime, incr_etime; > int lock = 0; > int fw = 0; > int rec_cnt, sz; > int sync_write = 0; > char * buf; > > if (argc < 4) > { > usage(argv[0]); > exit(1); > } > > > for(i=1; i<argc; i++ ) > { > parm = argv[i]; > if (strcmp(parm,"-size") == 0) > { > i++; > rec_size = atoi(argv[i]); > continue; > } > if (strcmp(parm,"-max") == 0) > { > i++; > max = atoi(argv[i]); > continue; > } > if (strcmp(parm,"-reads") == 0) > { > i++; > reads = atoi(argv[i]); > continue; > } > if (strcmp(parm,"-rdwr") == 0) > { > rdwr = 1; > continue; > } > if (strcmp(parm,"-direct") == 0) > { > direct = 1; > o_direct = O_DIRECT; > continue; > } > if (strcmp(parm,"-fwrite") == 0) > { > fw = 1; > continue; > } > if (strcmp(parm,"-verbose") == 0) > { > verbose = 1; > continue; > } > if (strcmp(parm,"-lock") == 0) > { > lock = 1; > continue; > } > if (strcmp(parm,"-sync") == 0) > { > sync_write = 1; > continue; > } > if (strcmp(parm,"-create") == 0) > { > create= 1; > continue; > } > if (strcmp(parm,"-file") == 0) > { > i++; > file_name = argv[i]; > continue; > } > fprintf(stderr,"Invalid option %s\n",parm); > exit(1); > } > if (!reads) > reads = max; > > if (!rec_size || !file_name) > { > fprintf(stderr,"Command line has insufficient parameters\n"); > exit(1); > } > if (direct) > { > buf = malloc(rec_size + 512); > /* align on 512 boundary, a reqiurement of O_DIRECT */ > buf += 512; > buf = (char *) ((unsigned long)buf >> 8); > buf = (char *) ((unsigned long)buf << 8); > } > else > buf = malloc(rec_size ); > memset(buf,0,rec_size); > > /* Create phase */ > if (create) > { > unlink (file_name); > if (fw) > { > fp = fopen(file_name, "w+"); > if (!fp) > { > fprintf(stderr,"error creating %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > } > else > { > fildes = open(file_name, O_RDWR | O_CREAT | O_TRUNC | o_direct , 0666); > if (fildes < 0) > { > fprintf(stderr,"error creating %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > } > > fprintf(stderr,"Start Create \n"); > stime = get_time(); > for(rec_cnt = 0; rec_cnt < max; rec_cnt++) > { > if (fw) > sz = fwrite(buf, 1,rec_size, fp); > else > { > sz = write(fildes, buf, rec_size); > if (sync_write ) > fsync(fildes); > if (lock) > { > lock_file(fildes, F_SETLKW); > lock_file(fildes, F_UNLCK); > } > } > if (sz != rec_size) > { > if (errno) > { > fprintf(stderr,"error write %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > else > { > fprintf(stderr,"error write %s : no room left\n", file_name ); > break; > } > } > if (verbose && rec_cnt && (rec_cnt % 100000) == 0) > fprintf(stderr,"Completed 100,000\n"); > } > etime = get_time(); > etime -= stime; > (void) fprintf(stderr,"Created %d records in %g secs @ %g rec/sec\n", > rec_cnt, etime, (double)rec_cnt/etime); > } > else > { > if (fw) > { > fp = fopen(file_name, "r"); > if (!fp) > { > fprintf(stderr,"error opening %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > } > else > { > fildes = open(file_name, O_RDWR | o_direct ); > if (fildes < 0) > { > fprintf(stderr,"error opening %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > } > } > > fprintf(stderr,"Start Read \n"); > stime = get_time(); > incr_stime = stime; > for(ioffset = rec_cnt = 0; rec_cnt < reads; rec_cnt++, ioffset += prime_num ) > { > off_t offset; > int sts; > > if (ioffset > max) > ioffset = ioffset % max; > > > offset = (off_t) ioffset; > offset *= (off_t) rec_size; > if (fw) > sts = fseek(fp, offset, SEEK_SET); > else > { > sts = lseek(fildes, offset, SEEK_SET); > if (lock) > lock_file(fildes, F_SETLKW); > } > > if (sts < 0) > { > fprintf(stderr,"error seek %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > if (fw) > sz = fread(buf, 1,rec_size, fp); > else > sz = read(fildes, buf, rec_size); > if (sz && sz != rec_size) > { > fprintf(stderr,"error read %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > if (rdwr) > { > if (fw) > sz = fwrite(buf, 1,rec_size, fp); > else > sz = write(fildes, buf, rec_size); > if (sync_write ) > fsync(fildes); > > if (sz != rec_size) > { > if (errno) > { > fprintf(stderr,"error write %s : %s\n", file_name, strerror(errno) ); > exit(1); > } > else > { > fprintf(stderr,"error write %s : no room left\n", file_name ); > break; > } > } > } > if (!fw && lock) > lock_file(fildes, F_UNLCK); > if (verbose && rec_cnt && (rec_cnt % 100000) == 0) > { > incr_etime = get_time(); > fprintf(stderr,"Completed 100,000 %g/sec\n", > (double)10000 / (incr_etime-incr_stime)); > incr_stime = incr_etime ; > } > } > etime = get_time(); > etime -= stime; > (void) fprintf(stderr,"Read %d records in %g secs @ %g rec/sec\n", > rec_cnt, etime, (double)rec_cnt/etime); > > if (fw) > fclose(fp); > else > close(fildes); > >} > > >static void lock_file(int fd, int cmd) >{ > int sts; > struct flock flock_buf; > > flock_buf.l_type = F_UNLCK; > flock_buf.l_whence = SEEK_SET; > flock_buf.l_start = (off_t) 0; > flock_buf.l_len = 1; > > sts = fcntl(fd, cmd, &flock_buf); > if (sts == -1) > { > printf("lock error: %s\n", strerror(errno)); > } > >} > >static double get_time(void) >{ > double out; > struct timeval time_b; > > gettimeofday (&time_b, NULL); > > out = time_b.tv_usec; > out = (out / 1000000.) + time_b.tv_sec; > return out; >} > > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 463497
: 317505 |
317506