X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/81ab11a7a524d12412a59ef49c6b270671e62ea0..24790aefe03381e47679c9459a3cd0b5e5af751a:/thread-pool.c diff --git a/thread-pool.c b/thread-pool.c index 86fa4a8f89..03ba0b02a4 100644 --- a/thread-pool.c +++ b/thread-pool.c @@ -14,11 +14,11 @@ * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/queue.h" #include "qemu/thread.h" -#include "qemu/osdep.h" -#include "block/coroutine.h" +#include "qemu/coroutine.h" #include "trace.h" #include "block/thread-pool.h" #include "qemu/main-loop.h" @@ -34,7 +34,7 @@ enum ThreadState { }; struct ThreadPoolElement { - BlockDriverAIOCB common; + BlockAIOCB common; ThreadPool *pool; ThreadPoolFunc *func; void *arg; @@ -170,12 +170,12 @@ restart: if (elem->state != THREAD_DONE) { continue; } - if (elem->state == THREAD_DONE) { - trace_thread_pool_complete(pool, elem, elem->common.opaque, - elem->ret); - } - if (elem->state == THREAD_DONE && elem->common.cb) { - QLIST_REMOVE(elem, all); + + trace_thread_pool_complete(pool, elem, elem->common.opaque, + elem->ret); + QLIST_REMOVE(elem, all); + + if (elem->common.cb) { /* Read state before ret. */ smp_rmb(); @@ -188,14 +188,12 @@ restart: qemu_aio_unref(elem); goto restart; } else { - /* remove the request */ - QLIST_REMOVE(elem, all); qemu_aio_unref(elem); } } } -static void thread_pool_cancel(BlockDriverAIOCB *acb) +static void thread_pool_cancel(BlockAIOCB *acb) { ThreadPoolElement *elem = (ThreadPoolElement *)acb; ThreadPool *pool = elem->pool; @@ -220,7 +218,7 @@ static void thread_pool_cancel(BlockDriverAIOCB *acb) qemu_mutex_unlock(&pool->lock); } -static AioContext *thread_pool_get_aio_context(BlockDriverAIOCB *acb) +static AioContext *thread_pool_get_aio_context(BlockAIOCB *acb) { ThreadPoolElement *elem = (ThreadPoolElement *)acb; ThreadPool *pool = elem->pool; @@ -233,9 +231,9 @@ static const AIOCBInfo thread_pool_aiocb_info = { .get_aio_context = thread_pool_get_aio_context, }; -BlockDriverAIOCB *thread_pool_submit_aio(ThreadPool *pool, +BlockAIOCB *thread_pool_submit_aio(ThreadPool *pool, ThreadPoolFunc *func, void *arg, - BlockDriverCompletionFunc *cb, void *opaque) + BlockCompletionFunc *cb, void *opaque) { ThreadPoolElement *req;