1 Return-Path: qemu-devel-bounces+aderumier=odiso.com@nongnu.org
2 Received: from mailpro.odiso.net (LHLO mailpro.odiso.net) (10.1.31.112) by
3 mailpro.odiso.net with LMTP; Thu, 9 Jul 2015 05:48:28 +0200 (CEST)
4 Received: from localhost (localhost [127.0.0.1])
5 by mailpro.odiso.net (Postfix) with ESMTP id E27A845C8E4B0
6 for <aderumier@oxygem.tv>; Thu, 9 Jul 2015 05:48:27 +0200 (CEST)
7 X-Virus-Scanned: amavisd-new at mailpro.odiso.com
11 X-Spam-Status: No, score=0 tagged_above=-10 required=4
12 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.001, SPF_PASS=-0.001]
13 autolearn=ham autolearn_force=no
14 Received: from mailpro.odiso.net ([127.0.0.1])
15 by localhost (mailpro.odiso.net [127.0.0.1]) (amavisd-new, port 10024)
16 with ESMTP id dJJWUgwkqqGc for <aderumier@oxygem.tv>;
17 Thu, 9 Jul 2015 05:48:26 +0200 (CEST)
18 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17])
19 by mailpro.odiso.net (Postfix) with ESMTPS id 79D8C40592FF1
20 for <aderumier@odiso.com>; Thu, 9 Jul 2015 05:48:26 +0200 (CEST)
21 Received: from localhost ([::1]:37746 helo=lists.gnu.org)
22 by lists.gnu.org with esmtp (Exim 4.71)
23 (envelope-from <qemu-devel-bounces+aderumier=odiso.com@nongnu.org>)
25 for aderumier@odiso.com; Wed, 08 Jul 2015 23:48:25 -0400
26 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55387)
27 by lists.gnu.org with esmtp (Exim 4.71)
28 (envelope-from <famz@redhat.com>) id 1ZD2oq-00078r-My
29 for qemu-devel@nongnu.org; Wed, 08 Jul 2015 23:48:17 -0400
30 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
31 (envelope-from <famz@redhat.com>) id 1ZD2op-0004hr-MC
32 for qemu-devel@nongnu.org; Wed, 08 Jul 2015 23:48:16 -0400
33 Received: from mx1.redhat.com ([209.132.183.28]:44555)
34 by eggs.gnu.org with esmtp (Exim 4.71)
35 (envelope-from <famz@redhat.com>)
36 id 1ZD2ol-0004g3-H0; Wed, 08 Jul 2015 23:48:11 -0400
37 Received: from int-mx09.intmail.prod.int.phx2.redhat.com
38 (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22])
39 by mx1.redhat.com (Postfix) with ESMTPS id 103F72B5EA0;
40 Thu, 9 Jul 2015 03:48:11 +0000 (UTC)
41 Received: from ad.nay.redhat.com. (dhcp-15-42.nay.redhat.com [10.66.15.42])
42 by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP
43 id t693lwp6028288; Wed, 8 Jul 2015 23:48:08 -0400
44 From: Fam Zheng <famz@redhat.com>
45 To: qemu-devel@nongnu.org
46 Date: Thu, 9 Jul 2015 11:47:58 +0800
47 Message-Id: <1436413678-7114-4-git-send-email-famz@redhat.com>
48 In-Reply-To: <1436413678-7114-1-git-send-email-famz@redhat.com>
49 References: <1436413678-7114-1-git-send-email-famz@redhat.com>
50 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
51 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
52 X-Received-From: 209.132.183.28
53 Cc: Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>,
55 Subject: [Qemu-devel] [PATCH 3/3] mirror: Speed up bitmap initial scanning
56 X-BeenThere: qemu-devel@nongnu.org
57 X-Mailman-Version: 2.1.14
59 List-Id: <qemu-devel.nongnu.org>
60 List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
61 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
62 List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel>
63 List-Post: <mailto:qemu-devel@nongnu.org>
64 List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
65 List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
66 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
67 Errors-To: qemu-devel-bounces+aderumier=odiso.com@nongnu.org
68 Sender: qemu-devel-bounces+aderumier=odiso.com@nongnu.org
70 Limiting to sectors_per_chunk for each bdrv_is_allocated_above is slow,
71 because the underlying protocol driver would issue much more queries
72 than necessary. We should coalesce the query.
74 Signed-off-by: Fam Zheng <famz@redhat.com>
76 block/mirror.c | 15 ++++++---------
77 1 file changed, 6 insertions(+), 9 deletions(-)
79 diff --git a/block/mirror.c b/block/mirror.c
80 index ca55578..e8cb592 100644
83 @@ -387,7 +387,7 @@ static void coroutine_fn mirror_run(void *opaque)
84 MirrorBlockJob *s = opaque;
86 BlockDriverState *bs = s->common.bs;
87 - int64_t sector_num, end, sectors_per_chunk, length;
88 + int64_t sector_num, end, length;
89 uint64_t last_pause_ns;
91 char backing_filename[2]; /* we only need 2 characters because we are only
92 @@ -441,7 +441,6 @@ static void coroutine_fn mirror_run(void *opaque)
96 - sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
99 last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
100 @@ -449,7 +448,9 @@ static void coroutine_fn mirror_run(void *opaque)
101 /* First part, loop on the sectors and initialize the dirty bitmap. */
102 BlockDriverState *base = s->base;
103 for (sector_num = 0; sector_num < end; ) {
104 - int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1;
105 + /* Just to make sure we are not exceeding int limit. */
106 + int nb_sectors = MIN(INT_MAX >> BDRV_SECTOR_BITS,
108 int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
110 if (now - last_pause_ns > SLICE_TIME) {
111 @@ -460,9 +461,7 @@ static void coroutine_fn mirror_run(void *opaque)
112 if (block_job_is_cancelled(&s->common)) {
116 - ret = bdrv_is_allocated_above(bs, base,
117 - sector_num, next - sector_num, &n);
118 + ret = bdrv_is_allocated_above(bs, base, sector_num, nb_sectors, &n);
122 @@ -471,10 +470,8 @@ static void coroutine_fn mirror_run(void *opaque)
125 bdrv_set_dirty_bitmap(s->dirty_bitmap, sector_num, n);