[pve-devel] [PATCH] qemu : add drive-mirror sleep patches

Dietmar Maurer dietmar at proxmox.com
Wed Jul 1 06:37:02 CEST 2015


applied (to master), thanks!

Note: I fixed the path for qemu-kvm/debian/patches/mirror-sleep2.patch
to debian/patches/mirror-sleep2.patch

On 07/01/2015 06:01 AM, Alexandre Derumier wrote:
> Currently when drive-mirror is starting,
> the vm and qmp it's hanging on bitmap scanning phase (mainly with raw, nfs and block raw driver).
>
> This patch do regular pause between each iteration
>
> The initial patch from qemu mailing is working,but pause time is really too short,
> so we still hang qmp hangs and qemu big slowdown.
>
> I increase it to SLICE_TIME, which is 100ms by default
>
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>   debian/patches/mirror-sleep.patch           | 58 +++++++++++++++++++++++++++++
>   debian/patches/series                       |  2 +
>   qemu-kvm/debian/patches/mirror-sleep2.patch | 28 ++++++++++++++
>   3 files changed, 88 insertions(+)
>   create mode 100644 debian/patches/mirror-sleep.patch
>   create mode 100644 qemu-kvm/debian/patches/mirror-sleep2.patch
>
> diff --git a/debian/patches/mirror-sleep.patch b/debian/patches/mirror-sleep.patch
> new file mode 100644
> index 0000000..37dc939
> --- /dev/null
> +++ b/debian/patches/mirror-sleep.patch
> @@ -0,0 +1,58 @@
> +From 2540abec85433596dd04640b14f75ceb13bbb342 Mon Sep 17 00:00:00 2001
> +From: Fam Zheng <famz at redhat.com>
> +Date: Wed, 13 May 2015 11:11:13 +0800
> +Subject: [PATCH] block/mirror: Sleep periodically during bitmap scanning
> +
> +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 <famz at redhat.com>
> +Reviewed-by: Wen Congyang <wency at cn.fujitsu.com>
> +Reviewed-by: Paolo Bonzini <pbonzini at redhat.com>
> +Reviewed-by: Stefan Hajnoczi <stefanha at redhat.com>
> +---
> + block/mirror.c | 13 ++++++++++++-
> + 1 file changed, 12 insertions(+), 1 deletion(-)
> +
> +diff --git a/block/mirror.c b/block/mirror.c
> +index 4056164..0a05971 100644
> +--- a/block/mirror.c
> ++++ b/block/mirror.c
> +@@ -432,11 +432,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);
> +
> +@@ -455,7 +467,6 @@ static void coroutine_fn mirror_run(void *opaque)
> +     }
> +
> +     bdrv_dirty_iter_init(bs, s->dirty_bitmap, &s->hbi);
> +-    last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
> +     for (;;) {
> +         uint64_t delay_ns = 0;
> +         int64_t cnt;
> +--
> +2.1.4
> +
> diff --git a/debian/patches/series b/debian/patches/series
> index 1105537..a018473 100644
> --- a/debian/patches/series
> +++ b/debian/patches/series
> @@ -33,3 +33,5 @@ add-qmp-get-link-status.patch
>   0001-friendlier-ai_flag-hints-for-ipv6-hosts.patch
>   0001-vvfat-add-a-label-option.patch
>   jemalloc.patch
> +mirror-sleep.patch
> +mirror-sleep2.patch
> diff --git a/qemu-kvm/debian/patches/mirror-sleep2.patch b/qemu-kvm/debian/patches/mirror-sleep2.patch
> new file mode 100644
> index 0000000..e1b59db
> --- /dev/null
> +++ b/qemu-kvm/debian/patches/mirror-sleep2.patch
> @@ -0,0 +1,28 @@
> +From d1ca17e6bfcf8292b85474cc871e015088672df4 Mon Sep 17 00:00:00 2001
> +From: Alexandre Derumier <aderumier at odiso.com>
> +Date: Wed, 1 Jul 2015 05:07:06 +0200
> +Subject: [PATCH] increase block_job_sleep_ns time to SLICE_TIME
> +
> +current value 0 is really too short to avoid qmp hangs
> +
> +Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> +---
> + block/mirror.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/block/mirror.c b/block/mirror.c
> +index 0a05971..2711249 100644
> +--- a/block/mirror.c
> ++++ b/block/mirror.c
> +@@ -442,7 +442,7 @@ static void coroutine_fn mirror_run(void *opaque)
> +
> +             if (now - last_pause_ns > SLICE_TIME) {
> +                 last_pause_ns = now;
> +-                block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, 0);
> ++                block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, SLICE_TIME);
> +             }
> +
> +             if (block_job_is_cancelled(&s->common)) {
> +--
> +2.1.4
> +





More information about the pve-devel mailing list