Fix runtime of terse output
authorshoichi.sawada@toshiba.co.jp <shoichi.sawada@toshiba.co.jp>
Tue, 22 Dec 2015 08:16:24 +0000 (08:16 +0000)
committerJens Axboe <axboe@fb.com>
Wed, 23 Dec 2015 16:02:50 +0000 (09:02 -0700)
Hi,

When I used fio with option of '--status-interval=1 --minimal' and 'random_distribution=zipf:1.2',
'runtime' of 2nd line was 18446744073709551345.
This value is -271 in int_64.

This is because 'runtime' was subtracted in function '__show_running_run_stats'.
If 'td->io_bytes' is 0 when this function was called,
and 'td->io_bytes' is not 0 when '__show_run_stats' returned,
'runtime' is subtracted by 'rt' even though 'runtime' have not added.

I fixed the problem by applying this patch to fio-2.2.13.

Regards
Shoichi

----

Signed-off-by: Jens Axboe <axboe@fb.com>
stat.c

diff --git a/stat.c b/stat.c
index a3bfe632454e4b0a2a2d5c5dcde5a4b429f4e6f5..3070cef9dc895f220ef48107d130839fe746285e 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1730,19 +1730,19 @@ void __show_running_run_stats(void)
        fio_gettime(&tv, NULL);
 
        for_each_td(td, i) {
-               rt[i] = mtime_since(&td->start, &tv);
-               if (td_read(td) && td->io_bytes[DDIR_READ])
-                       td->ts.runtime[DDIR_READ] += rt[i];
-               if (td_write(td) && td->io_bytes[DDIR_WRITE])
-                       td->ts.runtime[DDIR_WRITE] += rt[i];
-               if (td_trim(td) && td->io_bytes[DDIR_TRIM])
-                       td->ts.runtime[DDIR_TRIM] += rt[i];
-
                td->update_rusage = 1;
                td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ];
                td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE];
                td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
                td->ts.total_run_time = mtime_since(&td->epoch, &tv);
+
+               rt[i] = mtime_since(&td->start, &tv);
+               if (td_read(td) && td->ts.io_bytes[DDIR_READ])
+                       td->ts.runtime[DDIR_READ] += rt[i];
+               if (td_write(td) && td->ts.io_bytes[DDIR_WRITE])
+                       td->ts.runtime[DDIR_WRITE] += rt[i];
+               if (td_trim(td) && td->ts.io_bytes[DDIR_TRIM])
+                       td->ts.runtime[DDIR_TRIM] += rt[i];
        }
 
        for_each_td(td, i) {
@@ -1758,11 +1758,11 @@ void __show_running_run_stats(void)
        __show_run_stats();
 
        for_each_td(td, i) {
-               if (td_read(td) && td->io_bytes[DDIR_READ])
+               if (td_read(td) && td->ts.io_bytes[DDIR_READ])
                        td->ts.runtime[DDIR_READ] -= rt[i];
-               if (td_write(td) && td->io_bytes[DDIR_WRITE])
+               if (td_write(td) && td->ts.io_bytes[DDIR_WRITE])
                        td->ts.runtime[DDIR_WRITE] -= rt[i];
-               if (td_trim(td) && td->io_bytes[DDIR_TRIM])
+               if (td_trim(td) && td->ts.io_bytes[DDIR_TRIM])
                        td->ts.runtime[DDIR_TRIM] -= rt[i];
        }