qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 3/8] block: Add blk_get_opt_transfer()


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH v4 3/8] block: Add blk_get_opt_transfer()
Date: Tue, 21 Feb 2017 08:11:59 +0000

On Tue, Feb 21, 2017 at 6:45 AM Eric Blake <address@hidden> wrote:

> The NBD protocol would like to advertise the optimal I/O
> size to the client; but it would be a layering violation to
> peek into blk_bs(blk)->bl, when we only have a BB.
>
> This copies the existing blk_get_max_transfer() in reading
> a value from the top BDS; where that value was picked via
> bdrv_refresh_limits() to reflect the overall constraints of
> the entire BDS chain.
>
> Signed-off-by: Eric Blake <address@hidden>
>



Reviewed-by: Marc-André Lureau <address@hidden>



>
> ---
> v4: retitle, as part of rebasing to byte limits
> v3: new patch
> ---
>  include/sysemu/block-backend.h |  1 +
>  block/block-backend.c          | 12 ++++++++++++
>  2 files changed, 13 insertions(+)
>
> diff --git a/include/sysemu/block-backend.h
> b/include/sysemu/block-backend.h
> index 6444e41..882480a 100644
> --- a/include/sysemu/block-backend.h
> +++ b/include/sysemu/block-backend.h
> @@ -174,6 +174,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked);
>  void blk_eject(BlockBackend *blk, bool eject_flag);
>  int blk_get_flags(BlockBackend *blk);
>  uint32_t blk_get_max_transfer(BlockBackend *blk);
> +uint32_t blk_get_opt_transfer(BlockBackend *blk);
>  int blk_get_max_iov(BlockBackend *blk);
>  void blk_set_guest_block_size(BlockBackend *blk, int align);
>  void *blk_try_blockalign(BlockBackend *blk, size_t size);
> diff --git a/block/block-backend.c b/block/block-backend.c
> index efbf398..4d91ff8 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -1426,6 +1426,18 @@ uint32_t blk_get_max_transfer(BlockBackend *blk)
>      return MIN_NON_ZERO(max, INT_MAX);
>  }
>
> +/* Returns the optimum transfer length, in bytes; may be 0 if no optimum
> */
> +uint32_t blk_get_opt_transfer(BlockBackend *blk)
> +{
> +    BlockDriverState *bs = blk_bs(blk);
> +
> +    if (bs) {
> +        return bs->bl.opt_transfer;
> +    } else {
> +        return 0;
> +    }
> +}
> +
>  int blk_get_max_iov(BlockBackend *blk)
>  {
>      return blk->root->bs->bl.max_iov;
> --
> 2.9.3
>
>
> --
Marc-André Lureau


reply via email to

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