All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/mirror: enable detect zeroes when driving mirror
@ 2016-11-21  1:24 Yang Wei
  2016-11-21  1:34 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Yang Wei @ 2016-11-21  1:24 UTC (permalink / raw)
  To: jcody; +Cc: qemu-block, qemu-devel, w90p710

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-11-23  3:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21  1:24 [Qemu-devel] [PATCH] block/mirror: enable detect zeroes when driving mirror Yang Wei
2016-11-21  1:34 ` 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

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.