From: Jens Axboe Date: Sun, 3 Feb 2013 13:20:44 +0000 (+0100) Subject: Fix failure to exit IO loop on some IO sizes X-Git-Tag: fio-2.0.14~40 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=5bd5f71a3e54950fb4bee64c7ad5edc67e40b8c8 Fix failure to exit IO loop on some IO sizes 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 --- diff --git a/backend.c b/backend.c index 218ae254..6461fff7 100644 --- 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; }