block-backend: Allow concurrent context changes
commitad893672027ffe26db498947d70cde6d4f58a111
authorHanna Czenczek <hreitz@redhat.com>
Fri, 2 Feb 2024 14:47:54 +0000 (2 15:47 +0100)
committerKevin Wolf <kwolf@redhat.com>
Wed, 7 Feb 2024 13:55:25 +0000 (7 14:55 +0100)
tree1dc29fb4e576dfe9239c1a631b866c5a9f729944
parent1f25c172f83704e350c0829438d832384084a74d
block-backend: Allow concurrent context changes

Since AioContext locks have been removed, a BlockBackend's AioContext
may really change at any time (only exception is that it is often
confined to a drained section, as noted in this patch).  Therefore,
blk_get_aio_context() cannot rely on its root node's context always
matching that of the BlockBackend.

In practice, whether they match does not matter anymore anyway: Requests
can be sent to BDSs from any context, so anyone who requests the BB's
context should have no reason to require the root node to have the same
context.  Therefore, we can and should remove the assertion to that
effect.

In addition, because the context can be set and queried from different
threads concurrently, it has to be accessed with atomic operations.

Buglink: https://issues.redhat.com/browse/RHEL-19381
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
Message-ID: <20240202144755.671354-2-hreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/block-backend.c