From patchwork Wed Jul 15 02:26:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 495375 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D2352140319 for ; Wed, 15 Jul 2015 12:27:41 +1000 (AEST) Received: from localhost ([::1]:33536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFCQ2-000356-SW for incoming@patchwork.ozlabs.org; Tue, 14 Jul 2015 22:27:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFCPd-0002FS-5T for qemu-devel@nongnu.org; Tue, 14 Jul 2015 22:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFCPb-00015J-Ma for qemu-devel@nongnu.org; Tue, 14 Jul 2015 22:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFCPW-0000zs-Jj; Tue, 14 Jul 2015 22:27:02 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 387A13589F8; Wed, 15 Jul 2015 02:27:02 +0000 (UTC) Received: from localhost (ovpn-112-22.phx2.redhat.com [10.3.112.22]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6F2R0Vn005945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Tue, 14 Jul 2015 22:27:01 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 14 Jul 2015 22:26:53 -0400 Message-Id: <1436927217-383-2-git-send-email-jcody@redhat.com> In-Reply-To: <1436927217-383-1-git-send-email-jcody@redhat.com> References: <1436927217-383-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: jcody@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL for-2.4 1/5] block/mirror: Sleep periodically during bitmap scanning X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Fam Zheng Before, we only yield after initializing dirty bitmap, where the QMP command would return. That may take very long, and guest IO will be blocked. Add sleep points like the later mirror iterations. Signed-off-by: Fam Zheng Reviewed-by: Wen Congyang Reviewed-by: Paolo Bonzini Reviewed-by: Stefan Hajnoczi Message-id: 1431486673-19280-1-git-send-email-famz@redhat.com Signed-off-by: Jeff Cody --- block/mirror.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index d409337..a2700ca 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -444,11 +444,23 @@ static void coroutine_fn mirror_run(void *opaque) sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; mirror_free_init(s); + last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); if (!s->is_none_mode) { /* First part, loop on the sectors and initialize the dirty bitmap. */ BlockDriverState *base = s->base; for (sector_num = 0; sector_num < end; ) { int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1; + int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); + + if (now - last_pause_ns > SLICE_TIME) { + last_pause_ns = now; + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, 0); + } + + if (block_job_is_cancelled(&s->common)) { + goto immediate_exit; + } + ret = bdrv_is_allocated_above(bs, base, sector_num, next - sector_num, &n); @@ -467,7 +479,6 @@ static void coroutine_fn mirror_run(void *opaque) } bdrv_dirty_iter_init(s->dirty_bitmap, &s->hbi); - last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); for (;;) { uint64_t delay_ns = 0; int64_t cnt;