thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-block-add-flags-to-bdrv_-_write_zeroes.patch.patch.patch

0a122b
From 0f795e4e9e128f9ff88a128ed8590d2357228b80 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <0f795e4e9e128f9ff88a128ed8590d2357228b80.1389014116.git.minovotn@redhat.com>
0a122b
In-Reply-To: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
0a122b
References: <c8cc35838d42aa286242772d97e3a9be7bb786ba.1389014116.git.minovotn@redhat.com>
0a122b
From: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Date: Mon, 9 Dec 2013 14:08:55 +0100
0a122b
Subject: [PATCH 07/50] block: add flags to bdrv_*_write_zeroes
0a122b
0a122b
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: <1386598178-11845-10-git-send-email-pbonzini@redhat.com>
0a122b
Patchwork-id: 56046
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH 09/52] block: add flags to bdrv_*_write_zeroes
0a122b
Bugzilla: 1007815
0a122b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
From: Peter Lieven <pl@kamp.de>
0a122b
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
Signed-off-by: Peter Lieven <pl@kamp.de>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit aa7bfbfff792538a9eeefe879fc4c629aa0b4203)
0a122b
0a122b
Conflicts:
0a122b
	block.c [missing before_write notifier]
0a122b
	block/backup.c [missing]
0a122b
	block/qcow2-cluster.c [missing function to expand zero clusters]
0a122b
	block/raw_bsd.c [replaced by block/raw.c]
0a122b
	qemu-io-cmds.c [replaced by qemu-io.c]
0a122b
---
0a122b
 block-migration.c         |  2 +-
0a122b
 block.c                   | 20 +++++++++++---------
0a122b
 block/qcow2.c             |  2 +-
0a122b
 block/qed.c               |  3 ++-
0a122b
 block/raw.c               |  5 +++--
0a122b
 block/vmdk.c              |  3 ++-
0a122b
 include/block/block.h     |  4 ++--
0a122b
 include/block/block_int.h |  2 +-
0a122b
 qemu-io.c                 |  2 +-
0a122b
 9 files changed, 24 insertions(+), 19 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 block-migration.c         |  2 +-
0a122b
 block.c                   | 20 +++++++++++---------
0a122b
 block/qcow2.c             |  2 +-
0a122b
 block/qed.c               |  3 ++-
0a122b
 block/raw.c               |  5 +++--
0a122b
 block/vmdk.c              |  3 ++-
0a122b
 include/block/block.h     |  4 ++--
0a122b
 include/block/block_int.h |  2 +-
0a122b
 qemu-io.c                 |  2 +-
0a122b
 9 files changed, 24 insertions(+), 19 deletions(-)
0a122b
0a122b
diff --git a/block-migration.c b/block-migration.c
0a122b
index f803f20..3b22db6 100644
0a122b
--- a/block-migration.c
0a122b
+++ b/block-migration.c
0a122b
@@ -780,7 +780,7 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
0a122b
             }
0a122b
 
0a122b
             if (flags & BLK_MIG_FLAG_ZERO_BLOCK) {
0a122b
-                ret = bdrv_write_zeroes(bs, addr, nr_sectors);
0a122b
+                ret = bdrv_write_zeroes(bs, addr, nr_sectors, 0);
0a122b
             } else {
0a122b
                 buf = g_malloc(BLOCK_SIZE);
0a122b
                 qemu_get_buffer(f, buf, BLOCK_SIZE);
0a122b
diff --git a/block.c b/block.c
0a122b
index b7ca799..698334a 100644
0a122b
--- a/block.c
0a122b
+++ b/block.c
0a122b
@@ -79,7 +79,7 @@ static BlockDriverAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,
0a122b
                                                bool is_write);
0a122b
 static void coroutine_fn bdrv_co_do_rw(void *opaque);
0a122b
 static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
0a122b
-    int64_t sector_num, int nb_sectors);
0a122b
+    int64_t sector_num, int nb_sectors, BdrvRequestFlags flags);
0a122b
 
0a122b
 static bool bdrv_exceed_bps_limits(BlockDriverState *bs, int nb_sectors,
0a122b
         bool is_write, double elapsed_time, uint64_t *wait);
0a122b
@@ -2405,10 +2405,11 @@ int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov)
0a122b
     return bdrv_rwv_co(bs, sector_num, qiov, true, 0);
0a122b
 }
0a122b
 
0a122b
-int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
0a122b
+int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
0a122b
+                      int nb_sectors, BdrvRequestFlags flags)
0a122b
 {
0a122b
     return bdrv_rw_co(bs, sector_num, NULL, nb_sectors, true,
0a122b
-                      BDRV_REQ_ZERO_WRITE);
0a122b
+                      BDRV_REQ_ZERO_WRITE | flags);
0a122b
 }
0a122b
 
0a122b
 int bdrv_pread(BlockDriverState *bs, int64_t offset,
0a122b
@@ -2590,7 +2591,7 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
0a122b
     if (drv->bdrv_co_write_zeroes &&
0a122b
         buffer_is_zero(bounce_buffer, iov.iov_len)) {
0a122b
         ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num,
0a122b
-                                      cluster_nb_sectors);
0a122b
+                                      cluster_nb_sectors, 0);
0a122b
     } else {
0a122b
         /* This does not change the data on the disk, it is not necessary
0a122b
          * to flush even in cache=writethrough mode.
0a122b
@@ -2724,7 +2725,7 @@ int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
0a122b
 }
0a122b
 
0a122b
 static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
0a122b
-    int64_t sector_num, int nb_sectors)
0a122b
+    int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
0a122b
 {
0a122b
     BlockDriver *drv = bs->drv;
0a122b
     QEMUIOVector qiov;
0a122b
@@ -2736,7 +2737,7 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
0a122b
 
0a122b
     /* First try the efficient write zeroes operation */
0a122b
     if (drv->bdrv_co_write_zeroes) {
0a122b
-        ret = drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors);
0a122b
+        ret = drv->bdrv_co_write_zeroes(bs, sector_num, nb_sectors, flags);
0a122b
         if (ret != -ENOTSUP) {
0a122b
             return ret;
0a122b
         }
0a122b
@@ -2787,7 +2788,7 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,
0a122b
     tracked_request_begin(&req, bs, sector_num, nb_sectors, true);
0a122b
 
0a122b
     if (flags & BDRV_REQ_ZERO_WRITE) {
0a122b
-        ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors);
0a122b
+        ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags);
0a122b
     } else {
0a122b
         ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
0a122b
     }
0a122b
@@ -2821,12 +2822,13 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
0a122b
 }
0a122b
 
0a122b
 int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs,
0a122b
-                                      int64_t sector_num, int nb_sectors)
0a122b
+                                      int64_t sector_num, int nb_sectors,
0a122b
+                                      BdrvRequestFlags flags)
0a122b
 {
0a122b
     trace_bdrv_co_write_zeroes(bs, sector_num, nb_sectors);
0a122b
 
0a122b
     return bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL,
0a122b
-                             BDRV_REQ_ZERO_WRITE);
0a122b
+                             BDRV_REQ_ZERO_WRITE | flags);
0a122b
 }
0a122b
 
0a122b
 /**
0a122b
diff --git a/block/qcow2.c b/block/qcow2.c
0a122b
index 8de8892..c109646 100644
0a122b
--- a/block/qcow2.c
0a122b
+++ b/block/qcow2.c
0a122b
@@ -1685,7 +1685,7 @@ static int qcow2_make_empty(BlockDriverState *bs)
0a122b
 }
0a122b
 
0a122b
 static coroutine_fn int qcow2_co_write_zeroes(BlockDriverState *bs,
0a122b
-    int64_t sector_num, int nb_sectors)
0a122b
+    int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
0a122b
 {
0a122b
     int ret;
0a122b
     BDRVQcowState *s = bs->opaque;
0a122b
diff --git a/block/qed.c b/block/qed.c
0a122b
index 084dc0a..e163372 100644
0a122b
--- a/block/qed.c
0a122b
+++ b/block/qed.c
0a122b
@@ -1397,7 +1397,8 @@ static void coroutine_fn qed_co_write_zeroes_cb(void *opaque, int ret)
0a122b
 
0a122b
 static int coroutine_fn bdrv_qed_co_write_zeroes(BlockDriverState *bs,
0a122b
                                                  int64_t sector_num,
0a122b
-                                                 int nb_sectors)
0a122b
+                                                 int nb_sectors,
0a122b
+                                                 BdrvRequestFlags flags)
0a122b
 {
0a122b
     BlockDriverAIOCB *blockacb;
0a122b
     BDRVQEDState *s = bs->opaque;
0a122b
diff --git a/block/raw.c b/block/raw.c
0a122b
index e1ed8cc..67d6445 100644
0a122b
--- a/block/raw.c
0a122b
+++ b/block/raw.c
0a122b
@@ -47,9 +47,10 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs,
0a122b
 
0a122b
 static int coroutine_fn raw_co_write_zeroes(BlockDriverState *bs,
0a122b
                                             int64_t sector_num,
0a122b
-                                            int nb_sectors)
0a122b
+                                            int nb_sectors,
0a122b
+                                            BdrvRequestFlags flags)
0a122b
 {
0a122b
-    return bdrv_co_write_zeroes(bs->file, sector_num, nb_sectors);
0a122b
+    return bdrv_co_write_zeroes(bs->file, sector_num, nb_sectors, flags);
0a122b
 }
0a122b
 
0a122b
 static int64_t raw_getlength(BlockDriverState *bs)
0a122b
diff --git a/block/vmdk.c b/block/vmdk.c
0a122b
index 7ec6427..6d676e4 100644
0a122b
--- a/block/vmdk.c
0a122b
+++ b/block/vmdk.c
0a122b
@@ -1426,7 +1426,8 @@ static coroutine_fn int vmdk_co_write(BlockDriverState *bs, int64_t sector_num,
0a122b
 
0a122b
 static int coroutine_fn vmdk_co_write_zeroes(BlockDriverState *bs,
0a122b
                                              int64_t sector_num,
0a122b
-                                             int nb_sectors)
0a122b
+                                             int nb_sectors,
0a122b
+                                             BdrvRequestFlags flags)
0a122b
 {
0a122b
     int ret;
0a122b
     BDRVVmdkState *s = bs->opaque;
0a122b
diff --git a/include/block/block.h b/include/block/block.h
0a122b
index ce6e897..2d78a84 100644
0a122b
--- a/include/block/block.h
0a122b
+++ b/include/block/block.h
0a122b
@@ -194,7 +194,7 @@ int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
0a122b
 int bdrv_write(BlockDriverState *bs, int64_t sector_num,
0a122b
                const uint8_t *buf, int nb_sectors);
0a122b
 int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
0a122b
-               int nb_sectors);
0a122b
+               int nb_sectors, BdrvRequestFlags flags);
0a122b
 int bdrv_writev(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov);
0a122b
 int bdrv_pread(BlockDriverState *bs, int64_t offset,
0a122b
                void *buf, int count);
0a122b
@@ -216,7 +216,7 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
0a122b
  * because it may allocate memory for the entire region.
0a122b
  */
0a122b
 int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
0a122b
-    int nb_sectors);
0a122b
+    int nb_sectors, BdrvRequestFlags flags);
0a122b
 BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
0a122b
     const char *backing_file);
0a122b
 int bdrv_get_backing_file_depth(BlockDriverState *bs);
0a122b
diff --git a/include/block/block_int.h b/include/block/block_int.h
0a122b
index 8223f5b..236c0c2 100644
0a122b
--- a/include/block/block_int.h
0a122b
+++ b/include/block/block_int.h
0a122b
@@ -125,7 +125,7 @@ struct BlockDriver {
0a122b
      * instead.
0a122b
      */
0a122b
     int coroutine_fn (*bdrv_co_write_zeroes)(BlockDriverState *bs,
0a122b
-        int64_t sector_num, int nb_sectors);
0a122b
+        int64_t sector_num, int nb_sectors, BdrvRequestFlags flags);
0a122b
     int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs,
0a122b
         int64_t sector_num, int nb_sectors);
0a122b
     int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,
0a122b
diff --git a/qemu-io.c b/qemu-io.c
0a122b
index df21022..393c2c8 100644
0a122b
--- a/qemu-io.c
0a122b
+++ b/qemu-io.c
0a122b
@@ -234,7 +234,7 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque)
0a122b
     CoWriteZeroes *data = opaque;
0a122b
 
0a122b
     data->ret = bdrv_co_write_zeroes(bs, data->offset / BDRV_SECTOR_SIZE,
0a122b
-                                     data->count / BDRV_SECTOR_SIZE);
0a122b
+                                     data->count / BDRV_SECTOR_SIZE, 0);
0a122b
     data->done = true;
0a122b
     if (data->ret < 0) {
0a122b
         *data->total = data->ret;
0a122b
-- 
0a122b
1.7.11.7
0a122b