Document (via a comment and an assert) that nbd_client_detach_aio_context and nbd_client_attach_aio_context_bh run in the desired aio_context.
Signed-off-by: Roman Kagan <rvka...@yandex-team.ru> --- block/nbd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 1d8edb5b21..658b827d24 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -241,6 +241,12 @@ static void nbd_client_detach_aio_context(BlockDriverState *bs) { BDRVNBDState *s = (BDRVNBDState *)bs->opaque; + /* + * This runs in the (old, about to be detached) aio context of the @bs so + * accessing the stuff on @s is concurrency-free. + */ + assert(qemu_get_current_aio_context() == bdrv_get_aio_context(bs)); + /* Timer is deleted in nbd_client_co_drain_begin() */ assert(!s->reconnect_delay_timer); /* @@ -258,6 +264,12 @@ static void nbd_client_attach_aio_context_bh(void *opaque) BlockDriverState *bs = opaque; BDRVNBDState *s = (BDRVNBDState *)bs->opaque; + /* + * This runs in the (new, just attached) aio context of the @bs so + * accessing the stuff on @s is concurrency-free. + */ + assert(qemu_get_current_aio_context() == bdrv_get_aio_context(bs)); + if (s->connection_co) { /* * The node is still drained, so we know the coroutine has yielded in -- 2.30.2