qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 22/42] block: Use CAFs in bdrv_get_allocated_


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v5 22/42] block: Use CAFs in bdrv_get_allocated_file_size()
Date: Thu, 13 Jun 2019 00:17:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 13.06.19 00:09, Max Reitz wrote:
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  block.c | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 11b7ba8cf6..856d9b58be 100644
> --- a/block.c
> +++ b/block.c
> @@ -4511,15 +4511,37 @@ exit:
>  int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
>  {
>      BlockDriver *drv = bs->drv;
> +    BlockDriverState *storage_bs, *metadata_bs;
> +
>      if (!drv) {
>          return -ENOMEDIUM;
>      }
> +
>      if (drv->bdrv_get_allocated_file_size) {
>          return drv->bdrv_get_allocated_file_size(bs);
>      }
> -    if (bs->file) {
> -        return bdrv_get_allocated_file_size(bs->file->bs);
> +
> +    storage_bs = bdrv_storage_bs(bs);
> +    metadata_bs = bdrv_metadata_bs(bs);
> +
> +    if (storage_bs) {
> +        int64_t data_size, metadata_size = 0;
> +
> +        data_size = bdrv_get_allocated_file_size(storage_bs);
> +        if (data_size < 0) {
> +            return data_size;
> +        }
> +
> +        if (storage_bs != metadata_bs) {

Let this be a lesson to you: If you run all tests, then prepare to send
the series and just change “a minor thing”, you really should rerun the
tests.  Well, I should have, at least.

That should read “if (metadata_bs && storage_bs != metadata_bs) {”.

(Damn.  Why did I only remember to do so literally five minutes after
sending the series?)

Max

> +            metadata_size = bdrv_get_allocated_file_size(metadata_bs);
> +            if (metadata_size < 0) {
> +                return metadata_size;
> +            }
> +        }
> +
> +        return data_size + metadata_size;
>      }
> +
>      return -ENOTSUP;
>  }
>  
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]