cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
432cb7
From 8e23c0f208c6bd5bb64c4f6e4863b93fa6f4e9de Mon Sep 17 00:00:00 2001
432cb7
From: Hanna Reitz <hreitz@redhat.com>
432cb7
Date: Fri, 4 Feb 2022 12:10:06 +0100
432cb7
Subject: [PATCH 1/6] block/nbd: Delete reconnect delay timer when done
432cb7
432cb7
RH-Author: Hanna Reitz <hreitz@redhat.com>
432cb7
RH-MergeRequest: 117: block/nbd: Handle AioContext changes
432cb7
RH-Commit: [1/6] 70814602a8a43a7c14857d76266d82b1aa5174a9
432cb7
RH-Bugzilla: 2035185
432cb7
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
432cb7
RH-Acked-by: Eric Blake <eblake@redhat.com>
432cb7
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
432cb7
432cb7
We start the reconnect delay timer to cancel the reconnection attempt
432cb7
after a while.  Once nbd_co_do_establish_connection() has returned, this
432cb7
attempt is over, and we no longer need the timer.
432cb7
432cb7
Delete it before returning from nbd_reconnect_attempt(), so that it does
432cb7
not persist beyond the I/O request that was paused for reconnecting; we
432cb7
do not want it to fire in a drained section, because all sort of things
432cb7
can happen in such a section (e.g. the AioContext might be changed, and
432cb7
we do not want the timer to fire in the wrong context; or the BDS might
432cb7
even be deleted, and so the timer CB would access already-freed data).
432cb7
432cb7
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
432cb7
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
432cb7
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
432cb7
(cherry picked from commit 3ce1fc16bad9c3f8b7b10b451a224d6d76e5c551)
432cb7
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
432cb7
---
432cb7
 block/nbd.c | 7 +++++++
432cb7
 1 file changed, 7 insertions(+)
432cb7
432cb7
diff --git a/block/nbd.c b/block/nbd.c
432cb7
index 5ef462db1b..b8e5a9b4cc 100644
432cb7
--- a/block/nbd.c
432cb7
+++ b/block/nbd.c
432cb7
@@ -353,6 +353,13 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
432cb7
     }
432cb7
 
432cb7
     nbd_co_do_establish_connection(s->bs, NULL);
432cb7
+
432cb7
+    /*
432cb7
+     * The reconnect attempt is done (maybe successfully, maybe not), so
432cb7
+     * we no longer need this timer.  Delete it so it will not outlive
432cb7
+     * this I/O request (so draining removes all timers).
432cb7
+     */
432cb7
+    reconnect_delay_timer_del(s);
432cb7
 }
432cb7
 
432cb7
 static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle)
432cb7
-- 
432cb7
2.27.0
432cb7