[PATCH] fio: correct stats for loops=x, where x > 1
authorJens Axboe <axboe@suse.de>
Fri, 4 Nov 2005 08:52:04 +0000 (09:52 +0100)
committerJens Axboe <axboe@suse.de>
Fri, 4 Nov 2005 08:52:04 +0000 (09:52 +0100)
fio.c

diff --git a/fio.c b/fio.c
index 2c54dac221b0d9c323da7ba6bd5ebb952b844749..b357dfab3b996d83b2574d78bd010055cdac05a0 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -804,9 +804,6 @@ static void do_sync_io(struct thread_data *td)
        struct io_u *io_u = NULL;
        struct timeval e;
 
-       td->cur_off = 0;
-       td->last_kb = 0;
-
        for (td->this_io_kb = 0; td->this_io_kb < td->kb;) {
                int ret;
 
@@ -1071,9 +1068,6 @@ static void do_async_io(struct thread_data *td)
        struct timeval s, e;
        unsigned long usec;
 
-       td->cur_off = 0;
-       td->last_kb = 0;
-
        for (td->this_io_kb = 0; td->this_io_kb < td->kb;) {
                struct timespec ts = { .tv_sec = 0, .tv_nsec = 0};
                struct timespec *timeout;
@@ -1455,12 +1449,16 @@ static void *thread_main(int shm_id, int offset, char *argv[])
 
        gettimeofday(&td->start, NULL);
 
-       if (td->ratemin)
-               memcpy(&td->lastrate, &td->start, sizeof(td->start));
+       while (td->loops--) {
+               gettimeofday(&td->stat_sample_time, NULL);
+
+               if (td->ratemin)
+                       memcpy(&td->lastrate, &td->stat_sample_time, sizeof(td->lastrate));
 
-       memcpy(&td->stat_sample_time, &td->start, sizeof(td->start));
+               td->cur_off = 0;
+               td->last_kb = 0;
+               td->stat_io_kb = 0;
 
-       while (td->loops--) {
                if (!td->use_aio) {
                        do_sync_io(td);