backend: only terminate multiple loops if we did no IO
authorJens Axboe <axboe@fb.com>
Mon, 21 Dec 2015 17:01:40 +0000 (10:01 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 21 Dec 2015 17:01:40 +0000 (10:01 -0700)
Commit 095196b1e76b introduced a stop point if do_io() returned
nothing, but that only counts writes and trims. Change that to
count all types of IO.

Fixes: 095196b1e76b ("backend: terminate loop if we didn't do IO")
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c

index 89ac76b379813284648d83763aa63b101328ae88..9920e630dc113bff1288ffb9d2f8bf160ac5347c 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -808,15 +808,14 @@ static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
  *
  * Returns number of bytes written and trimmed.
  */
  *
  * Returns number of bytes written and trimmed.
  */
-static uint64_t do_io(struct thread_data *td)
+static void do_io(struct thread_data *td, uint64_t *bytes_done)
 {
        unsigned int i;
        int ret = 0;
        uint64_t total_bytes, bytes_issued = 0;
 {
        unsigned int i;
        int ret = 0;
        uint64_t total_bytes, bytes_issued = 0;
-       uint64_t this_bytes[2];
 
 
-       this_bytes[0] = td->bytes_done[DDIR_WRITE];
-       this_bytes[1] = td->bytes_done[DDIR_TRIM];
+       for (i = 0; i < DDIR_RWDIR_CNT; i++)
+               bytes_done[i] = td->bytes_done[i];
 
        if (in_ramp_time(td))
                td_set_runstate(td, TD_RAMP);
 
        if (in_ramp_time(td))
                td_set_runstate(td, TD_RAMP);
@@ -1050,8 +1049,8 @@ reap:
        if (!ddir_rw_sum(td->this_io_bytes))
                td->done = 1;
 
        if (!ddir_rw_sum(td->this_io_bytes))
                td->done = 1;
 
-       return (td->bytes_done[DDIR_WRITE] - this_bytes[0]) +
-               (td->bytes_done[DDIR_TRIM] - this_bytes[1]);
+       for (i = 0; i < DDIR_RWDIR_CNT; i++)
+               bytes_done[i] = td->bytes_done[i] - bytes_done[i];
 }
 
 static void cleanup_io_u(struct thread_data *td)
 }
 
 static void cleanup_io_u(struct thread_data *td)
@@ -1603,9 +1602,17 @@ static void *thread_main(void *data)
                if (td->o.verify_only && (td_write(td) || td_rw(td)))
                        verify_bytes = do_dry_run(td);
                else {
                if (td->o.verify_only && (td_write(td) || td_rw(td)))
                        verify_bytes = do_dry_run(td);
                else {
-                       verify_bytes = do_io(td);
-                       if (!verify_bytes)
+                       uint64_t bytes_done[DDIR_RWDIR_CNT];
+
+                       do_io(td, bytes_done);
+
+                       if (!ddir_rw_sum(bytes_done)) {
                                fio_mark_td_terminate(td);
                                fio_mark_td_terminate(td);
+                               verify_bytes = 0;
+                       } else {
+                               verify_bytes = bytes_done[DDIR_WRITE] +
+                                               bytes_done[DDIR_TRIM];
+                       }
                }
 
                clear_state = 1;
                }
 
                clear_state = 1;