thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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