All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: qemu-block@nongnu.org
Cc: jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL for-2.4 1/5] block/mirror: Sleep periodically during bitmap scanning
Date: Tue, 14 Jul 2015 22:26:53 -0400	[thread overview]
Message-ID: <1436927217-383-2-git-send-email-jcody@redhat.com> (raw)
In-Reply-To: <1436927217-383-1-git-send-email-jcody@redhat.com>

From: Fam Zheng <famz@redhat.com>

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@redhat.com>
Reviewed-by: Wen Congyang <wency@cn.fujitsu.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1431486673-19280-1-git-send-email-famz@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/mirror.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/block/mirror.c b/block/mirror.c
index d409337..a2700ca 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -444,11 +444,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);
 
@@ -467,7 +479,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;
-- 
1.9.3

  reply	other threads:[~2015-07-15  2:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  2:26 [Qemu-devel] [PULL for-2.4 0/5] Block layer patches for 2.4.0-rc1 Jeff Cody
2015-07-15  2:26 ` Jeff Cody [this message]
2015-07-15  2:26 ` [Qemu-devel] [PULL for-2.4 2/5] blockdev: no need to drain in qmp_block_commit Jeff Cody
2015-07-15  2:26 ` [Qemu-devel] [PULL for-2.4 3/5] block: keep bitmap if incremental backup job is cancelled Jeff Cody
2015-07-15  2:26 ` [Qemu-devel] [PULL for-2.4 4/5] mirror: correct buf_size Jeff Cody
2015-07-15  2:26 ` [Qemu-devel] [PULL for-2.4 5/5] block/curl: Don't lose original error when a connection fails Jeff Cody
2015-07-15 14:27 ` [Qemu-devel] [PULL for-2.4 0/5] Block layer patches for 2.4.0-rc1 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=1436927217-383-2-git-send-email-jcody@redhat.com \
    --to=jcody@redhat.com \
    --cc=qemu-block@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.