All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ari Sundholm <ari@tuxera.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>, Fam Zheng <famz@redhat.com>,
	qemu-block@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>Kevin Wolf <kwolf@redhat.com>Max
	Reitz <mreitz@redhat.com>,
	John Snow <jsnow@redhat.com>"open list:Block I/O path"
	<qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v4 03/10] block: Add a mechanism for passing a block driver a block configuration
Date: Mon, 11 Jun 2018 18:06:54 +0300	[thread overview]
Message-ID: <827eb538-c55d-dadd-3b2d-d418cbe90468@tuxera.com> (raw)
In-Reply-To: <1528461148-17925-4-git-send-email-ari@tuxera.com>

Ping regarding this patch and the ones following it in the series. I 
would very much appreciate any feedback on the new callback and related 
plumbing I'm proposing for passing things like the guest block device 
sector size to block drivers (such as the filter type one proposed 
earlier in this series). Alternative ideas are also welcome.

Thank you,
Ari Sundholm
ari@tuxera.com

On 06/08/2018 03:32 PM, Ari Sundholm wrote:
> A block driver may need to know about the block configuration, most
> critically the sector sizes, of a block backend for alignment purposes
> or for some other reason. It doesn't seem like qemu has an existing
> mechanism for a block backend to convey the required information to
> the relevant block driver when it is being realized.
> 
> The need for this mechanism rises from the fact that a drive may not
> have a backend at the time it is created, as devices are created after
> drives during qemu startup. Therefore, a driver requiring information
> about the block configuration can get this information when a backend
> is created for it at the earliest. The most natural place for this to
> take place seems to be in the realization functions of the various
> block device drivers, such as scsi-hd. The interface proposed here
> allows the block driver to receive information about the block
> configuration and the associated backend through a new callback.
> 
> Signed-off-by: Ari Sundholm <ari@tuxera.com>
> ---
>   block/io.c                | 22 ++++++++++++++++++++++
>   hw/block/block.c          | 12 +++++++++++-
>   include/block/block.h     | 10 ++++++++++
>   include/block/block_int.h |  9 +++++++++
>   include/hw/block/block.h  |  1 +
>   5 files changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/block/io.c b/block/io.c
> index b7beaee..3a06843 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -2932,3 +2932,25 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset,
>       bdrv_dec_in_flight(dst_bs);
>       return ret;
>   }
> +
> +void bdrv_apply_blkconf(BlockDriverState *bs, BlockConf *conf)
> +{
> +    BlockDriver *drv = bs->drv;
> +
> +    if (!drv) {
> +        return;
> +    }
> +
> +    if (drv->bdrv_apply_blkconf) {
> +        drv->bdrv_apply_blkconf(bs, conf);
> +        return;
> +    }
> +
> +    if (bs->file && bs->file->bs) {
> +        bdrv_apply_blkconf(bs->file->bs, conf);
> +    }
> +
> +    if (bs->drv->supports_backing && backing_bs(bs)) {
> +        bdrv_apply_blkconf(backing_bs(bs), conf);
> +    }
> +}
> diff --git a/hw/block/block.c b/hw/block/block.c
> index b91e2b6..8c87dbf 100644
> --- a/hw/block/block.c
> +++ b/hw/block/block.c
> @@ -38,7 +38,7 @@ void blkconf_blocksizes(BlockConf *conf)
>       /* fill in detected values if they are not defined via qemu command line */
>       if (!conf->physical_block_size) {
>           if (!backend_ret) {
> -           conf->physical_block_size = blocksizes.phys;
> +            conf->physical_block_size = blocksizes.phys;
>           } else {
>               conf->physical_block_size = BDRV_SECTOR_SIZE;
>           }
> @@ -52,6 +52,16 @@ void blkconf_blocksizes(BlockConf *conf)
>       }
>   }
>   
> +void blkconf_apply_to_blkdrv(BlockConf *conf)
> +{
> +    BlockBackend *blk = conf->blk;
> +    BlockDriverState *bs = blk_bs(blk);
> +
> +    if (bs) {
> +        bdrv_apply_blkconf(bs, conf);
> +    }
> +}
> +
>   bool blkconf_apply_backend_options(BlockConf *conf, bool readonly,
>                                      bool resizable, Error **errp)
>   {
> diff --git a/include/block/block.h b/include/block/block.h
> index 312ae01..5d0a8ba 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -10,6 +10,7 @@
>   #include "block/dirty-bitmap.h"
>   #include "block/blockjob.h"
>   #include "qemu/hbitmap.h"
> +#include "hw/block/block.h"
>   
>   /* block.c */
>   typedef struct BlockDriver BlockDriver;
> @@ -650,4 +651,13 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host);
>   int coroutine_fn bdrv_co_copy_range(BdrvChild *src, uint64_t src_offset,
>                                       BdrvChild *dst, uint64_t dst_offset,
>                                       uint64_t bytes, BdrvRequestFlags flags);
> +
> +/*
> + * bdrv_apply_blkconf:
> + *
> + * Recursively finds the highest-level block drivers among the files and
> + * backing files that accept a block configuration and applies the given block
> + * configuration to them.
> + */
> +void bdrv_apply_blkconf(BlockDriverState *bs, BlockConf *conf);
>   #endif
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 888b7f7..cb82745 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -464,6 +464,15 @@ struct BlockDriver {
>       void (*bdrv_abort_perm_update)(BlockDriverState *bs);
>   
>       /**
> +     * Called to inform the driver of the block configuration of the virtual
> +     * block device.
> +     *
> +     * This function is called by a block device realization function if the
> +     * device wants to inform the block driver of its block configuration.
> +     */
> +    void (*bdrv_apply_blkconf)(BlockDriverState *bs, BlockConf *conf);
> +
> +    /**
>        * Returns in @nperm and @nshared the permissions that the driver for @bs
>        * needs on its child @c, based on the cumulative permissions requested by
>        * the parents in @parent_perm and @parent_shared.
> diff --git a/include/hw/block/block.h b/include/hw/block/block.h
> index d4f4dff..2861995 100644
> --- a/include/hw/block/block.h
> +++ b/include/hw/block/block.h
> @@ -77,6 +77,7 @@ bool blkconf_geometry(BlockConf *conf, int *trans,
>                         unsigned cyls_max, unsigned heads_max, unsigned secs_max,
>                         Error **errp);
>   void blkconf_blocksizes(BlockConf *conf);
> +void blkconf_apply_to_blkdrv(BlockConf *conf);
>   bool blkconf_apply_backend_options(BlockConf *conf, bool readonly,
>                                      bool resizable, Error **errp);
>   
> 

  reply	other threads:[~2018-06-11 15:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 12:32 [Qemu-devel] [PATCH v4 00/10] New block driver: blklogwrites Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 01/10] block: Move two block permission constants to the relevant enum Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 02/10] block: Add blklogwrites Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 03/10] block: Add a mechanism for passing a block driver a block configuration Ari Sundholm
2018-06-11 15:06   ` Ari Sundholm [this message]
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 04/10] hw/scsi/scsi-disk: Always apply block configuration to block driver Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 05/10] hw/ide/qdev: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 06/10] hw/block/virtio-blk: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 07/10] hw/block/nvme: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 08/10] hw/block/fdc: " Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 09/10] block/blklogwrites: Use block limits from the backend block configuration Ari Sundholm
2018-06-08 12:32 ` [Qemu-devel] [PATCH v4 10/10] block/blklogwrites: Use the block device logical sector size when logging writes Ari Sundholm
2018-06-18 15:36   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-06-18 15:53     ` Ari Sundholm
2018-06-19 11:22       ` Alberto Garcia
2018-06-14 22:23 ` [Qemu-devel] [PATCH v4 00/10] New block driver: blklogwrites Ari Sundholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=827eb538-c55d-dadd-3b2d-d418cbe90468@tuxera.com \
    --to=ari@tuxera.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.