|
|
60061b |
From c7f63e7bbc5119d92775e20d1ebbf8280c78b732 Mon Sep 17 00:00:00 2001
|
|
|
60061b |
From: Hanna Reitz <hreitz@redhat.com>
|
|
|
60061b |
Date: Fri, 4 Feb 2022 12:10:11 +0100
|
|
|
60061b |
Subject: [PATCH 5/6] block/nbd: Move s->ioc on AioContext change
|
|
|
60061b |
|
|
|
60061b |
RH-Author: Hanna Reitz <hreitz@redhat.com>
|
|
|
60061b |
RH-MergeRequest: 117: block/nbd: Handle AioContext changes
|
|
|
60061b |
RH-Commit: [5/6] 107757b9fbadfb832c75521317108525daa4174e
|
|
|
60061b |
RH-Bugzilla: 2035185
|
|
|
60061b |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
60061b |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
60061b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
60061b |
|
|
|
60061b |
s->ioc must always be attached to the NBD node's AioContext. If that
|
|
|
60061b |
context changes, s->ioc must be attached to the new context.
|
|
|
60061b |
|
|
|
60061b |
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2033626
|
|
|
60061b |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
60061b |
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
60061b |
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
60061b |
(cherry picked from commit e15f3a66c830e3fce99c9d56c493c2f7078a1225)
|
|
|
60061b |
|
|
|
60061b |
Conflict:
|
|
|
60061b |
- block/nbd.c: open_timer was added after the 6.2 release, so we need
|
|
|
60061b |
not (and cannot) assert it is NULL here.
|
|
|
60061b |
|
|
|
60061b |
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
|
|
|
60061b |
---
|
|
|
60061b |
block/nbd.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
|
60061b |
1 file changed, 41 insertions(+)
|
|
|
60061b |
|
|
|
60061b |
diff --git a/block/nbd.c b/block/nbd.c
|
|
|
60061b |
index aab20125d8..a3896c7f5f 100644
|
|
|
60061b |
--- a/block/nbd.c
|
|
|
60061b |
+++ b/block/nbd.c
|
|
|
60061b |
@@ -2003,6 +2003,38 @@ static void nbd_cancel_in_flight(BlockDriverState *bs)
|
|
|
60061b |
nbd_co_establish_connection_cancel(s->conn);
|
|
|
60061b |
}
|
|
|
60061b |
|
|
|
60061b |
+static void nbd_attach_aio_context(BlockDriverState *bs,
|
|
|
60061b |
+ AioContext *new_context)
|
|
|
60061b |
+{
|
|
|
60061b |
+ BDRVNBDState *s = bs->opaque;
|
|
|
60061b |
+
|
|
|
60061b |
+ /*
|
|
|
60061b |
+ * The reconnect_delay_timer is scheduled in I/O paths when the
|
|
|
60061b |
+ * connection is lost, to cancel the reconnection attempt after a
|
|
|
60061b |
+ * given time. Once this attempt is done (successfully or not),
|
|
|
60061b |
+ * nbd_reconnect_attempt() ensures the timer is deleted before the
|
|
|
60061b |
+ * respective I/O request is resumed.
|
|
|
60061b |
+ * Since the AioContext can only be changed when a node is drained,
|
|
|
60061b |
+ * the reconnect_delay_timer cannot be active here.
|
|
|
60061b |
+ */
|
|
|
60061b |
+ assert(!s->reconnect_delay_timer);
|
|
|
60061b |
+
|
|
|
60061b |
+ if (s->ioc) {
|
|
|
60061b |
+ qio_channel_attach_aio_context(s->ioc, new_context);
|
|
|
60061b |
+ }
|
|
|
60061b |
+}
|
|
|
60061b |
+
|
|
|
60061b |
+static void nbd_detach_aio_context(BlockDriverState *bs)
|
|
|
60061b |
+{
|
|
|
60061b |
+ BDRVNBDState *s = bs->opaque;
|
|
|
60061b |
+
|
|
|
60061b |
+ assert(!s->reconnect_delay_timer);
|
|
|
60061b |
+
|
|
|
60061b |
+ if (s->ioc) {
|
|
|
60061b |
+ qio_channel_detach_aio_context(s->ioc);
|
|
|
60061b |
+ }
|
|
|
60061b |
+}
|
|
|
60061b |
+
|
|
|
60061b |
static BlockDriver bdrv_nbd = {
|
|
|
60061b |
.format_name = "nbd",
|
|
|
60061b |
.protocol_name = "nbd",
|
|
|
60061b |
@@ -2026,6 +2058,9 @@ static BlockDriver bdrv_nbd = {
|
|
|
60061b |
.bdrv_dirname = nbd_dirname,
|
|
|
60061b |
.strong_runtime_opts = nbd_strong_runtime_opts,
|
|
|
60061b |
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
|
|
60061b |
+
|
|
|
60061b |
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
|
|
60061b |
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
|
|
60061b |
};
|
|
|
60061b |
|
|
|
60061b |
static BlockDriver bdrv_nbd_tcp = {
|
|
|
60061b |
@@ -2051,6 +2086,9 @@ static BlockDriver bdrv_nbd_tcp = {
|
|
|
60061b |
.bdrv_dirname = nbd_dirname,
|
|
|
60061b |
.strong_runtime_opts = nbd_strong_runtime_opts,
|
|
|
60061b |
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
|
|
60061b |
+
|
|
|
60061b |
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
|
|
60061b |
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
|
|
60061b |
};
|
|
|
60061b |
|
|
|
60061b |
static BlockDriver bdrv_nbd_unix = {
|
|
|
60061b |
@@ -2076,6 +2114,9 @@ static BlockDriver bdrv_nbd_unix = {
|
|
|
60061b |
.bdrv_dirname = nbd_dirname,
|
|
|
60061b |
.strong_runtime_opts = nbd_strong_runtime_opts,
|
|
|
60061b |
.bdrv_cancel_in_flight = nbd_cancel_in_flight,
|
|
|
60061b |
+
|
|
|
60061b |
+ .bdrv_attach_aio_context = nbd_attach_aio_context,
|
|
|
60061b |
+ .bdrv_detach_aio_context = nbd_detach_aio_context,
|
|
|
60061b |
};
|
|
|
60061b |
|
|
|
60061b |
static void bdrv_nbd_init(void)
|
|
|
60061b |
--
|
|
|
60061b |
2.27.0
|
|
|
60061b |
|