]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
update submodule and patches to 6.2.0
[pve-qemu.git] / debian / patches / extra / 0009-block-nbd-Move-s-ioc-on-AioContext-change.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Hanna Reitz <hreitz@redhat.com>
3 Date: Wed, 9 Feb 2022 15:02:57 +0100
4 Subject: [PATCH] block/nbd: Move s->ioc on AioContext change
5
6 s->ioc must always be attached to the NBD node's AioContext. If that
7 context changes, s->ioc must be attached to the new context.
8
9 Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2033626
10 Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
11 Signed-off-by: Hanna Reitz <hreitz@redhat.com>
12 [FE: backport (open_timer doesn't exist yet in 6.2.0)]
13 Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
14 ---
15 block/nbd.c | 41 +++++++++++++++++++++++++++++++++++++++++
16 1 file changed, 41 insertions(+)
17
18 diff --git a/block/nbd.c b/block/nbd.c
19 index aab20125d8..a3896c7f5f 100644
20 --- a/block/nbd.c
21 +++ b/block/nbd.c
22 @@ -2003,6 +2003,38 @@ static void nbd_cancel_in_flight(BlockDriverState *bs)
23 nbd_co_establish_connection_cancel(s->conn);
24 }
25
26 +static void nbd_attach_aio_context(BlockDriverState *bs,
27 + AioContext *new_context)
28 +{
29 + BDRVNBDState *s = bs->opaque;
30 +
31 + /*
32 + * The reconnect_delay_timer is scheduled in I/O paths when the
33 + * connection is lost, to cancel the reconnection attempt after a
34 + * given time. Once this attempt is done (successfully or not),
35 + * nbd_reconnect_attempt() ensures the timer is deleted before the
36 + * respective I/O request is resumed.
37 + * Since the AioContext can only be changed when a node is drained,
38 + * the reconnect_delay_timer cannot be active here.
39 + */
40 + assert(!s->reconnect_delay_timer);
41 +
42 + if (s->ioc) {
43 + qio_channel_attach_aio_context(s->ioc, new_context);
44 + }
45 +}
46 +
47 +static void nbd_detach_aio_context(BlockDriverState *bs)
48 +{
49 + BDRVNBDState *s = bs->opaque;
50 +
51 + assert(!s->reconnect_delay_timer);
52 +
53 + if (s->ioc) {
54 + qio_channel_detach_aio_context(s->ioc);
55 + }
56 +}
57 +
58 static BlockDriver bdrv_nbd = {
59 .format_name = "nbd",
60 .protocol_name = "nbd",
61 @@ -2026,6 +2058,9 @@ static BlockDriver bdrv_nbd = {
62 .bdrv_dirname = nbd_dirname,
63 .strong_runtime_opts = nbd_strong_runtime_opts,
64 .bdrv_cancel_in_flight = nbd_cancel_in_flight,
65 +
66 + .bdrv_attach_aio_context = nbd_attach_aio_context,
67 + .bdrv_detach_aio_context = nbd_detach_aio_context,
68 };
69
70 static BlockDriver bdrv_nbd_tcp = {
71 @@ -2051,6 +2086,9 @@ static BlockDriver bdrv_nbd_tcp = {
72 .bdrv_dirname = nbd_dirname,
73 .strong_runtime_opts = nbd_strong_runtime_opts,
74 .bdrv_cancel_in_flight = nbd_cancel_in_flight,
75 +
76 + .bdrv_attach_aio_context = nbd_attach_aio_context,
77 + .bdrv_detach_aio_context = nbd_detach_aio_context,
78 };
79
80 static BlockDriver bdrv_nbd_unix = {
81 @@ -2076,6 +2114,9 @@ static BlockDriver bdrv_nbd_unix = {
82 .bdrv_dirname = nbd_dirname,
83 .strong_runtime_opts = nbd_strong_runtime_opts,
84 .bdrv_cancel_in_flight = nbd_cancel_in_flight,
85 +
86 + .bdrv_attach_aio_context = nbd_attach_aio_context,
87 + .bdrv_detach_aio_context = nbd_detach_aio_context,
88 };
89
90 static void bdrv_nbd_init(void)