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 <axboe@kernel.dk>
diff --git a/backend.c b/backend.c
index 218ae25..6461fff 100644
--- a/backend.c
+++ b/backend.c
@@ -813,7 +813,7 @@
 
 		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 @@
 		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;
 }