From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Fam Zheng <famz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL v2 for-2.4 v2 1/7] mirror: Speed up bitmap initial scanning
Date: Wed, 22 Jul 2015 12:43:39 +0100 [thread overview]
Message-ID: <1437565425-29861-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1437565425-29861-1-git-send-email-stefanha@redhat.com>
From: Fam Zheng <famz@redhat.com>
Limiting to sectors_per_chunk for each bdrv_is_allocated_above is slow,
because the underlying protocol driver would issue much more queries
than necessary. We should coalesce the query.
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: <1436413678-7114-4-git-send-email-famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/mirror.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 323f747..fc4d8f5 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -388,7 +388,7 @@ static void coroutine_fn mirror_run(void *opaque)
MirrorBlockJob *s = opaque;
MirrorExitData *data;
BlockDriverState *bs = s->common.bs;
- int64_t sector_num, end, sectors_per_chunk, length;
+ int64_t sector_num, end, length;
uint64_t last_pause_ns;
BlockDriverInfo bdi;
char backing_filename[2]; /* we only need 2 characters because we are only
@@ -442,7 +442,6 @@ static void coroutine_fn mirror_run(void *opaque)
goto immediate_exit;
}
- sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
mirror_free_init(s);
last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
@@ -450,7 +449,9 @@ static void coroutine_fn mirror_run(void *opaque)
/* 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;
+ /* Just to make sure we are not exceeding int limit. */
+ int nb_sectors = MIN(INT_MAX >> BDRV_SECTOR_BITS,
+ end - sector_num);
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
if (now - last_pause_ns > SLICE_TIME) {
@@ -462,8 +463,7 @@ static void coroutine_fn mirror_run(void *opaque)
goto immediate_exit;
}
- ret = bdrv_is_allocated_above(bs, base,
- sector_num, next - sector_num, &n);
+ ret = bdrv_is_allocated_above(bs, base, sector_num, nb_sectors, &n);
if (ret < 0) {
goto immediate_exit;
@@ -472,10 +472,8 @@ static void coroutine_fn mirror_run(void *opaque)
assert(n > 0);
if (ret == 1) {
bdrv_set_dirty_bitmap(s->dirty_bitmap, sector_num, n);
- sector_num = next;
- } else {
- sector_num += n;
}
+ sector_num += n;
}
}
--
2.4.3
next prev parent reply other threads:[~2015-07-22 11:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-22 11:43 [Qemu-devel] [PULL v2 for-2.4 v2 0/7] Block patches Stefan Hajnoczi
2015-07-22 11:43 ` Stefan Hajnoczi [this message]
2015-07-22 11:43 ` [Qemu-devel] [PULL v2 for-2.4 v2 2/7] qemu-timer: initialize "timers_done_ev" to set Stefan Hajnoczi
2015-07-22 11:43 ` [Qemu-devel] [PULL v2 for-2.4 v2 3/7] tests: remove irrelevant assertions from test-aio Stefan Hajnoczi
2015-07-22 11:43 ` [Qemu-devel] [PULL v2 for-2.4 v2 4/7] aio-win32: reorganize polling loop Stefan Hajnoczi
2015-07-22 11:43 ` [Qemu-devel] [PULL v2 for-2.4 v2 5/7] AioContext: fix broken ctx->dispatching optimization Stefan Hajnoczi
2015-07-23 14:14 ` Cornelia Huck
2015-07-23 17:20 ` Paolo Bonzini
2015-07-23 18:19 ` Paolo Bonzini
2015-07-23 19:19 ` Christian Borntraeger
2015-07-23 19:25 ` Paolo Bonzini
2015-07-23 19:29 ` Christian Borntraeger
2015-07-24 6:46 ` Cornelia Huck
2015-07-27 15:41 ` Stefan Hajnoczi
2015-07-22 11:43 ` [Qemu-devel] [PULL v2 for-2.4 v2 6/7] AioContext: fix broken placement of event_notifier_test_and_clear Stefan Hajnoczi
2015-07-22 11:43 ` [Qemu-devel] [PULL v2 for-2.4 v2 7/7] AioContext: optimize clearing the EventNotifier Stefan Hajnoczi
2015-07-22 14:02 ` [Qemu-devel] [PULL v2 for-2.4 v2 0/7] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437565425-29861-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).