mutex: fix other locations where we are not waking within the lock
authorJens Axboe <axboe@kernel.dk>
Fri, 9 Mar 2018 14:59:03 +0000 (07:59 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 9 Mar 2018 14:59:03 +0000 (07:59 -0700)
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 <axboe@kernel.dk>
verify.c
workqueue.c

index aeafdb5..d070f33 100644 (file)
--- 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;
 }
 
index 1131400..18ec198 100644 (file)
@@ -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)