[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/5] qcow2: Report BDRV_BLOCK_ZERO more accurately in bdrv_co_bloc
From: |
Kevin Wolf |
Subject: |
[PULL 3/5] qcow2: Report BDRV_BLOCK_ZERO more accurately in bdrv_co_block_status() |
Date: |
Tue, 27 Oct 2020 16:15:13 +0100 |
From: Alberto Garcia <berto@igalia.com>
If a BlockDriverState supports backing files but has none then any
unallocated area reads back as zeroes.
bdrv_co_block_status() is only reporting this is if want_zero is true,
but this is an inexpensive test and there is no reason not to do it in
all cases.
Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id:
<66fa0914a0e2b727ab6d1b63ca773d7cd29a9a9e.1603731354.git.berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/io.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/io.c b/block/io.c
index 02528b3823..6fe1b275b6 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2282,17 +2282,17 @@ static int coroutine_fn
bdrv_co_block_status(BlockDriverState *bs,
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ALLOCATED;
- } else if (want_zero && bs->drv->supports_backing) {
+ } else if (bs->drv->supports_backing) {
BlockDriverState *cow_bs = bdrv_cow_bs(bs);
- if (cow_bs) {
+ if (!cow_bs) {
+ ret |= BDRV_BLOCK_ZERO;
+ } else if (want_zero) {
int64_t size2 = bdrv_getlength(cow_bs);
if (size2 >= 0 && offset >= size2) {
ret |= BDRV_BLOCK_ZERO;
}
- } else {
- ret |= BDRV_BLOCK_ZERO;
}
}
--
2.28.0
- [PULL 0/5] Block layer patches, Kevin Wolf, 2020/10/27
- [PULL 1/5] qemu-img: add support for rate limit in qemu-img commit, Kevin Wolf, 2020/10/27
- [PULL 2/5] qemu-img: add support for rate limit in qemu-img convert, Kevin Wolf, 2020/10/27
- [PULL 3/5] qcow2: Report BDRV_BLOCK_ZERO more accurately in bdrv_co_block_status(),
Kevin Wolf <=
- [PULL 5/5] block: End quiescent sections when a BDS is deleted, Kevin Wolf, 2020/10/27
- [PULL 4/5] qcow2: Skip copy-on-write when allocating a zero cluster, Kevin Wolf, 2020/10/27
- Re: [PULL 0/5] Block layer patches, Peter Maydell, 2020/10/30