]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
mirror: fix early wake from sleep due to aio
authorStefan Hajnoczi <stefanha@redhat.com>
Fri, 21 Mar 2014 12:55:19 +0000 (13:55 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 25 Jun 2014 20:26:29 +0000 (15:26 -0500)
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>
(cherry picked from commit 7b770c720b28b8ac5b82ae431f2f354b7f8add91)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/mirror.c

index 9bfc22f5711a92139ed2bef8c91f4de48d5488d6..2d9104efc065a8aa72a3802274c11f4bf1199752 100644 (file)
@@ -95,7 +95,14 @@ static void mirror_iteration_done(MirrorOp *op, int ret)
     }
 
     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)