qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nbd/server: attach client channel to the export's AioContext
@ 2019-09-11 16:15 Sergio Lopez
  2019-09-11 17:21 ` Eric Blake
  2019-09-12  8:23 ` Kevin Wolf
  0 siblings, 2 replies; 13+ messages in thread
From: Sergio Lopez @ 2019-09-11 16:15 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, qemu-devel, Sergio Lopez

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 in
blk_aio_attached().

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
 nbd/server.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/nbd/server.c b/nbd/server.c
index 10faedcfc5..51322e2343 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -471,6 +471,7 @@ static int nbd_negotiate_handle_export_name(NBDClient *client,
     QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);
     nbd_export_get(client->exp);
     nbd_check_meta_export(client);
+    qio_channel_attach_aio_context(client->ioc, client->exp->ctx);
 
     return 0;
 }
@@ -673,6 +674,7 @@ static int nbd_negotiate_handle_info(NBDClient *client, uint16_t myflags,
         QTAILQ_INSERT_TAIL(&client->exp->clients, client, next);
         nbd_export_get(client->exp);
         nbd_check_meta_export(client);
+        qio_channel_attach_aio_context(client->ioc, exp->ctx);
         rc = 1;
     }
     return rc;
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-09-16 22:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 16:15 [Qemu-devel] [PATCH] nbd/server: attach client channel to the export's AioContext Sergio Lopez
2019-09-11 17:21 ` Eric Blake
2019-09-11 21:33   ` Eric Blake
2019-09-11 22:03     ` Eric Blake
2019-09-12  6:37     ` Sergio Lopez
2019-09-16 21:11       ` Eric Blake
2019-09-12  8:14     ` Kevin Wolf
2019-09-12 10:30       ` Sergio Lopez
2019-09-12 11:31         ` Kevin Wolf
2019-09-16 22:30           ` Eric Blake
2019-09-12  8:23 ` Kevin Wolf
2019-09-12 10:13   ` Sergio Lopez
2019-09-12 10:25     ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).