Commit b4961249 authored by Sergio Lopez's avatar Sergio Lopez Committed by Eric Blake
Browse files

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: default avatarSergio Lopez <slp@redhat.com>
Message-Id: <20190912110032.26395-1-slp@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
parent 1b5c15ce
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1297,6 +1297,11 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
        return ret;
    }

    /* Attach the channel to the same AioContext as the export */
    if (client->exp && client->exp->ctx) {
        qio_channel_attach_aio_context(client->ioc, client->exp->ctx);
    }

    assert(!client->optlen);
    trace_nbd_negotiate_success();