mirror of
https://github.com/qemu/qemu.git
synced 2024-11-23 19:03:38 +08:00
block: remove bdrv_try_set_aio_context and replace it with bdrv_try_change_aio_context
No functional change intended. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20221025084952.2139888-11-eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
a41cfda126
commit
142e690712
14
block.c
14
block.c
@ -2904,7 +2904,7 @@ static void bdrv_attach_child_common_abort(void *opaque)
|
|||||||
bdrv_replace_child_noperm(s->child, NULL);
|
bdrv_replace_child_noperm(s->child, NULL);
|
||||||
|
|
||||||
if (bdrv_get_aio_context(bs) != s->old_child_ctx) {
|
if (bdrv_get_aio_context(bs) != s->old_child_ctx) {
|
||||||
bdrv_try_set_aio_context(bs, s->old_child_ctx, &error_abort);
|
bdrv_try_change_aio_context(bs, s->old_child_ctx, NULL, &error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bdrv_child_get_parent_aio_context(s->child) != s->old_parent_ctx) {
|
if (bdrv_child_get_parent_aio_context(s->child) != s->old_parent_ctx) {
|
||||||
@ -2975,7 +2975,8 @@ static BdrvChild *bdrv_attach_child_common(BlockDriverState *child_bs,
|
|||||||
parent_ctx = bdrv_child_get_parent_aio_context(new_child);
|
parent_ctx = bdrv_child_get_parent_aio_context(new_child);
|
||||||
if (child_ctx != parent_ctx) {
|
if (child_ctx != parent_ctx) {
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int ret = bdrv_try_set_aio_context(child_bs, parent_ctx, &local_err);
|
int ret = bdrv_try_change_aio_context(child_bs, parent_ctx, NULL,
|
||||||
|
&local_err);
|
||||||
|
|
||||||
if (ret < 0 && child_class->change_aio_ctx) {
|
if (ret < 0 && child_class->change_aio_ctx) {
|
||||||
Transaction *tran = tran_new();
|
Transaction *tran = tran_new();
|
||||||
@ -3065,7 +3066,7 @@ static void bdrv_detach_child(BdrvChild *child)
|
|||||||
* When the parent requiring a non-default AioContext is removed, the
|
* When the parent requiring a non-default AioContext is removed, the
|
||||||
* node moves back to the main AioContext
|
* node moves back to the main AioContext
|
||||||
*/
|
*/
|
||||||
bdrv_try_set_aio_context(old_bs, qemu_get_aio_context(), NULL);
|
bdrv_try_change_aio_context(old_bs, qemu_get_aio_context(), NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7407,13 +7408,6 @@ int bdrv_try_change_aio_context(BlockDriverState *bs, AioContext *ctx,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
GLOBAL_STATE_CODE();
|
|
||||||
return bdrv_try_change_aio_context(bs, ctx, NULL, errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bdrv_add_aio_context_notifier(BlockDriverState *bs,
|
void bdrv_add_aio_context_notifier(BlockDriverState *bs,
|
||||||
void (*attached_aio_context)(AioContext *new_context, void *opaque),
|
void (*attached_aio_context)(AioContext *new_context, void *opaque),
|
||||||
void (*detach_aio_context)(void *opaque), void *opaque)
|
void (*detach_aio_context)(void *opaque), void *opaque)
|
||||||
|
@ -129,7 +129,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
|
|||||||
|
|
||||||
/* Ignore errors with fixed-iothread=false */
|
/* Ignore errors with fixed-iothread=false */
|
||||||
set_context_errp = fixed_iothread ? errp : NULL;
|
set_context_errp = fixed_iothread ? errp : NULL;
|
||||||
ret = bdrv_try_set_aio_context(bs, new_ctx, set_context_errp);
|
ret = bdrv_try_change_aio_context(bs, new_ctx, NULL, set_context_errp);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
aio_context_release(ctx);
|
aio_context_release(ctx);
|
||||||
aio_context_acquire(new_ctx);
|
aio_context_acquire(new_ctx);
|
||||||
|
22
blockdev.c
22
blockdev.c
@ -1630,8 +1630,8 @@ static void external_snapshot_abort(BlkActionState *common)
|
|||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
aio_context_acquire(tmp_context);
|
aio_context_acquire(tmp_context);
|
||||||
|
|
||||||
ret = bdrv_try_set_aio_context(state->old_bs,
|
ret = bdrv_try_change_aio_context(state->old_bs,
|
||||||
aio_context, NULL);
|
aio_context, NULL, NULL);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
|
|
||||||
aio_context_release(tmp_context);
|
aio_context_release(tmp_context);
|
||||||
@ -1792,12 +1792,12 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
|
||||||
old_context = bdrv_get_aio_context(target_bs);
|
old_context = bdrv_get_aio_context(target_bs);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
aio_context_acquire(old_context);
|
aio_context_acquire(old_context);
|
||||||
|
|
||||||
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
bdrv_unref(target_bs);
|
bdrv_unref(target_bs);
|
||||||
aio_context_release(old_context);
|
aio_context_release(old_context);
|
||||||
@ -1892,12 +1892,12 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
|
||||||
aio_context = bdrv_get_aio_context(bs);
|
aio_context = bdrv_get_aio_context(bs);
|
||||||
old_context = bdrv_get_aio_context(target_bs);
|
old_context = bdrv_get_aio_context(target_bs);
|
||||||
aio_context_acquire(old_context);
|
aio_context_acquire(old_context);
|
||||||
|
|
||||||
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
aio_context_release(old_context);
|
aio_context_release(old_context);
|
||||||
return;
|
return;
|
||||||
@ -3194,12 +3194,12 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
|||||||
!bdrv_has_zero_init(target_bs)));
|
!bdrv_has_zero_init(target_bs)));
|
||||||
|
|
||||||
|
|
||||||
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
|
||||||
old_context = bdrv_get_aio_context(target_bs);
|
old_context = bdrv_get_aio_context(target_bs);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
aio_context_acquire(old_context);
|
aio_context_acquire(old_context);
|
||||||
|
|
||||||
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
bdrv_unref(target_bs);
|
bdrv_unref(target_bs);
|
||||||
aio_context_release(old_context);
|
aio_context_release(old_context);
|
||||||
@ -3266,12 +3266,12 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
|
|||||||
|
|
||||||
zero_target = (sync == MIRROR_SYNC_MODE_FULL);
|
zero_target = (sync == MIRROR_SYNC_MODE_FULL);
|
||||||
|
|
||||||
/* Honor bdrv_try_set_aio_context() context acquisition requirements. */
|
/* Honor bdrv_try_change_aio_context() context acquisition requirements. */
|
||||||
old_context = bdrv_get_aio_context(target_bs);
|
old_context = bdrv_get_aio_context(target_bs);
|
||||||
aio_context = bdrv_get_aio_context(bs);
|
aio_context = bdrv_get_aio_context(bs);
|
||||||
aio_context_acquire(old_context);
|
aio_context_acquire(old_context);
|
||||||
|
|
||||||
ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
|
ret = bdrv_try_change_aio_context(target_bs, aio_context, NULL, errp);
|
||||||
|
|
||||||
aio_context_release(old_context);
|
aio_context_release(old_context);
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
@ -3767,7 +3767,7 @@ void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
|
|||||||
old_context = bdrv_get_aio_context(bs);
|
old_context = bdrv_get_aio_context(bs);
|
||||||
aio_context_acquire(old_context);
|
aio_context_acquire(old_context);
|
||||||
|
|
||||||
bdrv_try_set_aio_context(bs, new_context, errp);
|
bdrv_try_change_aio_context(bs, new_context, NULL, errp);
|
||||||
|
|
||||||
aio_context_release(old_context);
|
aio_context_release(old_context);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ The AioContext originates from the QEMU block layer, even though nowadays
|
|||||||
AioContext is a generic event loop that can be used by any QEMU subsystem.
|
AioContext is a generic event loop that can be used by any QEMU subsystem.
|
||||||
|
|
||||||
The block layer has support for AioContext integrated. Each BlockDriverState
|
The block layer has support for AioContext integrated. Each BlockDriverState
|
||||||
is associated with an AioContext using bdrv_try_set_aio_context() and
|
is associated with an AioContext using bdrv_try_change_aio_context() and
|
||||||
bdrv_get_aio_context(). This allows block layer code to process I/O inside the
|
bdrv_get_aio_context(). This allows block layer code to process I/O inside the
|
||||||
right AioContext. Other subsystems may wish to follow a similar approach.
|
right AioContext. Other subsystems may wish to follow a similar approach.
|
||||||
|
|
||||||
@ -134,5 +134,5 @@ Long-running jobs (usually in the form of coroutines) are best scheduled in
|
|||||||
the BlockDriverState's AioContext to avoid the need to acquire/release around
|
the BlockDriverState's AioContext to avoid the need to acquire/release around
|
||||||
each bdrv_*() call. The functions bdrv_add/remove_aio_context_notifier,
|
each bdrv_*() call. The functions bdrv_add/remove_aio_context_notifier,
|
||||||
or alternatively blk_add/remove_aio_context_notifier if you use BlockBackends,
|
or alternatively blk_add/remove_aio_context_notifier if you use BlockBackends,
|
||||||
can be used to get a notification whenever bdrv_try_set_aio_context() moves a
|
can be used to get a notification whenever bdrv_try_change_aio_context() moves a
|
||||||
BlockDriverState to a different AioContext.
|
BlockDriverState to a different AioContext.
|
||||||
|
@ -220,8 +220,6 @@ void coroutine_fn bdrv_co_lock(BlockDriverState *bs);
|
|||||||
*/
|
*/
|
||||||
void coroutine_fn bdrv_co_unlock(BlockDriverState *bs);
|
void coroutine_fn bdrv_co_unlock(BlockDriverState *bs);
|
||||||
|
|
||||||
int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
|
|
||||||
Error **errp);
|
|
||||||
AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c);
|
AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c);
|
||||||
bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx,
|
bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx,
|
||||||
GHashTable *visited, Transaction *tran,
|
GHashTable *visited, Transaction *tran,
|
||||||
|
2
job.c
2
job.c
@ -588,7 +588,7 @@ static void coroutine_fn job_do_yield_locked(Job *job, uint64_t ns)
|
|||||||
next_aio_context = job->aio_context;
|
next_aio_context = job->aio_context;
|
||||||
/*
|
/*
|
||||||
* Coroutine has resumed, but in the meanwhile the job AioContext
|
* Coroutine has resumed, but in the meanwhile the job AioContext
|
||||||
* might have changed via bdrv_try_set_aio_context(), so we need to move
|
* might have changed via bdrv_try_change_aio_context(), so we need to move
|
||||||
* the coroutine too in the new aiocontext.
|
* the coroutine too in the new aiocontext.
|
||||||
*/
|
*/
|
||||||
while (qemu_get_current_aio_context() != next_aio_context) {
|
while (qemu_get_current_aio_context() != next_aio_context) {
|
||||||
|
@ -1538,16 +1538,16 @@ static void test_set_aio_context(void)
|
|||||||
&error_abort);
|
&error_abort);
|
||||||
|
|
||||||
bdrv_drained_begin(bs);
|
bdrv_drained_begin(bs);
|
||||||
bdrv_try_set_aio_context(bs, ctx_a, &error_abort);
|
bdrv_try_change_aio_context(bs, ctx_a, NULL, &error_abort);
|
||||||
|
|
||||||
aio_context_acquire(ctx_a);
|
aio_context_acquire(ctx_a);
|
||||||
bdrv_drained_end(bs);
|
bdrv_drained_end(bs);
|
||||||
|
|
||||||
bdrv_drained_begin(bs);
|
bdrv_drained_begin(bs);
|
||||||
bdrv_try_set_aio_context(bs, ctx_b, &error_abort);
|
bdrv_try_change_aio_context(bs, ctx_b, NULL, &error_abort);
|
||||||
aio_context_release(ctx_a);
|
aio_context_release(ctx_a);
|
||||||
aio_context_acquire(ctx_b);
|
aio_context_acquire(ctx_b);
|
||||||
bdrv_try_set_aio_context(bs, qemu_get_aio_context(), &error_abort);
|
bdrv_try_change_aio_context(bs, qemu_get_aio_context(), NULL, &error_abort);
|
||||||
aio_context_release(ctx_b);
|
aio_context_release(ctx_b);
|
||||||
bdrv_drained_end(bs);
|
bdrv_drained_end(bs);
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ static void test_propagate_mirror(void)
|
|||||||
filter = bdrv_find_node("filter_node");
|
filter = bdrv_find_node("filter_node");
|
||||||
|
|
||||||
/* Change the AioContext of src */
|
/* Change the AioContext of src */
|
||||||
bdrv_try_set_aio_context(src, ctx, &error_abort);
|
bdrv_try_change_aio_context(src, ctx, NULL, &error_abort);
|
||||||
g_assert(bdrv_get_aio_context(src) == ctx);
|
g_assert(bdrv_get_aio_context(src) == ctx);
|
||||||
g_assert(bdrv_get_aio_context(target) == ctx);
|
g_assert(bdrv_get_aio_context(target) == ctx);
|
||||||
g_assert(bdrv_get_aio_context(filter) == ctx);
|
g_assert(bdrv_get_aio_context(filter) == ctx);
|
||||||
@ -773,7 +773,7 @@ static void test_propagate_mirror(void)
|
|||||||
|
|
||||||
/* Change the AioContext of target */
|
/* Change the AioContext of target */
|
||||||
aio_context_acquire(ctx);
|
aio_context_acquire(ctx);
|
||||||
bdrv_try_set_aio_context(target, main_ctx, &error_abort);
|
bdrv_try_change_aio_context(target, main_ctx, NULL, &error_abort);
|
||||||
aio_context_release(ctx);
|
aio_context_release(ctx);
|
||||||
g_assert(bdrv_get_aio_context(src) == main_ctx);
|
g_assert(bdrv_get_aio_context(src) == main_ctx);
|
||||||
g_assert(bdrv_get_aio_context(target) == main_ctx);
|
g_assert(bdrv_get_aio_context(target) == main_ctx);
|
||||||
@ -783,7 +783,7 @@ static void test_propagate_mirror(void)
|
|||||||
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
|
||||||
blk_insert_bs(blk, src, &error_abort);
|
blk_insert_bs(blk, src, &error_abort);
|
||||||
|
|
||||||
bdrv_try_set_aio_context(target, ctx, &local_err);
|
bdrv_try_change_aio_context(target, ctx, NULL, &local_err);
|
||||||
error_free_or_abort(&local_err);
|
error_free_or_abort(&local_err);
|
||||||
|
|
||||||
g_assert(blk_get_aio_context(blk) == main_ctx);
|
g_assert(blk_get_aio_context(blk) == main_ctx);
|
||||||
@ -794,7 +794,7 @@ static void test_propagate_mirror(void)
|
|||||||
/* ...unless we explicitly allow it */
|
/* ...unless we explicitly allow it */
|
||||||
aio_context_acquire(ctx);
|
aio_context_acquire(ctx);
|
||||||
blk_set_allow_aio_context_change(blk, true);
|
blk_set_allow_aio_context_change(blk, true);
|
||||||
bdrv_try_set_aio_context(target, ctx, &error_abort);
|
bdrv_try_change_aio_context(target, ctx, NULL, &error_abort);
|
||||||
aio_context_release(ctx);
|
aio_context_release(ctx);
|
||||||
|
|
||||||
g_assert(blk_get_aio_context(blk) == ctx);
|
g_assert(blk_get_aio_context(blk) == ctx);
|
||||||
@ -806,7 +806,7 @@ static void test_propagate_mirror(void)
|
|||||||
|
|
||||||
aio_context_acquire(ctx);
|
aio_context_acquire(ctx);
|
||||||
blk_set_aio_context(blk, main_ctx, &error_abort);
|
blk_set_aio_context(blk, main_ctx, &error_abort);
|
||||||
bdrv_try_set_aio_context(target, main_ctx, &error_abort);
|
bdrv_try_change_aio_context(target, main_ctx, NULL, &error_abort);
|
||||||
aio_context_release(ctx);
|
aio_context_release(ctx);
|
||||||
|
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
|
Loading…
Reference in New Issue
Block a user