Blame SOURCES/kvm-block-add-wrappers-for-logical-block-provisioning-in.patch.patch.patch

0a122b
From 53d8964bc0e80e99d5ccb15100ecb93a7b5f74b0 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <53d8964bc0e80e99d5ccb15100ecb93a7b5f74b0.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:58 +0100
0a122b
Subject: [PATCH 10/50] block: add wrappers for logical block provisioning
0a122b
 information
0a122b
0a122b
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: <1386598178-11845-13-git-send-email-pbonzini@redhat.com>
0a122b
Patchwork-id: 56050
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH 12/52] block: add wrappers for logical block provisioning information
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
This adds 2 wrappers to read the unallocated_blocks_are_zero and
0a122b
can_write_zeroes_with_unmap info from the BDI. The wrappers are
0a122b
required to check for the existence of a backing_hd and
0a122b
if the devices are opened with the correct flags.
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 4ce786914b745a144a9eda1ea33f3ff98328c527)
0a122b
---
0a122b
 block.c               | 30 ++++++++++++++++++++++++++++++
0a122b
 include/block/block.h |  2 ++
0a122b
 2 files changed, 32 insertions(+)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 block.c               | 30 ++++++++++++++++++++++++++++++
0a122b
 include/block/block.h |  2 ++
0a122b
 2 files changed, 32 insertions(+)
0a122b
0a122b
diff --git a/block.c b/block.c
0a122b
index 77167f0..2fae459 100644
0a122b
--- a/block.c
0a122b
+++ b/block.c
0a122b
@@ -3121,6 +3121,36 @@ int bdrv_has_zero_init(BlockDriverState *bs)
0a122b
     return 0;
0a122b
 }
0a122b
 
0a122b
+bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs)
0a122b
+{
0a122b
+    BlockDriverInfo bdi;
0a122b
+
0a122b
+    if (bs->backing_hd) {
0a122b
+        return false;
0a122b
+    }
0a122b
+
0a122b
+    if (bdrv_get_info(bs, &bdi) == 0) {
0a122b
+        return bdi.unallocated_blocks_are_zero;
0a122b
+    }
0a122b
+
0a122b
+    return false;
0a122b
+}
0a122b
+
0a122b
+bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
0a122b
+{
0a122b
+    BlockDriverInfo bdi;
0a122b
+
0a122b
+    if (bs->backing_hd || !(bs->open_flags & BDRV_O_UNMAP)) {
0a122b
+        return false;
0a122b
+    }
0a122b
+
0a122b
+    if (bdrv_get_info(bs, &bdi) == 0) {
0a122b
+        return bdi.can_write_zeroes_with_unmap;
0a122b
+    }
0a122b
+
0a122b
+    return false;
0a122b
+}
0a122b
+
0a122b
 typedef struct BdrvCoGetBlockStatusData {
0a122b
     BlockDriverState *bs;
0a122b
     BlockDriverState *base;
0a122b
diff --git a/include/block/block.h b/include/block/block.h
0a122b
index ab3044e..1958d98 100644
0a122b
--- a/include/block/block.h
0a122b
+++ b/include/block/block.h
0a122b
@@ -330,6 +330,8 @@ int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
0a122b
 int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
0a122b
 int bdrv_has_zero_init_1(BlockDriverState *bs);
0a122b
 int bdrv_has_zero_init(BlockDriverState *bs);
0a122b
+bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs);
0a122b
+bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
0a122b
 int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
0a122b
                               int nb_sectors, int *pnum);
0a122b
 int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
0a122b
-- 
0a122b
1.7.11.7
0a122b