[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/32] mirror: Hold main AioContext lock for calling bdrv_open_bac
From: |
Kevin Wolf |
Subject: |
[PULL 05/32] mirror: Hold main AioContext lock for calling bdrv_open_backing_file() |
Date: |
Tue, 30 May 2023 18:32:12 +0200 |
bdrv_open_backing_file() calls bdrv_open_inherit(), so all callers must
hold the main AioContext lock.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230525124713.401149-6-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 2 ++
block/mirror.c | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/block.c b/block.c
index 79bc9c01de..be9ae364fb 100644
--- a/block.c
+++ b/block.c
@@ -3478,6 +3478,8 @@ int bdrv_set_backing_hd(BlockDriverState *bs,
BlockDriverState *backing_hd,
* itself, all options starting with "${bdref_key}." are considered part of the
* BlockdevRef.
*
+ * The caller must hold the main AioContext lock.
+ *
* TODO Can this be unified with bdrv_open_image()?
*/
int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
diff --git a/block/mirror.c b/block/mirror.c
index b7d92d1378..d3cacd1708 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -662,11 +662,15 @@ static int mirror_exit_common(Job *job)
bool abort = job->ret < 0;
int ret = 0;
+ GLOBAL_STATE_CODE();
+
if (s->prepared) {
return 0;
}
s->prepared = true;
+ aio_context_acquire(qemu_get_aio_context());
+
mirror_top_bs = s->mirror_top_bs;
bs_opaque = mirror_top_bs->opaque;
src = mirror_top_bs->backing->bs;
@@ -789,6 +793,8 @@ static int mirror_exit_common(Job *job)
bdrv_unref(mirror_top_bs);
bdrv_unref(src);
+ aio_context_release(qemu_get_aio_context());
+
return ret;
}
--
2.40.1
- [PULL 00/32] Block layer patches, Kevin Wolf, 2023/05/30
- [PULL 06/32] qcow2: Fix open with 'file' in iothread, Kevin Wolf, 2023/05/30
- [PULL 05/32] mirror: Hold main AioContext lock for calling bdrv_open_backing_file(),
Kevin Wolf <=
- [PULL 08/32] copy-before-write: Fix open with child in iothread, Kevin Wolf, 2023/05/30
- [PULL 03/32] block: Take main AioContext lock when calling bdrv_open(), Kevin Wolf, 2023/05/30
- [PULL 02/32] block: Clarify locking rules for bdrv_open(_inherit)(), Kevin Wolf, 2023/05/30
- [PULL 01/32] block-coroutine-wrapper: Take AioContext lock in no_co_wrappers, Kevin Wolf, 2023/05/30
- [PULL 04/32] block-backend: Fix blk_new_open() for iothreads, Kevin Wolf, 2023/05/30
- [PULL 19/32] block/export: stop using is_external in vhost-user-blk server, Kevin Wolf, 2023/05/30
- [PULL 16/32] virtio-scsi: stop using aio_disable_external() during unplug, Kevin Wolf, 2023/05/30
- [PULL 15/32] virtio-scsi: avoid race between unplug and transport event, Kevin Wolf, 2023/05/30
- [PULL 17/32] util/vhost-user-server: rename refcount to in_flight counter, Kevin Wolf, 2023/05/30
- [PULL 18/32] block/export: wait for vhost-user-blk requests when draining, Kevin Wolf, 2023/05/30