From 26de50cf42e452f2f0bc7dde9faca18fd9976991 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 8 Dec 2015 12:25:07 -0700 Subject: [PATCH] workqueue: ensure that workqueue_enqueue() can't fail Signed-off-by: Jens Axboe --- backend.c | 9 +++------ workqueue.c | 19 ++++++++----------- workqueue.h | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/backend.c b/backend.c index 5c35757c..d3996851 100644 --- 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; diff --git a/workqueue.c b/workqueue.c index b9b09866..9bec0c32 100644 --- a/workqueue.c +++ b/workqueue.c @@ -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) diff --git a/workqueue.h b/workqueue.h index 69a85128..46a3979f 100644 --- a/workqueue.h +++ b/workqueue.h @@ -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) -- 2.25.1