cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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