[PATCH 5/8] block/file-posix: drop unallocated_blocks_are_zero

Vladimir Sementsov-Ogievskiy posted 8 patches 5 years, 6 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Jeff Cody <codyprime@gmail.com>, Fam Zheng <fam@euphon.net>, Stefan Hajnoczi <stefanha@redhat.com>, Ronnie Sahlberg <ronniesahlberg@gmail.com>, Max Reitz <mreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>, Peter Lieven <pl@kamp.de>
There is a newer version of this series
[PATCH 5/8] block/file-posix: drop unallocated_blocks_are_zero
Posted by Vladimir Sementsov-Ogievskiy 5 years, 6 months ago
raw_co_block_status() in block/file-posix.c never returns 0, so
unallocated_blocks_are_zero is useless. Drop it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/file-posix.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 05e094be29..5c01735108 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2878,9 +2878,6 @@ static int coroutine_fn raw_co_pwrite_zeroes(
 
 static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
 {
-    BDRVRawState *s = bs->opaque;
-
-    bdi->unallocated_blocks_are_zero = s->discard_zeroes;
     return 0;
 }
 
-- 
2.21.0


Re: [PATCH 5/8] block/file-posix: drop unallocated_blocks_are_zero
Posted by Eric Blake 5 years, 6 months ago
On 5/6/20 4:25 AM, Vladimir Sementsov-Ogievskiy wrote:
> raw_co_block_status() in block/file-posix.c never returns 0, so
> unallocated_blocks_are_zero is useless. Drop it.

As in 4/8, you are correct that it had no impact on block_status, but it 
did affect qemu-img convert.  So again, removing the clients first makes 
this easier to justify as a cleanup patch.

That said...

> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   block/file-posix.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 05e094be29..5c01735108 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -2878,9 +2878,6 @@ static int coroutine_fn raw_co_pwrite_zeroes(
>   
>   static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
>   {
> -    BDRVRawState *s = bs->opaque;
> -
> -    bdi->unallocated_blocks_are_zero = s->discard_zeroes;
>       return 0;
>   }

the function now does nothing.  Hmm - why does bdrv_get_info() return 
-ENOTSUP if the driver does not implement this function?  Wouldn't it be 
better if the block layer could allow us to omit .bdrv_get_info and do 
the same thing, without us having to write a dummy function that does 
nothing but return 0?  As separate patches, of course, as it would 
require changing several existing bdrv_get_info() callers to behave 
sanely when getting an all-0 success return where they now deal with an 
-ENOTSUP return.

So in the meantime, yes, we need this placeholder.
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org