From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQyz3-0008Tu-Bd for qemu-devel@nongnu.org; Fri, 21 Mar 2014 08:55:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQyyx-0005sQ-Mc for qemu-devel@nongnu.org; Fri, 21 Mar 2014 08:55:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQyyx-0005sJ-Dn for qemu-devel@nongnu.org; Fri, 21 Mar 2014 08:55:31 -0400 From: Stefan Hajnoczi Date: Fri, 21 Mar 2014 13:55:19 +0100 Message-Id: <1395406519-21410-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1395406519-21410-1-git-send-email-stefanha@redhat.com> References: <1395406519-21410-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH for-2.0 2/2] 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: Kevin Wolf , Michal Privoznik , Jeff Cody , Joaquim Barrera , Stefan Hajnoczi , Paolo Bonzini 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