/* This program is a speed test for linearly accessing a drive. * You give it the devicename, blocksize to read, and how many blocks, * and it will then use asynchronous IO to get the data. * * In theory, this should allow a drive with tagged queueing to maximize * throughput. Assuming the driver also supports tagged queueing! * * compile with $CC -o aioread aioread.c -laio * Usage: aioread /dev/rpath blocksize blockcount */ #include #include #include #include #include #include #include void usage(){ fprintf(stderr,"aioread\n"); fprintf(stderr,"Usage: aioread /dev/path blocksize blockcount\n"); fprintf(stderr," Async reads blockcount number of blocks from device\n"); fprintf(stderr," Specifically makes blockcount number of separate requests\n"); } #define MAXCOUNT 1000 int main(int argc, char *argv[]){ int fd; char *buffers[MAXCOUNT]; aio_result_t resultstat[MAXCOUNT]; struct timeval timeout; int blockcount, blocksize,errflag=0; int bcount; timeout.tv_sec=3; if(argc<4){ usage(); exit(1); } blocksize=atoi(argv[2]); blockcount=atoi(argv[3]); if(blockcount>=MAXCOUNT){ fprintf(stderr,"Sorry, can only handle less than %d blocks\n", MAXCOUNT); return 1; } fd=open(argv[1],O_RDONLY); if(fd==-1){ perror("could not open device"); exit(errno); } for(bcount=0;bcount