Refer td->loops instead of td->o.loops to fix loop count issue
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 1 Oct 2021 10:32:57 +0000 (19:32 +0900)
committerJens Axboe <axboe@kernel.dk>
Fri, 1 Oct 2021 17:17:13 +0000 (11:17 -0600)
In the github issues #1093 and #1278, it was reported that the loops
option does not work as expected when do_verify=0 option is specified.
Per analysis by Sowmya Ravi, the cause was as follows:

1) keep_running() decrements td->o.loops at job repetition, then
   td->o.loops has zero value when the last loop is executed.
2) clear_io_state() is called at the beginning of the thread_main loop
   for each repetition for loops option.
3) clear_io_state() calls reset_io_counters() which resets
   td->nr_done_files to zero when td->o.loops is non-zero.
4) For the last loop of loops option, clear_io_state() call does not
   clear td->nr_done_files since td->l.loops is zero. This results in a
   setup error in do_io().

To fix the issue, modify reset_io_counters() to refer td->loops instead
of td->o.loops. td->o.loops is not a good reference since it is updated
in keep_running(). td->loops is not updated during fio run, and safe to
refer.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20211001103257.4130231-3-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
libfio.c

index 6144a474738fe9a51a530ffad691aa234138d665..ed5906d4c2d3d80d70ca5f806662c216224e8544 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -104,7 +104,7 @@ static void reset_io_counters(struct thread_data *td, int all)
        /*
         * reset file done count if we are to start over
         */
-       if (td->o.time_based || td->o.loops || td->o.do_verify)
+       if (td->o.time_based || td->loops > 1 || td->o.do_verify)
                td->nr_done_files = 0;
 }