Add iodepth_batch_complete control

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/ioengines.c b/ioengines.c
index 8975591..e447539 100644
--- a/ioengines.c
+++ b/ioengines.c
@@ -195,9 +195,13 @@
 		if (r < 0)
 			goto out;
 	}
+	if (max > td->cur_depth)
+		max = td->cur_depth;
+	if (min > max)
+		max = min;
 
 	r = 0;
-	if (td->io_ops->getevents)
+	if (max && td->io_ops->getevents)
 		r = td->io_ops->getevents(td, min, max, t);
 out:
 	if (r >= 0)