[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/27] blockjob: drop AioContext lock before calling bdrv_graph_wr
From: |
Kevin Wolf |
Subject: |
[PULL 11/27] blockjob: drop AioContext lock before calling bdrv_graph_wrlock() |
Date: |
Tue, 31 Oct 2023 19:59:02 +0100 |
From: Fiona Ebner <f.ebner@proxmox.com>
Same rationale as in 31b2ddfea3 ("graph-lock: Unlock the AioContext
while polling"). Otherwise, a deadlock can happen.
The alternative would be to pass a BlockDriverState along to
bdrv_graph_wrlock(), but there is no BlockDriverState readily
available and it's also better conceptually, because the lock is held
for the job.
The function is always called with the job's AioContext lock held, via
one of the .abort, .clean, .free or .prepare job driver functions.
Thus, it's safe to drop it.
While mirror_exit_common() does hold a second AioContext lock while
calling block_job_remove_all_bdrv(), that is for the main thread's
AioContext and does not need to be dropped (bdrv_graph_wrlock(bs) also
skips dropping the lock if bdrv_get_aio_context(bs) ==
qemu_get_aio_context()).
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20231019131936.414246-2-f.ebner@proxmox.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockjob.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/blockjob.c b/blockjob.c
index 807f992b59..953dc1b6dc 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -198,7 +198,9 @@ void block_job_remove_all_bdrv(BlockJob *job)
* one to make sure that such a concurrent access does not attempt
* to process an already freed BdrvChild.
*/
+ aio_context_release(job->job.aio_context);
bdrv_graph_wrlock(NULL);
+ aio_context_acquire(job->job.aio_context);
while (job->nodes) {
GSList *l = job->nodes;
BdrvChild *c = l->data;
--
2.41.0
- [PULL 06/27] iotests/{024, 271}: add testcases for qemu-img rebase, (continued)
- [PULL 06/27] iotests/{024, 271}: add testcases for qemu-img rebase, Kevin Wolf, 2023/10/31
- [PULL 16/27] virtio: use defer_call() in virtio_irqfd_notify(), Kevin Wolf, 2023/10/31
- [PULL 15/27] util/defer-call: move defer_call() to util/, Kevin Wolf, 2023/10/31
- [PULL 21/27] block/mirror: determine copy_to_target only once, Kevin Wolf, 2023/10/31
- [PULL 19/27] block/mirror: set actively_synced even after the job is ready, Kevin Wolf, 2023/10/31
- [PULL 20/27] block/mirror: move dirty bitmap to filter, Kevin Wolf, 2023/10/31
- [PULL 17/27] virtio-blk: remove batch notification BH, Kevin Wolf, 2023/10/31
- [PULL 13/27] blockdev: mirror: avoid potential deadlock when using iothread, Kevin Wolf, 2023/10/31
- [PULL 18/27] blockjob: introduce block-job-change QMP command, Kevin Wolf, 2023/10/31
- [PULL 09/27] block: Fix locking in media change monitor commands, Kevin Wolf, 2023/10/31
- [PULL 11/27] blockjob: drop AioContext lock before calling bdrv_graph_wrlock(),
Kevin Wolf <=
- [PULL 25/27] blockjob: query driver-specific info via a new 'query' driver method, Kevin Wolf, 2023/10/31
- [PULL 12/27] block: avoid potential deadlock during bdrv_graph_wrlock() in bdrv_close(), Kevin Wolf, 2023/10/31
- [PULL 14/27] block: rename blk_io_plug_call() API to defer_call(), Kevin Wolf, 2023/10/31
- [PULL 10/27] iotests: Test media change with iothreads, Kevin Wolf, 2023/10/31
- [PULL 23/27] qapi/block-core: use JobType for BlockJobInfo's type, Kevin Wolf, 2023/10/31
- [PULL 22/27] mirror: implement mirror_change method, Kevin Wolf, 2023/10/31
- [PULL 26/27] mirror: return mirror-specific information upon query, Kevin Wolf, 2023/10/31
- [PULL 27/27] iotests: add test for changing mirror's copy_mode, Kevin Wolf, 2023/10/31
- [PULL 24/27] qapi/block-core: turn BlockJobInfo into a union, Kevin Wolf, 2023/10/31
- [PULL 08/27] iotests: add tests for "qemu-img rebase" with compression, Kevin Wolf, 2023/10/31