qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] [PATCH v5 09/23] block: Switch BdrvCoGetBl


From: Jeff Cody
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v5 09/23] block: Switch BdrvCoGetBlockStatusData to byte-based
Date: Mon, 9 Oct 2017 16:07:36 -0400
User-agent: Mutt/1.5.24 (2015-08-30)

On Tue, Oct 03, 2017 at 09:00:34PM -0500, Eric Blake wrote:
> We are gradually converting to byte-based interfaces, as they are
> easier to reason about than sector-based.  Convert another internal
> type (no semantic change), and rename it to match the corresponding
> public function rename.
> 
> Signed-off-by: Eric Blake <address@hidden>
> Reviewed-by: Fam Zheng <address@hidden>
> Reviewed-by: John Snow <address@hidden>
> 
> ---
> v4-v5: no change
> v3: rebase to context conflicts, simple enough to keep R-b
> v2: rebase to earlier changes
> ---
>  block/io.c | 31 ++++++++++++++++++-------------
>  1 file changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/block/io.c b/block/io.c
> index b879e26154..1857191187 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -1744,17 +1744,17 @@ int bdrv_flush_all(void)
>  }
> 
> 
> -typedef struct BdrvCoGetBlockStatusData {
> +typedef struct BdrvCoBlockStatusData {
>      BlockDriverState *bs;
>      BlockDriverState *base;
>      BlockDriverState **file;
> -    int64_t sector_num;
> -    int nb_sectors;
> -    int *pnum;
> +    int64_t offset;
> +    int64_t bytes;
> +    int64_t *pnum;
>      int64_t ret;
>      bool mapping;
>      bool done;
> -} BdrvCoGetBlockStatusData;
> +} BdrvCoBlockStatusData;
> 
>  int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs,
>                                                          int64_t sector_num,
> @@ -1983,14 +1983,16 @@ static int64_t coroutine_fn 
> bdrv_co_get_block_status_above(BlockDriverState *bs,
>  /* Coroutine wrapper for bdrv_get_block_status_above() */
>  static void coroutine_fn bdrv_get_block_status_above_co_entry(void *opaque)
>  {
> -    BdrvCoGetBlockStatusData *data = opaque;
> +    BdrvCoBlockStatusData *data = opaque;
> +    int n;
> 
>      data->ret = bdrv_co_get_block_status_above(data->bs, data->base,
>                                                 data->mapping,
> -                                               data->sector_num,
> -                                               data->nb_sectors,
> -                                               data->pnum,
> +                                               data->offset >> 
> BDRV_SECTOR_BITS,
> +                                               data->bytes >> 
> BDRV_SECTOR_BITS,
> +                                               &n,
>                                                 data->file);
> +    *data->pnum = n * BDRV_SECTOR_SIZE;

This throws a warning:

 block/io.c: In function ‘bdrv_get_block_status_above_co_entry’:
 block/io.c:1995:21: error: ‘n’ may be used uninitialized in this function 
       [-Werror=maybe-uninitialized] *data->pnum = n * BDRV_SECTOR_SIZE;


It is fixed a couple patches from now, but it will still break git-bisect.


>      data->done = true;
>  }
> 
> @@ -2007,13 +2009,14 @@ static int64_t 
> bdrv_common_block_status_above(BlockDriverState *bs,
>                                                BlockDriverState **file)
>  {
>      Coroutine *co;
> -    BdrvCoGetBlockStatusData data = {
> +    int64_t n;
> +    BdrvCoBlockStatusData data = {
>          .bs = bs,
>          .base = base,
>          .file = file,
> -        .sector_num = sector_num,
> -        .nb_sectors = nb_sectors,
> -        .pnum = pnum,
> +        .offset = sector_num * BDRV_SECTOR_SIZE,
> +        .bytes = nb_sectors * BDRV_SECTOR_SIZE,
> +        .pnum = &n,
>          .mapping = mapping,
>          .done = false,
>      };
> @@ -2027,6 +2030,8 @@ static int64_t 
> bdrv_common_block_status_above(BlockDriverState *bs,
>          bdrv_coroutine_enter(bs, co);
>          BDRV_POLL_WHILE(bs, !data.done);
>      }
> +    assert(data.ret < 0 || QEMU_IS_ALIGNED(n, BDRV_SECTOR_SIZE));
> +    *pnum = n >> BDRV_SECTOR_BITS;
>      return data.ret;
>  }
> 
> -- 
> 2.13.6
> 
> 



reply via email to

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