workqueue: ensure we see deferred error for IOs
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 56abe6fd598ef2d8ecb0c7565b9552e0755e2ad5..d28d368f694916683ad05ad34f7fa446d3c11e89 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -604,7 +604,7 @@ static inline enum fio_ddir get_rand_ddir(struct thread_data *td)
 
 int io_u_quiesce(struct thread_data *td)
 {
-       int completed = 0;
+       int ret = 0, completed = 0;
 
        /*
         * We are going to sleep, ensure that we flush anything pending as
@@ -619,17 +619,20 @@ int io_u_quiesce(struct thread_data *td)
                td_io_commit(td);
 
        while (td->io_u_in_flight) {
-               int ret;
-
                ret = io_u_queued_complete(td, 1);
                if (ret > 0)
                        completed += ret;
+               else if (ret < 0)
+                       break;
        }
 
        if (td->flags & TD_F_REGROW_LOGS)
                regrow_logs(td);
 
-       return completed;
+       if (completed)
+               return completed;
+
+       return ret;
 }
 
 static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir)
@@ -1556,6 +1559,8 @@ again:
                assert(!(td->flags & TD_F_CHILD));
                ret = pthread_cond_wait(&td->free_cond, &td->io_u_lock);
                assert(ret == 0);
+               if (td->error)
+                       return NULL;
                goto again;
        }