[PATCH] fio: some verify fixes
authorJens Axboe <axboe@suse.de>
Thu, 3 Nov 2005 16:14:14 +0000 (17:14 +0100)
committerJens Axboe <axboe@suse.de>
Thu, 3 Nov 2005 16:14:14 +0000 (17:14 +0100)
Makefile
fio.c

index d616e8ce48aff2b33e48c02ad3b6a5ff462b0578..2b7b33cbcf6e90369071c91e934f23e5b9ea8b51 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ all: $(PROGS) $(SCRIPTS)
 dops: dops.o
        $(CC) $(CFLAGS) -o $@ $(filter %.o,$^) -laio
 
-fio: fio.o
+fio: fio.o md5.o
        $(CC) $(CFLAGS) -o $@ $(filter %.o,$^) -lpthread -laio -lm
 
 sgioread: sgioread.o
diff --git a/fio.c b/fio.c
index 10f9cceb8ade0c75919dd1cf73ee3104718c87ba..1ad22351404e49a3fd606ff07dc6a0a8535a26a7 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -281,6 +281,7 @@ struct thread_data {
        unsigned long kb;
        unsigned long io_blocks;
        unsigned long io_kb;
+       unsigned long this_io_kb;
        unsigned long last_kb;
        sem_t mutex;
        struct drand48_data random_state;
@@ -423,8 +424,8 @@ static unsigned int get_next_buflen(struct thread_data *td)
                buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
        }
 
-       if (buflen > ((td->kb - td->io_kb) << 10))
-               buflen = (td->kb - td->io_kb) << 10;
+       if (buflen > ((td->kb - td->this_io_kb) << 10))
+               buflen = (td->kb - td->this_io_kb) << 10;
 
        td->last_kb += buflen >> 10;
        return buflen;
@@ -479,14 +480,14 @@ static void add_bw_sample(struct thread_data *td, unsigned long msec)
        if (spent < td->bw_avg_time)
                return;
 
-       rate = ((td->io_kb - td->stat_io_kb) * 1024) / spent;
+       rate = ((td->this_io_kb - td->stat_io_kb) * 1024) / spent;
        add_stat_sample(td, &td->bw_stat, rate);
 
        if (td->bw_log)
                add_log_sample(td, td->bw_log, rate);
 
        gettimeofday(&td->stat_sample_time, NULL);
-       td->stat_io_kb = td->io_kb;
+       td->stat_io_kb = td->this_io_kb;
 }
 
 static void usec_sleep(int usec)
@@ -548,7 +549,7 @@ static int check_min_rate(struct thread_data *td, struct timeval *now)
                if (spent < td->ratecycle)
                        return 0;
 
-               rate = ((td->io_kb - td->rate_kb) * 1024) / spent;
+               rate = ((td->this_io_kb - td->rate_kb) * 1024) / spent;
                if (rate < td->ratemin) {
                        printf("Client%d: min rate %d not met, got %ldKiB/sec\n", td->thread_number, td->ratemin, rate);
                        if (rate_quit)
@@ -557,7 +558,7 @@ static int check_min_rate(struct thread_data *td, struct timeval *now)
                }
        }
 
-       td->rate_kb = td->io_kb;
+       td->rate_kb = td->this_io_kb;
        memcpy(&td->lastrate, now, sizeof(*now));
        return 0;
 }
@@ -755,6 +756,7 @@ static int do_sync_verify(struct thread_data *td)
                        break;
 
                if (back) {
+                       ret -= back;
                        if (lseek(td->fd, -back, SEEK_CUR) < 0) {
                                td->error = errno;
                                break;
@@ -780,7 +782,7 @@ static void do_sync_io(struct thread_data *td)
        td->cur_off = 0;
        td->last_kb = 0;
 
-       for (td->io_kb = 0; td->io_kb < td->kb;) {
+       for (td->this_io_kb = 0; td->this_io_kb < td->kb;) {
                int ret;
 
                if (td->terminate)
@@ -810,6 +812,7 @@ static void do_sync_io(struct thread_data *td)
 
                td->io_blocks++;
                td->io_kb += io_u->buflen >> 10;
+               td->this_io_kb += io_u->buflen >> 10;
                td->cur_off = io_u->offset + io_u->buflen;
 
                gettimeofday(&e, NULL);
@@ -885,6 +888,7 @@ static int ios_completed(struct thread_data *td, int nr)
 
                td->io_blocks++;
                td->io_kb += io_u->buflen >> 10;
+               td->this_io_kb += io_u->buflen >> 10;
                bytes_done += io_u->buflen;
 
                msec = mtime_since(&io_u->issue_time, &e);
@@ -946,7 +950,7 @@ static void do_async_io(struct thread_data *td)
        td->cur_off = 0;
        td->last_kb = 0;
 
-       for (td->io_kb = 0; td->io_kb < td->kb;) {
+       for (td->this_io_kb = 0; td->this_io_kb < td->kb;) {
                struct timespec ts = { .tv_sec = 0, .tv_nsec = 0};
                struct timespec *timeout;
                int ret, min_evts = 0;
@@ -1337,14 +1341,14 @@ static void *thread_main(int shm_id, int offset, char *argv[])
                        do_sync_io(td);
 
                        if (td->verify) {
-                               if (do_sync_verify(td))
+                               if (!do_sync_verify(td))
                                        break;
                        }
                } else {
                        do_async_io(td);
 
                        if (td->verify) {
-                               if (do_async_verify(td))
+                               if (!do_async_verify(td))
                                        break;
                        }
                }