|
|
218e99 |
From 95dd0c697b1b924c282cad302fc7f5af3330993d Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
Date: Fri, 18 Oct 2013 08:14:40 +0200
|
|
|
218e99 |
Subject: [PATCH 15/81] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
Message-id: <1382084091-16636-16-git-send-email-pbonzini@redhat.com>
|
|
|
218e99 |
Patchwork-id: 54998
|
|
|
218e99 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 15/26] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO
|
|
|
218e99 |
Bugzilla: 989646
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
Alternatively, this could use a "discard zeroes data" flag returned
|
|
|
218e99 |
by bdrv_get_info.
|
|
|
218e99 |
|
|
|
218e99 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
218e99 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 415b5b013ce74126e71459b922a92377918ae2ef)
|
|
|
218e99 |
---
|
|
|
218e99 |
block.c | 11 ++++++++++-
|
|
|
218e99 |
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block.c | 11 ++++++++++-
|
|
|
218e99 |
1 files changed, 10 insertions(+), 1 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block.c b/block.c
|
|
|
218e99 |
index 8c583bf..00bc3b2 100644
|
|
|
218e99 |
--- a/block.c
|
|
|
218e99 |
+++ b/block.c
|
|
|
218e99 |
@@ -3041,6 +3041,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
{
|
|
|
218e99 |
int64_t length;
|
|
|
218e99 |
int64_t n;
|
|
|
218e99 |
+ int64_t ret;
|
|
|
218e99 |
|
|
|
218e99 |
length = bdrv_getlength(bs);
|
|
|
218e99 |
if (length < 0) {
|
|
|
218e99 |
@@ -3062,7 +3063,15 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
|
|
218e99 |
return BDRV_BLOCK_DATA;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
- return bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
+ ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum);
|
|
|
218e99 |
+ if (ret < 0) {
|
|
|
218e99 |
+ return ret;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+
|
|
|
218e99 |
+ if (!(ret & BDRV_BLOCK_DATA) && bdrv_has_zero_init(bs)) {
|
|
|
218e99 |
+ ret |= BDRV_BLOCK_ZERO;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
/* Coroutine wrapper for bdrv_get_block_status() */
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|