block/nbd: nbd_co_reconnect_loop(): don't connect if drained
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Thu, 3 Sep 2020 19:03:01 +0000 (22:03 +0300)
committerEric Blake <eblake@redhat.com>
Fri, 9 Oct 2020 20:04:32 +0000 (15:04 -0500)
In a recent commit 12c75e20a269ac we've improved
nbd_co_reconnect_loop() to not make drain wait for additional sleep.
Similarly, we shouldn't try to connect, if previous sleep was
interrupted by drain begin, otherwise drain_begin will have to wait for
the whole connection attempt.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200903190301.367620-5-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
block/nbd.c

index caae0e6d311cbd6005031d4afb4784831bc804fc..4548046cd7cd0f9630acecc21d7e7ae5e6620c85 100644 (file)
@@ -661,6 +661,9 @@ static coroutine_fn void nbd_co_reconnect_loop(BDRVNBDState *s)
         } else {
             qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, timeout,
                                       &s->connection_co_sleep_ns_state);
+            if (s->drained) {
+                continue;
+            }
             if (timeout < max_timeout) {
                 timeout *= 2;
             }