qemu-kvm/kvm-nbd-server-attach-clien...

61 lines
2.2 KiB
Diff

From 394dd52ce4dbd69cd5eca9a9928c442650cc3fd2 Mon Sep 17 00:00:00 2001
From: Sergio Lopez Pascual <slp@redhat.com>
Date: Fri, 27 Sep 2019 11:13:24 +0100
Subject: [PATCH 1/2] nbd/server: attach client channel to the export's
AioContext
RH-Author: Sergio Lopez Pascual <slp@redhat.com>
Message-id: <20190927111324.17949-2-slp@redhat.com>
Patchwork-id: 90905
O-Subject: [RHEL-AV-8.1.0 qemu-kvm PATCH 1/1] nbd/server: attach client channel to the export's AioContext
Bugzilla: 1748253
RH-Acked-by: Eric Blake <eblake@redhat.com>
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
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>
(cherry picked from commit b4961249af0403fa55aae57c4c8806b24f7a7b33)
Signed-off-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
nbd/server.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/nbd/server.c b/nbd/server.c
index 10faedc..ea0353a 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1296,6 +1296,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();
--
1.8.3.1