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