workqueue: properly account ->cur_depth
[fio.git] / workqueue.c
index 7a69be21803656a10326c1b525a58502289ee39c..27d1060c6e6f2b1cd6710d540e63e9b0c621691c 100644 (file)
@@ -79,7 +79,7 @@ static struct submit_worker *get_submit_worker(struct workqueue *wq)
        return sw;
 }
 
-static int all_sw_idle(struct workqueue *wq)
+static bool all_sw_idle(struct workqueue *wq)
 {
        int i;
 
@@ -87,10 +87,10 @@ static int all_sw_idle(struct workqueue *wq)
                struct submit_worker *sw = &wq->workers[i];
 
                if (!(sw->flags & SW_F_IDLE))
-                       return 0;
+                       return false;
        }
 
-       return 1;
+       return true;
 }
 
 /*
@@ -283,8 +283,12 @@ static void *worker_thread(void *data)
 
                        if (td->io_u_queued || td->cur_depth ||
                            td->io_u_in_flight) {
+                               int ret;
+
                                pthread_mutex_unlock(&sw->lock);
-                               io_u_quiesce(td);
+                               ret = io_u_quiesce(td);
+                               if (ret > 0)
+                                       td->cur_depth -= ret;
                                pthread_mutex_lock(&sw->lock);
                        }