All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Wei <w90p710@gmail.com>
To: jcody@redhat.com
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, w90p710@gmail.com
Subject: [Qemu-devel] [PATCH] block/mirror: enable detect zeroes when driving mirror
Date: Mon, 21 Nov 2016 09:24:39 +0800	[thread overview]
Message-ID: <20161121012439.2394-1-w90p710@gmail.com> (raw)

In order to preserve sparse disk image, detect_zeroes
should also be enabled when bdrv_get_block_status_above()
returns BDRV_BLOCK_DATA

Signed-off-by: Yang Wei <w90p710@gmail.com>
---
 block/mirror.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/mirror.c b/block/mirror.c
index b2c1fb8..8b20b7a 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -76,6 +76,7 @@ typedef struct MirrorOp {
     QEMUIOVector qiov;
     int64_t sector_num;
     int nb_sectors;
+    BlockdevDetectZeroesOptions backup_detect_zeroes;
 } MirrorOp;
 
 static BlockErrorAction mirror_error_action(MirrorBlockJob *s, bool read,
@@ -132,6 +133,8 @@ static void mirror_write_complete(void *opaque, int ret)
 {
     MirrorOp *op = opaque;
     MirrorBlockJob *s = op->s;
+    BlockDriverState *target = s->target;
+    target->detect_zeroes = op->backup_detect_zeroes;
     if (ret < 0) {
         BlockErrorAction action;
 
@@ -148,6 +151,7 @@ static void mirror_read_complete(void *opaque, int ret)
 {
     MirrorOp *op = opaque;
     MirrorBlockJob *s = op->s;
+    BlockDriverState *target = s->target;
     if (ret < 0) {
         BlockErrorAction action;
 
@@ -160,6 +164,9 @@ static void mirror_read_complete(void *opaque, int ret)
         mirror_iteration_done(op, ret);
         return;
     }
+    op->backup_detect_zeroes = target->detect_zeroes;
+    target->detect_zeroes = s->unmap ? BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP :
+        BLOCKDEV_DETECT_ZEROES_OPTIONS_ON;
     blk_aio_pwritev(s->target, op->sector_num * BDRV_SECTOR_SIZE, &op->qiov,
                     0, mirror_write_complete, op);
 }
-- 
2.10.2

             reply	other threads:[~2016-11-21  1:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-21  1:24 Yang Wei [this message]
2016-11-21  1:34 ` [Qemu-devel] [PATCH] block/mirror: enable detect zeroes when driving mirror no-reply
2016-11-21  6:51 ` Vasiliy Tolstov
2016-11-22  2:31   ` wyang
2016-11-22 13:44     ` Eric Blake
2016-11-23  3:14       ` wyang
2016-11-21 11:34 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2016-11-22  3:45   ` wyang
2016-11-22 10:09     ` Kevin Wolf
2016-11-23  3:12       ` wyang

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=20161121012439.2394-1-w90p710@gmail.com \
    --to=w90p710@gmail.com \
    --cc=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.