mirror of https://github.com/xemu-project/xemu.git
block: inline bdrv_unallocated_blocks_are_zero()
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>
This commit is contained in:
parent
2253d86eb4
commit
7b1efe996c
15
block.c
15
block.c
|
@ -5408,21 +5408,6 @@ int bdrv_has_zero_init(BlockDriverState *bs)
|
||||||
return 0;
|
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)
|
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
if (!(bs->open_flags & BDRV_O_UNMAP)) {
|
if (!(bs->open_flags & BDRV_O_UNMAP)) {
|
||||||
|
|
11
block/io.c
11
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)) {
|
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
|
||||||
ret |= BDRV_BLOCK_ALLOCATED;
|
ret |= BDRV_BLOCK_ALLOCATED;
|
||||||
} else if (want_zero) {
|
} else if (want_zero) {
|
||||||
if (bdrv_unallocated_blocks_are_zero(bs)) {
|
if (bs->backing) {
|
||||||
ret |= BDRV_BLOCK_ZERO;
|
|
||||||
} else if (bs->backing) {
|
|
||||||
BlockDriverState *bs2 = bs->backing->bs;
|
BlockDriverState *bs2 = bs->backing->bs;
|
||||||
int64_t size2 = bdrv_getlength(bs2);
|
int64_t size2 = bdrv_getlength(bs2);
|
||||||
|
|
||||||
if (size2 >= 0 && offset >= size2) {
|
if (size2 >= 0 && offset >= size2) {
|
||||||
ret |= BDRV_BLOCK_ZERO;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes);
|
||||||
int bdrv_has_zero_init_1(BlockDriverState *bs);
|
int bdrv_has_zero_init_1(BlockDriverState *bs);
|
||||||
int bdrv_has_zero_init(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);
|
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
|
||||||
int bdrv_block_status(BlockDriverState *bs, int64_t offset,
|
int bdrv_block_status(BlockDriverState *bs, int64_t offset,
|
||||||
int64_t bytes, int64_t *pnum, int64_t *map,
|
int64_t bytes, int64_t *pnum, int64_t *map,
|
||||||
|
|
Loading…
Reference in New Issue