workqueue: ensure that workqueue_enqueue() can't fail
authorJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 19:25:07 +0000 (12:25 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 19:25:07 +0000 (12:25 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
workqueue.c
workqueue.h

index 5c35757..d399685 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -934,13 +934,10 @@ static uint64_t do_io(struct thread_data *td)
                        if (td->error)
                                break;
 
-                       ret = workqueue_enqueue(&td->io_wq, &io_u->work);
-                       if (ret)
-                               ret = FIO_Q_QUEUED;
-                       else
-                               ret = FIO_Q_BUSY;
+                       workqueue_enqueue(&td->io_wq, &io_u->work);
+                       ret = FIO_Q_QUEUED;
 
-                       if (ret == FIO_Q_QUEUED && ddir_rw(ddir)) {
+                       if (ddir_rw(ddir)) {
                                td->io_issues[ddir]++;
                                td->io_issue_bytes[ddir] += blen;
                                td->rate_io_issue_bytes[ddir] += blen;
index b9b0986..9bec0c3 100644 (file)
@@ -99,23 +99,20 @@ void workqueue_flush(struct workqueue *wq)
 /*
  * Must be serialized by caller. Returns true for queued, false for busy.
  */
-bool workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work)
+void workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work)
 {
        struct submit_worker *sw;
 
        sw = get_submit_worker(wq);
-       if (sw) {
-               pthread_mutex_lock(&sw->lock);
-               flist_add_tail(&work->list, &sw->work_list);
-               sw->seq = ++wq->work_seq;
-               sw->flags &= ~SW_F_IDLE;
-               pthread_mutex_unlock(&sw->lock);
+       assert(sw);
 
-               pthread_cond_signal(&sw->cond);
-               return true;
-       }
+       pthread_mutex_lock(&sw->lock);
+       flist_add_tail(&work->list, &sw->work_list);
+       sw->seq = ++wq->work_seq;
+       sw->flags &= ~SW_F_IDLE;
+       pthread_mutex_unlock(&sw->lock);
 
-       return false;
+       pthread_cond_signal(&sw->cond);
 }
 
 static void handle_list(struct submit_worker *sw, struct flist_head *list)
index 69a8512..46a3979 100644 (file)
@@ -63,7 +63,7 @@ struct workqueue {
 int workqueue_init(struct thread_data *td, struct workqueue *wq, struct workqueue_ops *ops, unsigned int max_workers);
 void workqueue_exit(struct workqueue *wq);
 
-bool workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work);
+void workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work);
 void workqueue_flush(struct workqueue *wq);
 
 static inline bool workqueue_pre_sleep_check(struct submit_worker *sw)