Fix failure to exit IO loop on some IO sizes
authorJens Axboe <axboe@kernel.dk>
Sun, 3 Feb 2013 13:20:44 +0000 (14:20 +0100)
committerJens Axboe <axboe@kernel.dk>
Sun, 3 Feb 2013 13:20:44 +0000 (14:20 +0100)
If the size of a file isn't a multiple of the block size being
used, it can cause fio to exit the IO loop, check bytes done,
and then decide to do one more loop since we didn't do quite
as much IO as we wanted to. This happens because the minimum
block size is larger than the remainder. So check for that,
and stop if we need to.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c

index 218ae2545db8fbf5e29a89ef43f954ac6f25bc9c..6461fff70c21aa37192d3c2dd40a1831543b7a05 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -813,7 +813,7 @@ sync_done:
 
                i = td->cur_depth;
                if (i) {
-                       ret = io_u_queued_complete(td, i, NULL);
+                       ret = io_u_queued_complete(td, i, bytes_done);
                        if (td->o.fill_device && td->error == ENOSPC)
                                td->error = 0;
                }
@@ -1017,8 +1017,19 @@ static int keep_running(struct thread_data *td)
                return 1;
        }
 
-       if (ddir_rw_sum(td->io_bytes) < td->o.size)
+       if (ddir_rw_sum(td->io_bytes) < td->o.size) {
+               uint64_t diff;
+
+               /*
+                * If the difference is less than the minimum IO size, we
+                * are done.
+                */
+               diff = td->o.size - ddir_rw_sum(td->io_bytes);
+               if (diff < td->o.rw_min_bs)
+                       return 0;
+
                return 1;
+       }
 
        return 0;
 }