[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/31] block: inline bdrv_unallocated_blocks_are_zero()
From: |
Max Reitz |
Subject: |
[PULL 23/31] block: inline bdrv_unallocated_blocks_are_zero() |
Date: |
Mon, 6 Jul 2020 12:04:24 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
The function has only one user: bdrv_co_block_status(). Inline it to
simplify reviewing of the following patches, which will finally drop
unallocated_blocks_are_zero field too.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200528094405.145708-3-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
include/block/block.h | 1 -
block.c | 15 ---------------
block/io.c | 11 ++++++++---
3 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index a2414a58c5..e7934e07f2 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -489,7 +489,6 @@ int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t
bytes);
int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes);
int bdrv_has_zero_init_1(BlockDriverState *bs);
int bdrv_has_zero_init(BlockDriverState *bs);
-bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs);
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
int bdrv_block_status(BlockDriverState *bs, int64_t offset,
int64_t bytes, int64_t *pnum, int64_t *map,
diff --git a/block.c b/block.c
index 144f52e413..62e40db2f1 100644
--- a/block.c
+++ b/block.c
@@ -5408,21 +5408,6 @@ int bdrv_has_zero_init(BlockDriverState *bs)
return 0;
}
-bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs)
-{
- BlockDriverInfo bdi;
-
- if (bs->backing) {
- return false;
- }
-
- if (bdrv_get_info(bs, &bdi) == 0) {
- return bdi.unallocated_blocks_are_zero;
- }
-
- return false;
-}
-
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
{
if (!(bs->open_flags & BDRV_O_UNMAP)) {
diff --git a/block/io.c b/block/io.c
index df8f2a98d4..36d4d562a6 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2407,15 +2407,20 @@ 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) {
- if (bdrv_unallocated_blocks_are_zero(bs)) {
- ret |= BDRV_BLOCK_ZERO;
- } else if (bs->backing) {
+ if (bs->backing) {
BlockDriverState *bs2 = bs->backing->bs;
int64_t size2 = bdrv_getlength(bs2);
if (size2 >= 0 && offset >= size2) {
ret |= BDRV_BLOCK_ZERO;
}
+ } else {
+ BlockDriverInfo bdi;
+ int ret2 = bdrv_get_info(bs, &bdi);
+
+ if (ret2 == 0 && bdi.unallocated_blocks_are_zero) {
+ ret |= BDRV_BLOCK_ZERO;
+ }
}
}
--
2.26.2
- [PULL 15/31] block/crypto: implement the encryption key management, (continued)
- [PULL 15/31] block/crypto: implement the encryption key management, Max Reitz, 2020/07/06
- [PULL 16/31] block/qcow2: extend qemu-img amend interface with crypto options, Max Reitz, 2020/07/06
- [PULL 18/31] block/core: add generic infrastructure for x-blockdev-amend qmp command, Max Reitz, 2020/07/06
- [PULL 20/31] block/qcow2: implement blockdev-amend, Max Reitz, 2020/07/06
- [PULL 17/31] iotests: qemu-img tests for luks key management, Max Reitz, 2020/07/06
- [PULL 19/31] block/crypto: implement blockdev-amend, Max Reitz, 2020/07/06
- [PULL 22/31] qemu-img: convert: don't use unallocated_blocks_are_zero, Max Reitz, 2020/07/06
- [PULL 21/31] iotests: add tests for blockdev-amend, Max Reitz, 2020/07/06
- [PULL 23/31] block: inline bdrv_unallocated_blocks_are_zero(),
Max Reitz <=
- [PULL 24/31] block/vdi: return ZERO block-status when appropriate, Max Reitz, 2020/07/06
- [PULL 26/31] block/crypto: drop unallocated_blocks_are_zero, Max Reitz, 2020/07/06
- [PULL 27/31] block/iscsi: drop unallocated_blocks_are_zero, Max Reitz, 2020/07/06
- [PULL 28/31] block/file-posix: drop unallocated_blocks_are_zero, Max Reitz, 2020/07/06
- [PULL 29/31] block/vhdx: drop unallocated_blocks_are_zero, Max Reitz, 2020/07/06
- [PULL 30/31] block: drop unallocated_blocks_are_zero, Max Reitz, 2020/07/06
- [PULL 31/31] qed: Simplify backing reads, Max Reitz, 2020/07/06
- [PULL 25/31] block/vpc: return ZERO block-status when appropriate, Max Reitz, 2020/07/06
- Re: [PULL 00/31] Block patches, no-reply, 2020/07/06
- Re: [PULL 00/31] Block patches, Peter Maydell, 2020/07/07