From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsT00-0007tl-8a for qemu-devel@nongnu.org; Wed, 13 May 2015 05:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsSzz-0002YD-63 for qemu-devel@nongnu.org; Wed, 13 May 2015 05:30:44 -0400 Message-ID: <555319B5.2040704@redhat.com> Date: Wed, 13 May 2015 11:30:29 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1431486673-19280-1-git-send-email-famz@redhat.com> In-Reply-To: <1431486673-19280-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block/mirror: Sleep periodically during bitmap scanning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , Jeff Cody , qemu-block@nongnu.org On 13/05/2015 05:11, Fam Zheng wrote: > 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. You were also planning to let bdrv_co_is_allocated/get_block_status return a larger p_num than nb_sectors---which maybe could make nb_sectors obsolete completely, I don't know. But this is already an improvement. Reviewed-by: Paolo Bonzini Thanks, Paolo > > Signed-off-by: Fam Zheng > --- > block/mirror.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/block/mirror.c b/block/mirror.c > index 1a1d997..baed225 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -467,11 +467,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); > > @@ -490,7 +502,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; >