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 5c35757ce1ad0316214a58b83efcd9278cd2887b..d39968519fe3680a8ab0fe87716087eb61ad1d6e 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 b9b098668094143f4a3e998d7f1294aca1dfac32..9bec0c329e742aaa64e883148247bd803fa27113 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 69a85128703395ae01031bddf1806d468b65c290..46a3979fde6190cc5d23603703334158f1267cf0 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)