@@ -2793,7 +2793,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
* to all devices.
*
*/
-int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Error **errp)
+int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp)
{
int ret = -1;
BlockReopenQueueEntry *bs_entry, *next;
@@ -2801,9 +2801,7 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Error **er
assert(bs_queue != NULL);
- aio_context_release(ctx);
bdrv_drain_all_begin();
- aio_context_acquire(ctx);
QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) {
if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, &local_err)) {
@@ -2847,7 +2845,7 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp)
Error *local_err = NULL;
BlockReopenQueue *queue = bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags);
- ret = bdrv_reopen_multiple(bdrv_get_aio_context(bs), queue, &local_err);
+ ret = bdrv_reopen_multiple(queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
}
@@ -1888,17 +1888,12 @@ int blk_commit_all(void)
BlockBackend *blk = NULL;
while ((blk = blk_all_next(blk)) != NULL) {
- AioContext *aio_context = blk_get_aio_context(blk);
-
- aio_context_acquire(aio_context);
if (blk_is_inserted(blk) && blk->root->bs->backing) {
int ret = bdrv_commit(blk->root->bs);
if (ret < 0) {
- aio_context_release(aio_context);
return ret;
}
}
- aio_context_release(aio_context);
}
return 0;
}
@@ -335,7 +335,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
orig_overlay_flags | BDRV_O_RDWR);
}
if (reopen_queue) {
- bdrv_reopen_multiple(bdrv_get_aio_context(bs), reopen_queue, &local_err);
+ bdrv_reopen_multiple(reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
goto fail;
@@ -505,7 +505,6 @@ static void mirror_exit(BlockJob *job, void *opaque)
{
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
MirrorExitData *data = opaque;
- AioContext *replace_aio_context = NULL;
BlockDriverState *src = s->source;
BlockDriverState *target_bs = blk_bs(s->target);
BlockDriverState *mirror_top_bs = s->mirror_top_bs;
@@ -545,11 +544,6 @@ static void mirror_exit(BlockJob *job, void *opaque)
}
}
- if (s->to_replace) {
- replace_aio_context = bdrv_get_aio_context(s->to_replace);
- aio_context_acquire(replace_aio_context);
- }
-
if (s->should_complete && data->ret == 0) {
BlockDriverState *to_replace = src;
if (s->to_replace) {
@@ -575,9 +569,6 @@ static void mirror_exit(BlockJob *job, void *opaque)
error_free(s->replace_blocker);
bdrv_unref(s->to_replace);
}
- if (replace_aio_context) {
- aio_context_release(replace_aio_context);
- }
g_free(s->replaces);
bdrv_unref(target_bs);
@@ -381,8 +381,7 @@ static void reopen_backing_file(BlockDriverState *bs, bool writable,
}
if (reopen_queue) {
- bdrv_reopen_multiple(bdrv_get_aio_context(bs),
- reopen_queue, &local_err);
+ bdrv_reopen_multiple(reopen_queue, &local_err);
error_propagate(errp, local_err);
}
}
@@ -3710,7 +3710,6 @@ void qmp_change_backing_file(const char *device,
Error **errp)
{
BlockDriverState *bs = NULL;
- AioContext *aio_context;
BlockDriverState *image_bs = NULL;
Error *local_err = NULL;
bool ro;
@@ -3722,37 +3721,34 @@ void qmp_change_backing_file(const char *device,
return;
}
- aio_context = bdrv_get_aio_context(bs);
- aio_context_acquire(aio_context);
-
image_bs = bdrv_lookup_bs(NULL, image_node_name, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- goto out;
+ return;
}
if (!image_bs) {
error_setg(errp, "image file not found");
- goto out;
+ return;
}
if (bdrv_find_base(image_bs) == image_bs) {
error_setg(errp, "not allowing backing file change on an image "
"without a backing file");
- goto out;
+ return;
}
/* even though we are not necessarily operating on bs, we need it to
* determine if block ops are currently prohibited on the chain */
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_CHANGE, errp)) {
- goto out;
+ return;
}
/* final sanity check */
if (!bdrv_chain_contains(bs, image_bs)) {
error_setg(errp, "'%s' and image file are not in the same chain",
device);
- goto out;
+ return;
}
/* if not r/w, reopen to make r/w */
@@ -3763,7 +3759,7 @@ void qmp_change_backing_file(const char *device,
bdrv_reopen(image_bs, open_flags | BDRV_O_RDWR, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- goto out;
+ return;
}
}
@@ -3781,9 +3777,6 @@ void qmp_change_backing_file(const char *device,
bdrv_reopen(image_bs, open_flags, &local_err);
error_propagate(errp, local_err);
}
-
-out:
- aio_context_release(aio_context);
}
void hmp_drive_add_node(Monitor *mon, const char *optstr)
@@ -265,7 +265,7 @@ BlockDriverState *bdrv_new_open_driver(BlockDriver *drv, const char *node_name,
BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
BlockDriverState *bs,
QDict *options, int flags);
-int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Error **errp);
+int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp);
int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp);
int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue, Error **errp);
@@ -2006,7 +2006,7 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv)
qemu_opts_reset(&reopen_opts);
brq = bdrv_reopen_queue(NULL, bs, opts, flags);
- bdrv_reopen_multiple(bdrv_get_aio_context(bs), brq, &local_err);
+ bdrv_reopen_multiple(brq, &local_err);
if (local_err) {
error_report_err(local_err);
} else {
Reopen needs to handle AioContext carefully due to calling bdrv_drain_all_begin/end. By not taking AioContext around calls to bdrv_reopen_multiple, we can drop the function's release/acquire pair and the AioContext argument too. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- block.c | 6 ++---- block/block-backend.c | 5 ----- block/commit.c | 2 +- block/mirror.c | 9 --------- block/replication.c | 3 +-- blockdev.c | 19 ++++++------------- include/block/block.h | 2 +- qemu-io-cmds.c | 2 +- 8 files changed, 12 insertions(+), 36 deletions(-)