From nobody Mon Feb 9 03:18:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654787685; cv=none; d=zohomail.com; s=zohoarc; b=YyUpjHfnM/R9d+CdTSG5IvEPQ0WWaCcNBJEUf2tN+MZwvkK+zd7Jj327AFDW/R+V4jZEYRl24rfRyN+Vfdrvh5C86UtQlDBQVMn1wcFoVMPGMdlPsVpBHRcTtOc4TNrF9rkQwqWkZGbSX+ULYNUnPlDmiWvW5TKhSWKcOiwU5ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654787685; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=socKiO2gGChieqontE2gzzIATZPaTJJpq+zV51PiYOs=; b=EXGgXZAlOXoWFlsaZohNVOBtgN6PvlicA6LEXb5OxiFZNmIydnskq5OotNS8F4DveHmd5puRx7FIUuIBmpZhhM5oWCdcSwpCblNwIgYLO1vual6HcdXK6bh6fhhQdG+Djiiscqdo+zLCkWkjfRoQYmexCrVvT0o6t91+B3H4wec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654787685810589.9041626833006; Thu, 9 Jun 2022 08:14:45 -0700 (PDT) Received: from localhost ([::1]:60952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzJrw-00024y-Qu for importer@patchew.org; Thu, 09 Jun 2022 11:14:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzIT9-0008L2-3P for qemu-devel@nongnu.org; Thu, 09 Jun 2022 09:45:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzIT7-0004gf-Ci for qemu-devel@nongnu.org; Thu, 09 Jun 2022 09:45:02 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-Uo-gn7OmNzycBqlcCIICNA-1; Thu, 09 Jun 2022 09:44:55 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1DACC1C05EB1; Thu, 9 Jun 2022 13:44:55 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D305A492C3B; Thu, 9 Jun 2022 13:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654782300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=socKiO2gGChieqontE2gzzIATZPaTJJpq+zV51PiYOs=; b=Ok9CQwf65AbYmoAcYiAuG5Lb9LM9ONoLuWFtTRDEMox10f21OMpUx7oAkxiRn9IHXRn2uS ZuluWPbGvO+twQkP9dcwgQ73sBS98vJwFg3UuBzy2NZVtD4z0SgTlW/xpvOXnpGMqOqdh5 qLVL2RpzvhnPD3wJ3zo5sj7/s9ghHJY= X-MC-Unique: Uo-gn7OmNzycBqlcCIICNA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Weil , Stefan Hajnoczi , Fam Zheng , Paolo Bonzini , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 1/2] linux-aio: use LinuxAioState from the running thread Date: Thu, 9 Jun 2022 09:44:51 -0400 Message-Id: <20220609134452.1146309-2-eesposit@redhat.com> In-Reply-To: <20220609134452.1146309-1-eesposit@redhat.com> References: <20220609134452.1146309-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654787686715100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Remove usage of aio_context_acquire by always submitting asynchronous AIO to the current thread's LinuxAioState. Signed-off-by: Paolo Bonzini Signed-off-by: Emanuele Giuseppe Esposito --- block/file-posix.c | 3 ++- block/linux-aio.c | 13 ++++++------- include/block/aio.h | 4 ---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 48cd096624..33f92f004a 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2086,7 +2086,8 @@ static int coroutine_fn raw_co_prw(BlockDriverState *= bs, uint64_t offset, #endif #ifdef CONFIG_LINUX_AIO } else if (s->use_linux_aio) { - LinuxAioState *aio =3D aio_get_linux_aio(bdrv_get_aio_context(bs)); + AioContext *ctx =3D qemu_get_current_aio_context(); + LinuxAioState *aio =3D aio_get_linux_aio(ctx); assert(qiov->size =3D=3D bytes); return laio_co_submit(bs, aio, s->fd, offset, qiov, type, s->aio_max_batch); diff --git a/block/linux-aio.c b/block/linux-aio.c index 4c423fcccf..1d3cc767d1 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -16,6 +16,9 @@ #include "qemu/coroutine.h" #include "qapi/error.h" =20 +/* Only used for assertions. */ +#include "qemu/coroutine_int.h" + #include =20 /* @@ -56,10 +59,8 @@ struct LinuxAioState { io_context_t ctx; EventNotifier e; =20 - /* io queue for submit at batch. Protected by AioContext lock. */ + /* All data is only used in one I/O thread. */ LaioQueue io_q; - - /* I/O completion processing. Only runs in I/O thread. */ QEMUBH *completion_bh; int event_idx; int event_max; @@ -102,9 +103,8 @@ static void qemu_laio_process_completion(struct qemu_la= iocb *laiocb) * later. Coroutines cannot be entered recursively so avoid doing * that! */ - if (!qemu_coroutine_entered(laiocb->co)) { - aio_co_wake(laiocb->co); - } + assert(laiocb->co->ctx =3D=3D laiocb->ctx->aio_context); + qemu_coroutine_enter_if_inactive(laiocb->co); } =20 /** @@ -238,7 +238,6 @@ static void qemu_laio_process_completions_and_submit(Li= nuxAioState *s) if (!s->io_q.plugged && !QSIMPLEQ_EMPTY(&s->io_q.pending)) { ioq_submit(s); } - aio_context_release(s->aio_context); } =20 static void qemu_laio_completion_bh(void *opaque) diff --git a/include/block/aio.h b/include/block/aio.h index d128558f1d..8bb5eea4a9 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -200,10 +200,6 @@ struct AioContext { struct ThreadPool *thread_pool; =20 #ifdef CONFIG_LINUX_AIO - /* - * State for native Linux AIO. Uses aio_context_acquire/release for - * locking. - */ struct LinuxAioState *linux_aio; #endif #ifdef CONFIG_LINUX_IO_URING --=20 2.31.1 From nobody Mon Feb 9 03:18:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1654785129; cv=none; d=zohomail.com; s=zohoarc; b=W91zU8+CyAdHldaugDwfc321JeyCo2priK91ba34DMANpnwKhc/v32VPIe1RhJX7r6qybPsFsCqgNd8IDFwavp2gvA+KEFOPR+/LQz0PxjJjLDGELqSpBNfjTeqGEKLu+VEc4vs31d3i1WM/WJ0eC2uG7JAwBIVodv4sGJApPVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654785129; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p8TUi3ulWNE26DtQH+OwMJj6TdfssoBsYXVV33K4Dso=; b=bdFqSQALLsWHCm3OVGBvcidWudp3B1zFeJHPShmr1PBD9tnBnTD5cfCRBDfdmCARuaIPC/pmx+SUzuI6QfuBdJ2f3A+YJQnby/JqcYBRTQUiV9X6d65iyoyxlIHzP/OBWZI2ZTjfNX1gEyyNYlKCMyBJWYrJSUyyefrjqpN6+Ws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654785129975690.0455206644943; Thu, 9 Jun 2022 07:32:09 -0700 (PDT) Received: from localhost ([::1]:60582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzJCi-0002Bp-TY for importer@patchew.org; Thu, 09 Jun 2022 10:32:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzIT7-0008Jb-Jc for qemu-devel@nongnu.org; Thu, 09 Jun 2022 09:45:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzIT5-0004g0-R2 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 09:45:01 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-575-HZFghOK5Prif4bROX5V6KA-1; Thu, 09 Jun 2022 09:44:55 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 639761C05EAE; Thu, 9 Jun 2022 13:44:55 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25C8F492C3B; Thu, 9 Jun 2022 13:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654782299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p8TUi3ulWNE26DtQH+OwMJj6TdfssoBsYXVV33K4Dso=; b=Qy4GAm9Ii9jG5+/a0CHEg8n2/Dx7l23DIyUitekob0uFR+VgNuv+HGKbQGry+YakArn13c kwT9Ppc3C5GMRnsdk9mMM5jOvRUaUCOb0hitfeAWbXyniEKQpTF3yTrZBJauRs2tuQrsFz CR+l4FlJwFb7rOEFWBdVWsjo/KSsK/I= X-MC-Unique: HZFghOK5Prif4bROX5V6KA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefan Weil , Stefan Hajnoczi , Fam Zheng , Paolo Bonzini , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 2/2] thread-pool: use ThreadPool from the running thread Date: Thu, 9 Jun 2022 09:44:52 -0400 Message-Id: <20220609134452.1146309-3-eesposit@redhat.com> In-Reply-To: <20220609134452.1146309-1-eesposit@redhat.com> References: <20220609134452.1146309-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1654785131599100001 Content-Type: text/plain; charset="utf-8" Remove usage of aio_context_acquire by always submitting work items to the current thread's ThreadPool. Signed-off-by: Paolo Bonzini Signed-off-by: Emanuele Giuseppe Esposito --- block/file-posix.c | 19 +++++++++---------- block/file-win32.c | 2 +- block/qcow2-threads.c | 2 +- util/thread-pool.c | 6 +----- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 33f92f004a..15765453b3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2053,11 +2053,10 @@ out: return result; } =20 -static int coroutine_fn raw_thread_pool_submit(BlockDriverState *bs, - ThreadPoolFunc func, void *= arg) +static int coroutine_fn raw_thread_pool_submit(ThreadPoolFunc func, void *= arg) { /* @bs can be NULL, bdrv_get_aio_context() returns the main context th= en */ - ThreadPool *pool =3D aio_get_thread_pool(bdrv_get_aio_context(bs)); + ThreadPool *pool =3D aio_get_thread_pool(qemu_get_current_aio_context(= )); return thread_pool_submit_co(pool, func, arg); } =20 @@ -2107,7 +2106,7 @@ static int coroutine_fn raw_co_prw(BlockDriverState *= bs, uint64_t offset, }; =20 assert(qiov->size =3D=3D bytes); - return raw_thread_pool_submit(bs, handle_aiocb_rw, &acb); + return raw_thread_pool_submit(handle_aiocb_rw, &acb); } =20 static int coroutine_fn raw_co_preadv(BlockDriverState *bs, int64_t offset, @@ -2182,7 +2181,7 @@ static int raw_co_flush_to_disk(BlockDriverState *bs) return luring_co_submit(bs, aio, s->fd, 0, NULL, QEMU_AIO_FLUSH); } #endif - return raw_thread_pool_submit(bs, handle_aiocb_flush, &acb); + return raw_thread_pool_submit(handle_aiocb_flush, &acb); } =20 static void raw_aio_attach_aio_context(BlockDriverState *bs, @@ -2244,7 +2243,7 @@ raw_regular_truncate(BlockDriverState *bs, int fd, in= t64_t offset, }, }; =20 - return raw_thread_pool_submit(bs, handle_aiocb_truncate, &acb); + return raw_thread_pool_submit(handle_aiocb_truncate, &acb); } =20 static int coroutine_fn raw_co_truncate(BlockDriverState *bs, int64_t offs= et, @@ -2994,7 +2993,7 @@ raw_do_pdiscard(BlockDriverState *bs, int64_t offset,= int64_t bytes, acb.aio_type |=3D QEMU_AIO_BLKDEV; } =20 - ret =3D raw_thread_pool_submit(bs, handle_aiocb_discard, &acb); + ret =3D raw_thread_pool_submit(handle_aiocb_discard, &acb); raw_account_discard(s, bytes, ret); return ret; } @@ -3069,7 +3068,7 @@ raw_do_pwrite_zeroes(BlockDriverState *bs, int64_t of= fset, int64_t bytes, handler =3D handle_aiocb_write_zeroes; } =20 - return raw_thread_pool_submit(bs, handler, &acb); + return raw_thread_pool_submit(handler, &acb); } =20 static int coroutine_fn raw_co_pwrite_zeroes( @@ -3280,7 +3279,7 @@ static int coroutine_fn raw_co_copy_range_to(BlockDri= verState *bs, }, }; =20 - return raw_thread_pool_submit(bs, handle_aiocb_copy_range, &acb); + return raw_thread_pool_submit(handle_aiocb_copy_range, &acb); } =20 BlockDriver bdrv_file =3D { @@ -3626,7 +3625,7 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long int= req, void *buf) }, }; =20 - return raw_thread_pool_submit(bs, handle_aiocb_ioctl, &acb); + return raw_thread_pool_submit(handle_aiocb_ioctl, &acb); } #endif /* linux */ =20 diff --git a/block/file-win32.c b/block/file-win32.c index ec9d64d0e4..3d7f59a592 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -167,7 +167,7 @@ static BlockAIOCB *paio_submit(BlockDriverState *bs, HA= NDLE hfile, acb->aio_offset =3D offset; =20 trace_file_paio_submit(acb, opaque, offset, count, type); - pool =3D aio_get_thread_pool(bdrv_get_aio_context(bs)); + pool =3D aio_get_thread_pool(qemu_get_current_aio_context()); return thread_pool_submit_aio(pool, aio_worker, acb, cb, opaque); } =20 diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c index 1914baf456..9e370acbb3 100644 --- a/block/qcow2-threads.c +++ b/block/qcow2-threads.c @@ -42,7 +42,7 @@ qcow2_co_process(BlockDriverState *bs, ThreadPoolFunc *fu= nc, void *arg) { int ret; BDRVQcow2State *s =3D bs->opaque; - ThreadPool *pool =3D aio_get_thread_pool(bdrv_get_aio_context(bs)); + ThreadPool *pool =3D aio_get_thread_pool(qemu_get_current_aio_context(= )); =20 qemu_co_mutex_lock(&s->lock); while (s->nb_threads >=3D QCOW2_MAX_THREADS) { diff --git a/util/thread-pool.c b/util/thread-pool.c index 31113b5860..74ce35f7a6 100644 --- a/util/thread-pool.c +++ b/util/thread-pool.c @@ -48,7 +48,7 @@ struct ThreadPoolElement { /* Access to this list is protected by lock. */ QTAILQ_ENTRY(ThreadPoolElement) reqs; =20 - /* Access to this list is protected by the global mutex. */ + /* This list is only written by the thread pool's mother thread. */ QLIST_ENTRY(ThreadPoolElement) all; }; =20 @@ -175,7 +175,6 @@ static void thread_pool_completion_bh(void *opaque) ThreadPool *pool =3D opaque; ThreadPoolElement *elem, *next; =20 - aio_context_acquire(pool->ctx); restart: QLIST_FOREACH_SAFE(elem, &pool->head, all, next) { if (elem->state !=3D THREAD_DONE) { @@ -195,9 +194,7 @@ restart: */ qemu_bh_schedule(pool->completion_bh); =20 - aio_context_release(pool->ctx); elem->common.cb(elem->common.opaque, elem->ret); - aio_context_acquire(pool->ctx); =20 /* We can safely cancel the completion_bh here regardless of s= omeone * else having scheduled it meanwhile because we reenter the @@ -211,7 +208,6 @@ restart: qemu_aio_unref(elem); } } - aio_context_release(pool->ctx); } =20 static void thread_pool_cancel(BlockAIOCB *acb) --=20 2.31.1