[PATCH] fio: fix timeout quit with loops > 1
authorJens Axboe <axboe@suse.de>
Fri, 2 Dec 2005 08:04:09 +0000 (09:04 +0100)
committerJens Axboe <axboe@suse.de>
Fri, 2 Dec 2005 08:04:09 +0000 (09:04 +0100)
fio.c
fio.h

diff --git a/fio.c b/fio.c
index 594d919c80808bcd95a69a152861df785efba88c..33f1b07f73e382ae114fd614eb9fd8fa3dd1e33e 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -431,7 +431,7 @@ static inline int runtime_exceeded(struct thread_data *td, struct timeval *t)
 {
        if (!td->timeout)
                return 0;
-       if (mtime_since(&td->start, t) >= td->timeout * 1000)
+       if (mtime_since(&td->epoch, t) >= td->timeout * 1000)
                return 1;
 
        return 0;
@@ -1791,6 +1791,8 @@ static void *thread_main(void *data)
        if (init_random_state(td))
                goto err;
 
+       gettimeofday(&td->epoch, NULL);
+
        while (td->loops--) {
                getrusage(RUSAGE_SELF, &td->ru_start);
                gettimeofday(&td->start, NULL);
@@ -1807,7 +1809,7 @@ static void *thread_main(void *data)
                else
                        do_async_io(td);
 
-               if (td->error)
+               if (td->error || td->terminate)
                        break;
 
                td->runtime += mtime_since_now(&td->start);
@@ -1823,7 +1825,7 @@ static void *thread_main(void *data)
                else
                        do_async_verify(td);
 
-               if (td->error)
+               if (td->error || td->terminate)
                        break;
        }
 
diff --git a/fio.h b/fio.h
index e1532a78de7532c294b3c07912fde0bb75eb0315..10d41feeb568393bdab04cab3a6a9cc4c38ab705 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -159,7 +159,8 @@ struct thread_data {
        struct io_log *lat_log;
        struct io_log *bw_log;
 
-       struct timeval start;
+       struct timeval start;   /* start of this loop */
+       struct timeval epoch;   /* time job was started */
 
        struct rusage ru_start;
        struct rusage ru_end;