Don't pass more than the queued IO depth in to getevents()
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index dfd15e0f5db1e943a9aec595454cf1f601e97fea..434b50372832c49952fd2195c4e4377ae3088227 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -536,7 +536,8 @@ sync_done:
                 */
                full = queue_full(td) || ret == FIO_Q_BUSY;
                if (full || !td->o.iodepth_batch_complete) {
                 */
                full = queue_full(td) || ret == FIO_Q_BUSY;
                if (full || !td->o.iodepth_batch_complete) {
-                       min_events = td->o.iodepth_batch_complete;
+                       min_events = min(td->o.iodepth_batch_complete,
+                                        td->cur_depth);
                        if (full && !min_events)
                                min_events = 1;
 
                        if (full && !min_events)
                                min_events = 1;
 
@@ -581,7 +582,8 @@ static void do_io(struct thread_data *td)
        else
                td_set_runstate(td, TD_RUNNING);
 
        else
                td_set_runstate(td, TD_RUNNING);
 
-       while ((td->this_io_bytes[0] + td->this_io_bytes[1]) < td->o.size) {
+       while ( (td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
+               ((td->this_io_bytes[0] + td->this_io_bytes[1]) < td->o.size) ) {
                struct timeval comp_time;
                unsigned long bytes_done[2] = { 0, 0 };
                int min_evts = 0;
                struct timeval comp_time;
                unsigned long bytes_done[2] = { 0, 0 };
                int min_evts = 0;
@@ -606,7 +608,8 @@ static void do_io(struct thread_data *td)
                 * Add verification end_io handler, if asked to verify
                 * a previously written file.
                 */
                 * Add verification end_io handler, if asked to verify
                 * a previously written file.
                 */
-               if (td->o.verify != VERIFY_NONE && io_u->ddir == DDIR_READ) {
+               if (td->o.verify != VERIFY_NONE && io_u->ddir == DDIR_READ &&
+                   !td_rw(td)) {
                        if (td->o.verify_async)
                                io_u->end_io = verify_io_u_async;
                        else
                        if (td->o.verify_async)
                                io_u->end_io = verify_io_u_async;
                        else
@@ -686,7 +689,8 @@ sync_done:
                 */
                full = queue_full(td) || ret == FIO_Q_BUSY;
                if (full || !td->o.iodepth_batch_complete) {
                 */
                full = queue_full(td) || ret == FIO_Q_BUSY;
                if (full || !td->o.iodepth_batch_complete) {
-                       min_evts = td->o.iodepth_batch_complete;
+                       min_evts = min(td->o.iodepth_batch_complete,
+                                       td->cur_depth);
                        if (full && !min_evts)
                                min_evts = 1;
 
                        if (full && !min_evts)
                                min_evts = 1;
 
@@ -1193,6 +1197,10 @@ err:
        if (td->error)
                printf("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
                                                        td->verror);
        if (td->error)
                printf("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
                                                        td->verror);
+
+       if (td->o.verify_async)
+               verify_async_exit(td);
+
        close_and_free_files(td);
        close_ioengine(td);
        cleanup_io_u(td);
        close_and_free_files(td);
        close_ioengine(td);
        cleanup_io_u(td);
@@ -1203,9 +1211,6 @@ err:
                td_verror(td, ret, "fio_cpuset_exit");
        }
 
                td_verror(td, ret, "fio_cpuset_exit");
        }
 
-       if (td->o.verify_async)
-               verify_async_exit(td);
-
        /*
         * do this very late, it will log file closing as well
         */
        /*
         * do this very late, it will log file closing as well
         */