From 5bd5f71a3e54950fb4bee64c7ad5edc67e40b8c8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sun, 3 Feb 2013 14:20:44 +0100 Subject: [PATCH] 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 --- backend.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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; } -- 2.25.1