diff options
author | Hanna Reitz <hreitz@redhat.com> | 2022-11-07 16:13:20 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2022-11-10 14:58:38 +0100 |
commit | af5b6ebe5b887cb650434f9f7294af597a66314c (patch) | |
tree | 5c468bf31fc9e7fd418d03cf8b2b46e8cb084940 /block/block-backend.c | |
parent | d5f8d79c2f1f22cb883ae404abff1ee8276d47f1 (diff) | |
download | qemu-af5b6ebe5b887cb650434f9f7294af597a66314c.zip qemu-af5b6ebe5b887cb650434f9f7294af597a66314c.tar.gz qemu-af5b6ebe5b887cb650434f9f7294af597a66314c.tar.bz2 |
block-backend: Update ctx immediately after root
blk_get_aio_context() asserts that blk->ctx is always equal to the root
BDS's context (if there is a root BDS). Therefore,
blk_do_set_aio_context() must update blk->ctx immediately after the root
BDS's context has changed.
Without this patch, the next patch would break iotest 238, because
bdrv_drained_begin() (called by blk_do_set_aio_context()) may then
invoke bdrv_child_get_parent_aio_context() on the root child, i.e.
blk_get_aio_context(). However, by this point, blk->ctx would not have
been updated and thus differ from the root node's context. This patch
fixes that.
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20221107151321.211175-3-hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/block-backend.c')
-rw-r--r-- | block/block-backend.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index ed2f4b6..b48c91f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2158,6 +2158,11 @@ static int blk_do_set_aio_context(BlockBackend *blk, AioContext *new_context, return ret; } } + /* + * Make blk->ctx consistent with the root node before we invoke any + * other operations like drain that might inquire blk->ctx + */ + blk->ctx = new_context; if (tgm->throttle_state) { bdrv_drained_begin(bs); throttle_group_detach_aio_context(tgm); @@ -2166,9 +2171,10 @@ static int blk_do_set_aio_context(BlockBackend *blk, AioContext *new_context, } bdrv_unref(bs); + } else { + blk->ctx = new_context; } - blk->ctx = new_context; return 0; } |