--- seeker_baryluk.c~ 2009-09-15 09:10:05.000000000 +0300
+++ seeker_baryluk.c 2010-08-19 12:33:45.151306691 +0300
@@ -17,11 +17,12 @@
#include <linux/fs.h>
#define BLOCKSIZE 512
-#define TIMEOUT 30
+#define DEFAULT_TIMEOUT 30
pthread_mutex_t muteks = PTHREAD_MUTEX_INITIALIZER;
int count;
+int TIMEOUT;
time_t start;
off64_t maxoffset = 0;
off64_t minoffset = 249994674176000uLL;
@@ -90,7 +91,9 @@
while (p->run) {
offset = (off64_t) ( (unsigned long long) (p->numbytes * (rand_r(&(p->seed)) / (RAND_MAX + 1.0) )));
- //printf("%d %llu\n", p->id, (unsigned long long )offset);
+ // do blocksize aligned seeks
+ offset = offset & (~((off64_t) 0) & (~(BLOCKSIZE-1))) ;
+ //printf("%d %x\n", p->id, (unsigned long long )offset);
retval = lseek64(p->fd, offset, SEEK_SET);
handle("lseek64", retval == (off64_t) -1);
retval = read(p->fd, p->buffer, BLOCKSIZE);
@@ -121,22 +124,26 @@
setvbuf(stdout, NULL, _IONBF, 0);
- printf("Seeker v3.0, 2009-06-17, "
+ printf("Seeker v3.0+Fedora, 2009-06-17, "
"http://www.linuxinsight.com/how_fast_is_your_disk.html\n");
- if (!(argc == 2 || argc == 3)) {
- printf("Usage: %s device [threads]\n", argv[0]);
+ if (!(argc == 2 || argc == 3 || argc == 4)) {
+ printf("Usage: %s device [threads] [seconds]\n", argv[0]);
exit(1);
}
threads = 1;
- if (argc == 3) {
+ TIMEOUT = DEFAULT_TIMEOUT;
+ if (argc > 2) {
threads = atoi(argv[2]);
+ if (argc > 3) {
+ TIMEOUT = atoi(argv[3]);
+ }
}
//pthread_mutex_init(&muteks, NULL);
- fd = open(argv[1], O_RDONLY | O_LARGEFILE);
+ fd = open(argv[1], O_RDONLY | O_LARGEFILE | O_DIRECT);
handle("open", fd < 0);
#ifdef BLKGETSIZE64
@@ -177,7 +184,9 @@
p[i].seed = rand()+i;
p[i].fd = dup(fd);
handle("dup", p[i].fd < 0);
- p[i].buffer = malloc(sizeof(char)*BLOCKSIZE);
+ p[i].buffer = memalign(512*8, sizeof(char)*BLOCKSIZE);
+ //printf("\n%x\n", (int)(&(p[i].buffer)));
+
p[i].numbytes = numbytes;
handle("malloc", p[i].buffer == NULL);
p[i].run = 1;