nbd/server: attach client channel to the export's AioContext
commitb4961249af0403fa55aae57c4c8806b24f7a7b33
authorSergio Lopez <slp@redhat.com>
Thu, 12 Sep 2019 11:00:33 +0000 (12 13:00 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 24 Sep 2019 12:30:19 +0000 (24 07:30 -0500)
tree6358a425a762fa8fd186fcea9b9ae85efc30985f
parent1b5c15cebd5cc7595337a8a7cf14f6a707605e99
nbd/server: attach client channel to the export's AioContext

On creation, the export's AioContext is set to the same one as the
BlockBackend, while the AioContext in the client QIOChannel is left
untouched.

As a result, when using data-plane, nbd_client_receive_next_request()
schedules coroutines in the IOThread AioContext, while the client's
QIOChannel is serviced from the main_loop, potentially triggering the
assertion at qio_channel_restart_[read|write].

To fix this, as soon we have the export corresponding to the client,
we call qio_channel_attach_aio_context() to attach the QIOChannel
context to the export's AioContext. This matches with the logic at
blk_aio_attached().

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
Signed-off-by: Sergio Lopez <slp@redhat.com>
Message-Id: <20190912110032.26395-1-slp@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
nbd/server.c