[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 9/9] block/nbd: nbd_co_reconnect_loop(): don't sleep if drained
From: |
Eric Blake |
Subject: |
[PULL 9/9] block/nbd: nbd_co_reconnect_loop(): don't sleep if drained |
Date: |
Tue, 28 Jul 2020 10:04:07 -0500 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
We try to go to wakeable sleep, so that, if drain begins it will break
the sleep. But what if nbd_client_co_drain_begin() already called and
s->drained is already true? We'll go to sleep, and drain will have to
wait for the whole timeout. Let's improve it.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200727184751.15704-5-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/nbd.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 620c97be6ba2..7bb881fef49c 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -341,8 +341,6 @@ static coroutine_fn void nbd_co_reconnect_loop(BDRVNBDState
*s)
qemu_co_queue_restart_all(&s->free_sema);
}
- qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, timeout,
- &s->connection_co_sleep_ns_state);
if (s->drained) {
bdrv_dec_in_flight(s->bs);
s->wait_drained_end = true;
@@ -354,9 +352,12 @@ static coroutine_fn void
nbd_co_reconnect_loop(BDRVNBDState *s)
qemu_coroutine_yield();
}
bdrv_inc_in_flight(s->bs);
- }
- if (timeout < max_timeout) {
- timeout *= 2;
+ } else {
+ qemu_co_sleep_ns_wakeable(QEMU_CLOCK_REALTIME, timeout,
+ &s->connection_co_sleep_ns_state);
+ if (timeout < max_timeout) {
+ timeout *= 2;
+ }
}
nbd_reconnect_attempt(s);
--
2.27.0
- [PULL 0/9] nbd patches for -rc2, 2020-07-28, Eric Blake, 2020/07/28
- [PULL 2/9] block: nbd: Fix convert qcow2 compressed to nbd, Eric Blake, 2020/07/28
- [PULL 1/9] nbd: Fix large trim/zero requests, Eric Blake, 2020/07/28
- [PULL 3/9] iotests: Make qemu_nbd_popen() a contextmanager, Eric Blake, 2020/07/28
- [PULL 5/9] iotests: Test convert to qcow2 compressed to NBD, Eric Blake, 2020/07/28
- [PULL 6/9] block/nbd: split nbd_establish_connection out of nbd_client_connect, Eric Blake, 2020/07/28
- [PULL 7/9] block/nbd: allow drain during reconnect attempt, Eric Blake, 2020/07/28
- [PULL 4/9] iotests: Add more qemu_img helpers, Eric Blake, 2020/07/28
- [PULL 8/9] block/nbd: on shutdown terminate connection attempt, Eric Blake, 2020/07/28
- [PULL 9/9] block/nbd: nbd_co_reconnect_loop(): don't sleep if drained,
Eric Blake <=
- Re: [PULL 0/9] nbd patches for -rc2, 2020-07-28, Peter Maydell, 2020/07/28