From b93a8eb09c7904790f78956cb481bd55b3ac8c82 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 9 Mar 2018 07:59:03 -0700 Subject: [PATCH] mutex: fix other locations where we are not waking within the lock Our workqueue implementation had a few cases where it did not wake while holding the lock, fix those up. Ditto for verify, where async IO completion also needed the ordering switched. Also see commit e4ccf13bad6d. Signed-off-by: Jens Axboe --- verify.c | 2 +- workqueue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/verify.c b/verify.c index aeafdb5d..d070f331 100644 --- a/verify.c +++ b/verify.c @@ -748,9 +748,9 @@ int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr) } flist_add_tail(&io_u->verify_list, &td->verify_list); *io_u_ptr = NULL; - pthread_mutex_unlock(&td->io_u_lock); pthread_cond_signal(&td->verify_cond); + pthread_mutex_unlock(&td->io_u_lock); return 0; } diff --git a/workqueue.c b/workqueue.c index 1131400f..18ec198b 100644 --- a/workqueue.c +++ b/workqueue.c @@ -109,9 +109,9 @@ void workqueue_enqueue(struct workqueue *wq, struct workqueue_work *work) flist_add_tail(&work->list, &sw->work_list); sw->seq = ++wq->work_seq; sw->flags &= ~SW_F_IDLE; - pthread_mutex_unlock(&sw->lock); pthread_cond_signal(&sw->cond); + pthread_mutex_unlock(&sw->lock); } static void handle_list(struct submit_worker *sw, struct flist_head *list) -- 2.25.1