]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/mirror-sleep.patch
mirror: Speed up bitmap initial scanning
[pve-qemu-kvm.git] / debian / patches / mirror-sleep.patch
1 From 2540abec85433596dd04640b14f75ceb13bbb342 Mon Sep 17 00:00:00 2001
2 From: Fam Zheng <famz@redhat.com>
3 Date: Wed, 13 May 2015 11:11:13 +0800
4 Subject: [PATCH] block/mirror: Sleep periodically during bitmap scanning
5
6 Before, we only yield after initializing dirty bitmap, where the QMP
7 command would return. That may take very long, and guest IO will be
8 blocked.
9
10 Add sleep points like the later mirror iterations.
11
12 Signed-off-by: Fam Zheng <famz@redhat.com>
13 Reviewed-by: Wen Congyang <wency@cn.fujitsu.com>
14 Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
15 Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
16 ---
17 block/mirror.c | 13 ++++++++++++-
18 1 file changed, 12 insertions(+), 1 deletion(-)
19
20 diff --git a/block/mirror.c b/block/mirror.c
21 index 4056164..0a05971 100644
22 --- a/block/mirror.c
23 +++ b/block/mirror.c
24 @@ -432,11 +432,23 @@ static void coroutine_fn mirror_run(void *opaque)
25 sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS;
26 mirror_free_init(s);
27
28 + last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
29 if (!s->is_none_mode) {
30 /* First part, loop on the sectors and initialize the dirty bitmap. */
31 BlockDriverState *base = s->base;
32 for (sector_num = 0; sector_num < end; ) {
33 int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1;
34 + int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
35 +
36 + if (now - last_pause_ns > SLICE_TIME) {
37 + last_pause_ns = now;
38 + block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, 0);
39 + }
40 +
41 + if (block_job_is_cancelled(&s->common)) {
42 + goto immediate_exit;
43 + }
44 +
45 ret = bdrv_is_allocated_above(bs, base,
46 sector_num, next - sector_num, &n);
47
48 @@ -455,7 +467,6 @@ static void coroutine_fn mirror_run(void *opaque)
49 }
50
51 bdrv_dirty_iter_init(bs, s->dirty_bitmap, &s->hbi);
52 - last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
53 for (;;) {
54 uint64_t delay_ns = 0;
55 int64_t cnt;
56 --
57 2.1.4
58