aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-05-06 19:17:58 +0200
committerKevin Wolf <kwolf@redhat.com>2019-05-20 17:08:56 +0200
commit0d83708a1d2effc5d905cd1d61d0ef47d310ad88 (patch)
tree4e3fed82df9f6faef3299634475dede40c6f40ea /block.c
parenta3a683c33d38fb29c7a78903e88dda12b84cc88d (diff)
downloadqemu-0d83708a1d2effc5d905cd1d61d0ef47d310ad88.zip
qemu-0d83708a1d2effc5d905cd1d61d0ef47d310ad88.tar.gz
qemu-0d83708a1d2effc5d905cd1d61d0ef47d310ad88.tar.bz2
block: Move recursion to bdrv_set_aio_context()
Instead of having two recursions, in bdrv_attach_aio_context() and in bdrv_detach_aio_context(), just having one recursion is enough. Said functions are only about a single node now. It is important that the recursion doesn't happen between detaching and attaching a context to the current node because the nested call will drain the node, and draining with a NULL context would segfault. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/block.c b/block.c
index b2f7114..0ace673 100644
--- a/block.c
+++ b/block.c
@@ -5679,7 +5679,6 @@ static void bdrv_do_remove_aio_context_notifier(BdrvAioNotifier *ban)
static void bdrv_detach_aio_context(BlockDriverState *bs)
{
BdrvAioNotifier *baf, *baf_tmp;
- BdrvChild *child;
assert(!bs->walking_aio_notifiers);
bs->walking_aio_notifiers = true;
@@ -5698,9 +5697,6 @@ static void bdrv_detach_aio_context(BlockDriverState *bs)
if (bs->drv && bs->drv->bdrv_detach_aio_context) {
bs->drv->bdrv_detach_aio_context(bs);
}
- QLIST_FOREACH(child, &bs->children, next) {
- bdrv_detach_aio_context(child->bs);
- }
if (bs->quiesce_counter) {
aio_enable_external(bs->aio_context);
@@ -5712,7 +5708,6 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
AioContext *new_context)
{
BdrvAioNotifier *ban, *ban_tmp;
- BdrvChild *child;
if (bs->quiesce_counter) {
aio_disable_external(new_context);
@@ -5720,9 +5715,6 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
bs->aio_context = new_context;
- QLIST_FOREACH(child, &bs->children, next) {
- bdrv_attach_aio_context(child->bs, new_context);
- }
if (bs->drv && bs->drv->bdrv_attach_aio_context) {
bs->drv->bdrv_attach_aio_context(bs, new_context);
}
@@ -5744,11 +5736,18 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
* the same as the current context of bs). */
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
{
+ BdrvChild *child;
+
if (bdrv_get_aio_context(bs) == new_context) {
return;
}
bdrv_drained_begin(bs);
+
+ QLIST_FOREACH(child, &bs->children, next) {
+ bdrv_set_aio_context(child->bs, new_context);
+ }
+
bdrv_detach_aio_context(bs);
/* This function executes in the old AioContext so acquire the new one in