From 6c041a8880a8993e037a417ba4c6548030da5f12 Mon Sep 17 00:00:00 2001 From: "shoichi.sawada@toshiba.co.jp" Date: Tue, 22 Dec 2015 08:16:24 +0000 Subject: [PATCH] Fix runtime of terse output 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 --- stat.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/stat.c b/stat.c index a3bfe632..3070cef9 100644 --- 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]; } -- 2.25.1