diff mbox series

[4/4] block/nbd: nbd_co_reconnect_loop(): don't connect if drained

Message ID 20200903190301.367620-5-vsementsov@virtuozzo.com
State New
Headers show
Series None | expand

Commit Message

Vladimir Sementsov-Ogievskiy Sept. 3, 2020, 7:03 p.m. UTC
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>
---
 block/nbd.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Eric Blake Sept. 23, 2020, 3:16 p.m. UTC | #1
On 9/3/20 2:03 PM, Vladimir Sementsov-Ogievskiy wrote:
> 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>
> ---
>   block/nbd.c | 3 +++
>   1 file changed, 3 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/block/nbd.c b/block/nbd.c
> index caae0e6d31..4548046cd7 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -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;
>               }
>
diff mbox series

Patch

diff --git a/block/nbd.c b/block/nbd.c
index caae0e6d31..4548046cd7 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -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;
             }