From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com,
qemu-devel@nongnu.org, mreitz@redhat.com, den@openvz.org
Subject: [PATCH 3/3] block/nbd: nbd_co_reconnect_loop(): don't sleep if drained
Date: Mon, 20 Jul 2020 12:00:24 +0300 [thread overview]
Message-ID: <20200720090024.18186-4-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20200720090024.18186-1-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>
---
block/nbd.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 42146a26f7..d9cde30457 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -327,8 +327,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;
@@ -340,9 +338,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.21.0
next prev parent reply other threads:[~2020-07-20 9:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 9:00 [PATCH for-5.1? 0/3] Fix nbd reconnect dead-locks Vladimir Sementsov-Ogievskiy
2020-07-20 9:00 ` [PATCH 1/3] block/nbd: allow drain during reconnect attempt Vladimir Sementsov-Ogievskiy
2020-07-20 9:02 ` Vladimir Sementsov-Ogievskiy
2020-07-23 18:47 ` Eric Blake
2020-07-24 10:04 ` Vladimir Sementsov-Ogievskiy
2020-07-24 11:50 ` Vladimir Sementsov-Ogievskiy
2020-07-24 9:49 ` Vladimir Sementsov-Ogievskiy
2020-07-24 10:21 ` Vladimir Sementsov-Ogievskiy
2020-07-20 9:00 ` [PATCH 2/3] block/nbd: on shutdown terminate connection attempt Vladimir Sementsov-Ogievskiy
2020-07-23 18:52 ` Eric Blake
2020-07-20 9:00 ` Vladimir Sementsov-Ogievskiy [this message]
2020-07-23 18:55 ` [PATCH 3/3] block/nbd: nbd_co_reconnect_loop(): don't sleep if drained Eric Blake
2020-07-27 18:42 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200720090024.18186-4-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).