block-backend: Update ctx immediately after root
commitaf5b6ebe5b887cb650434f9f7294af597a66314c
authorHanna Reitz <hreitz@redhat.com>
Mon, 7 Nov 2022 15:13:20 +0000 (7 16:13 +0100)
committerKevin Wolf <kwolf@redhat.com>
Thu, 10 Nov 2022 13:58:38 +0000 (10 14:58 +0100)
tree5c468bf31fc9e7fd418d03cf8b2b46e8cb084940
parentd5f8d79c2f1f22cb883ae404abff1ee8276d47f1
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>
block/block-backend.c