[PATCH] fio: make disk util work better (account like ru)
authorJens Axboe <axboe@suse.de>
Thu, 24 Nov 2005 15:21:49 +0000 (16:21 +0100)
committerJens Axboe <axboe@suse.de>
Thu, 24 Nov 2005 15:21:49 +0000 (16:21 +0100)
fio.c
fio.h

diff --git a/fio.c b/fio.c
index a789bd86881f22c8aa0d76134b68113d7de830bd..76e3626d24abda83a43907010a1e502e7772bc50 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1579,12 +1579,13 @@ static int get_io_ticks(struct thread_data *td)
        return i8;
 }
 
-static void finish_disk_stats(struct thread_data *td)
+static void update_io_ticks(struct thread_data *td)
 {
        unsigned long ticks;
 
        ticks = get_io_ticks(td);
-       td->io_ticks = ticks - td->io_ticks;
+       td->io_ticks += (ticks - td->start_io_ticks);
+       td->start_io_ticks = ticks;
 }
 
 static int init_disk_stats(struct thread_data *td)
@@ -1623,7 +1624,7 @@ static int init_disk_stats(struct thread_data *td)
                sprintf(td->disk_stat_path, "%s/stat", p);
        }
 
-       td->io_ticks = get_io_ticks(td);
+       td->start_io_ticks = get_io_ticks(td);
        return 0;
 }
 
@@ -1715,6 +1716,7 @@ static void *thread_main(void *data)
 
                td->runtime += mtime_since_now(&td->start);
                update_rusage_stat(td);
+               update_io_ticks(td);
 
                if (td->verify == VERIFY_NONE)
                        continue;
@@ -1732,8 +1734,6 @@ static void *thread_main(void *data)
 
        ret = 0;
 
-       finish_disk_stats(td);
-
        if (td->bw_log)
                finish_log(td, td->bw_log, "bw");
        if (td->lat_log)
diff --git a/fio.h b/fio.h
index 1ef9d3321417e00f3813881f66f7eda4b8f2af0f..54a23a3598e5db1b2f43717b09e0d2d5bba93b95 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -172,7 +172,7 @@ struct thread_data {
         * disk util stats
         */
        char disk_stat_path[256];
-       unsigned long io_ticks;
+       unsigned long start_io_ticks, io_ticks;
 };
 
 extern int parse_jobs_ini(char *);