From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL for-2.0 5/5] mirror: fix early wake from sleep due to aio
Date: Tue, 25 Mar 2014 15:51:35 +0100 [thread overview]
Message-ID: <1395759095-11276-6-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1395759095-11276-1-git-send-email-stefanha@redhat.com>
The mirror blockjob coroutine rate-limits itself by sleeping. The
coroutine also performs I/O asynchronously so it's important that the
aio callback doesn't wake the coroutine early as that breaks
rate-limiting.
Reported-by: Joaquim Barrera <jbarrera@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/mirror.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/block/mirror.c b/block/mirror.c
index adb09cf..0ef41f9 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -98,7 +98,14 @@ static void mirror_iteration_done(MirrorOp *op, int ret)
qemu_iovec_destroy(&op->qiov);
g_slice_free(MirrorOp, op);
- qemu_coroutine_enter(s->common.co, NULL);
+
+ /* Enter coroutine when it is not sleeping. The coroutine sleeps to
+ * rate-limit itself. The coroutine will eventually resume since there is
+ * a sleep timeout so don't wake it early.
+ */
+ if (s->common.busy) {
+ qemu_coroutine_enter(s->common.co, NULL);
+ }
}
static void mirror_write_complete(void *opaque, int ret)
--
1.8.5.3
next prev parent reply other threads:[~2014-03-25 15:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-25 14:51 [Qemu-devel] [PULL for-2.0 0/5] Block patches Stefan Hajnoczi
2014-03-25 14:51 ` [Qemu-devel] [PULL for-2.0 1/5] osdep: initialize glib threads in all QEMU tools Stefan Hajnoczi
2014-03-25 14:51 ` [Qemu-devel] [PULL for-2.0 2/5] qemu-img: mandate argument to 'qemu-img check --repair' Stefan Hajnoczi
2014-03-25 14:51 ` [Qemu-devel] [PULL for-2.0 3/5] Fixed various typos Stefan Hajnoczi
2014-03-25 14:51 ` [Qemu-devel] [PULL for-2.0 4/5] mirror: fix throttling delay calculation Stefan Hajnoczi
2014-03-25 14:51 ` Stefan Hajnoczi [this message]
2014-03-25 15:24 ` [Qemu-devel] [PULL for-2.0 0/5] Block patches Stefan Hajnoczi
2014-03-25 15:50 ` Peter Maydell
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=1395759095-11276-6-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@amazon.com \
--cc=peter.maydell@linaro.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).