|
|
9ae3a8 |
From 91a73a0f154a7d8f2c4949ea882f684d55c916e4 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 18 Oct 2013 08:14:47 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 22/81] block: look for zero blocks in bs->file
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1382084091-16636-23-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55005
|
|
|
9ae3a8 |
O-Subject: [RHEL 7.0 qemu-kvm PATCH 22/26] block: look for zero blocks in bs->file
|
|
|
9ae3a8 |
Bugzilla: 989646
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 5daa74a6ebce7543aaad178c4061dc087bb4c705)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 16 +++++++++++++++-
|
|
|
9ae3a8 |
1 file changed, 15 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 16 +++++++++++++++-
|
|
|
9ae3a8 |
1 files changed, 15 insertions(+), 1 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index 2a4a9dd..f993b2e 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -3041,7 +3041,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int64_t length;
|
|
|
9ae3a8 |
int64_t n;
|
|
|
9ae3a8 |
- int64_t ret;
|
|
|
9ae3a8 |
+ int64_t ret, ret2;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
length = bdrv_getlength(bs);
|
|
|
9ae3a8 |
if (length < 0) {
|
|
|
9ae3a8 |
@@ -3083,6 +3083,20 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (bs->file &&
|
|
|
9ae3a8 |
+ (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) &&
|
|
|
9ae3a8 |
+ (ret & BDRV_BLOCK_OFFSET_VALID)) {
|
|
|
9ae3a8 |
+ ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS,
|
|
|
9ae3a8 |
+ *pnum, pnum);
|
|
|
9ae3a8 |
+ if (ret2 >= 0) {
|
|
|
9ae3a8 |
+ /* Ignore errors. This is just providing extra information, it
|
|
|
9ae3a8 |
+ * is useful but not necessary.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+ ret |= (ret2 & BDRV_BLOCK_ZERO);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|