aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-03-21 13:55:19 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2014-03-25 14:09:50 +0100
commit7b770c720b28b8ac5b82ae431f2f354b7f8add91 (patch)
tree80ea19c13fa7c1cee21854bc1b96fdbf30fd25ac
parentcc8c9d6c6f28e4e376a6561a2a31524fd069bc2d (diff)
mirror: fix early wake from sleep due to aio
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>
-rw-r--r--block/mirror.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/block/mirror.c b/block/mirror.c
index adb09cf4ab..0ef41f999e 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)