Received: from eggs.gnu.org ([2001:4830:134:3::10]:52074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WST3U-0003T3-Hq for qemu-devel@nongnu.org; Tue, 25 Mar 2014 11:14:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WST3P-000712-LU for qemu-devel@nongnu.org; Tue, 25 Mar 2014 11:14:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WST3P-00070x-DF for qemu-devel@nongnu.org; Tue, 25 Mar 2014 11:14:15 -0400 From: Stefan Hajnoczi Date: Tue, 25 Mar 2014 15:51:35 +0100 Message-Id: <1395759095-11276-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1395759095-11276-1-git-send-email-stefanha@redhat.com> References: <1395759095-11276-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL for-2.0 5/5] mirror: fix early wake from sleep due to aio List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Anthony Liguori 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 Signed-off-by: Stefan Hajnoczi --- 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