Received: from eggs.gnu.org ([2001:4830:134:3::10]:39220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z48-0003Ak-VU for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Z3u-0007QT-H4 for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:28 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:60270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z3u-0007Q3-8a for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:14 -0400 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jul 2014 11:20:13 -0600 From: Michael Roth Date: Tue, 8 Jul 2014 12:16:44 -0500 Message-Id: <1404839947-1086-14-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 013/156] 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: qemu-stable@nongnu.org From: Stefan Hajnoczi 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 (cherry picked from commit 7b770c720b28b8ac5b82ae431f2f354b7f8add91) Signed-off-by: Michael Roth --- block/mirror.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 9bfc22f..2d9104e 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -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) -- 1.9.1