mirror of https://gitee.com/openkylin/qemu.git
block: Remove bdrv_set_aio_context()
All callers of bdrv_set_aio_context() are eliminated now, they have moved to bdrv_try_set_aio_context() and related safe functions. Remove bdrv_set_aio_context(). With this, we can now know that the .set_aio_ctx callback must be present in bdrv_set_aio_context_ignore() because bdrv_can_set_aio_context() would have returned false previously, so instead of checking the condition, we can assert it. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
26bf15e441
commit
42a65f02f9
26
block.c
26
block.c
|
@ -5789,8 +5789,17 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
|
|||
bs->walking_aio_notifiers = false;
|
||||
}
|
||||
|
||||
/* @ignore will accumulate all visited BdrvChild object. The caller is
|
||||
* responsible for freeing the list afterwards. */
|
||||
/*
|
||||
* Changes the AioContext used for fd handlers, timers, and BHs by this
|
||||
* BlockDriverState and all its children and parents.
|
||||
*
|
||||
* The caller must own the AioContext lock for the old AioContext of bs, but it
|
||||
* must not own the AioContext lock for new_context (unless new_context is the
|
||||
* same as the current context of bs).
|
||||
*
|
||||
* @ignore will accumulate all visited BdrvChild object. The caller is
|
||||
* responsible for freeing the list afterwards.
|
||||
*/
|
||||
void bdrv_set_aio_context_ignore(BlockDriverState *bs,
|
||||
AioContext *new_context, GSList **ignore)
|
||||
{
|
||||
|
@ -5813,11 +5822,10 @@ void bdrv_set_aio_context_ignore(BlockDriverState *bs,
|
|||
if (g_slist_find(*ignore, child)) {
|
||||
continue;
|
||||
}
|
||||
if (child->role->set_aio_ctx) {
|
||||
assert(child->role->set_aio_ctx);
|
||||
*ignore = g_slist_prepend(*ignore, child);
|
||||
child->role->set_aio_ctx(child, new_context, ignore);
|
||||
}
|
||||
}
|
||||
|
||||
bdrv_detach_aio_context(bs);
|
||||
|
||||
|
@ -5830,16 +5838,6 @@ void bdrv_set_aio_context_ignore(BlockDriverState *bs,
|
|||
aio_context_release(new_context);
|
||||
}
|
||||
|
||||
/* The caller must own the AioContext lock for the old AioContext of bs, but it
|
||||
* must not own the AioContext lock for new_context (unless new_context is
|
||||
* the same as the current context of bs). */
|
||||
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
|
||||
{
|
||||
GSList *ignore_list = NULL;
|
||||
bdrv_set_aio_context_ignore(bs, new_context, &ignore_list);
|
||||
g_slist_free(ignore_list);
|
||||
}
|
||||
|
||||
static bool bdrv_parent_can_set_aio_context(BdrvChild *c, AioContext *ctx,
|
||||
GSList **ignore, Error **errp)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
||||
The block layer has support for AioContext integrated. Each BlockDriverState
|
||||
is associated with an AioContext using bdrv_set_aio_context() and
|
||||
is associated with an AioContext using bdrv_try_set_aio_context() and
|
||||
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.
|
||||
|
||||
|
@ -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
|
||||
each bdrv_*() call. The functions bdrv_add/remove_aio_context_notifier,
|
||||
or alternatively blk_add/remove_aio_context_notifier if you use BlockBackends,
|
||||
can be used to get a notification whenever bdrv_set_aio_context() moves a
|
||||
can be used to get a notification whenever bdrv_try_set_aio_context() moves a
|
||||
BlockDriverState to a different AioContext.
|
||||
|
|
|
@ -583,15 +583,6 @@ AioContext *bdrv_get_aio_context(BlockDriverState *bs);
|
|||
*/
|
||||
void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co);
|
||||
|
||||
/**
|
||||
* bdrv_set_aio_context:
|
||||
*
|
||||
* Changes the #AioContext used for fd handlers, timers, and BHs by this
|
||||
* BlockDriverState and all its children.
|
||||
*
|
||||
* This function must be called with iothread lock held.
|
||||
*/
|
||||
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context);
|
||||
void bdrv_set_aio_context_ignore(BlockDriverState *bs,
|
||||
AioContext *new_context, GSList **ignore);
|
||||
int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
|
||||
|
|
Loading…
Reference in New Issue