A bunch of fixes

Really should have been split up, but...

- Check this_io_bytes at the bottom of do_io() so that async engines
  have a chance to queue pending IO before deeming this job done.

- dprint() should use log_info(), may not be stdout we want.

- last block bug in get_next_free_block(), if max blocks wasn't a
  multiple of the bitmap size.

- Add more debug points.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.c b/fio.c
index 2ee7dca..841b59a 100644
--- a/fio.c
+++ b/fio.c
@@ -571,12 +571,6 @@
 		}
 	}
 
-	/*
-	 * stop job if we failed doing any IO
-	 */
-	if ((td->this_io_bytes[0] + td->this_io_bytes[1]) == 0)
-		td->done = 1;
-
 	if (td->o.fill_device && td->error == ENOSPC) {
 		td->error = 0;
 		td->terminate = 1;
@@ -599,6 +593,12 @@
 		}
 	} else
 		cleanup_pending_aio(td);
+
+	/*
+	 * stop job if we failed doing any IO
+	 */
+	if ((td->this_io_bytes[0] + td->this_io_bytes[1]) == 0)
+		td->done = 1;
 }
 
 static void cleanup_io_u(struct thread_data *td)
@@ -777,7 +777,10 @@
 
 	td->last_was_sync = 0;
 
-	if (td->o.time_based)
+	/*
+	 * reset file done count if we are to start over
+	 */
+	if (td->o.time_based || td->o.loops)
 		td->nr_done_files = 0;
 
 	for_each_file(td, f, i)