QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, "Michael S . Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v5 1/4] block: Add zoned device model property
Date: Wed, 28 Aug 2019 10:21:06 +0100
Message-ID: <20190828092106.GC5573@stefanha-x1.localdomain> (raw)
In-Reply-To: <20190823194927.23278-2-dmitry.fomichev@wdc.com>

[-- Attachment #1: Type: text/plain, Size: 4535 bytes --]

On Fri, Aug 23, 2019 at 03:49:24PM -0400, Dmitry Fomichev wrote:
> +uint8_t bdrv_is_zoned(BlockDriverState *bs)
> +{
> +    /*
> +     * Host Aware zone devices are supposed to be able to work
> +     * just like regular block devices. Thus, we only consider
> +     * Host Managed devices to be zoned here.
> +     */
> +    return bdrv_get_zoned_model(bs) == BLK_ZONED_MODEL_HM;

This function doesn't say whether bs is a zoned device in general, it
says whether it's Host Managed.  Please rename to
bdrv_is_host_managed_zoned(), bdrv_is_zoned_hm(), or similar.

> +}
> +
>  bool bdrv_is_sg(BlockDriverState *bs)
>  {
>      return bs->sg;
> diff --git a/include/block/block.h b/include/block/block.h
> index 124ad40809..238c0f5ed7 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -271,18 +271,35 @@ enum {
>       */
>      BLK_PERM_GRAPH_MOD          = 0x10,
>  
> +    /** This permission is required to open zoned block devices. */
> +    BLK_PERM_SUPPORT_ZONED      = 0x20,

Maybe BLK_PERM_SUPPORT_ZONED_HM is clearer?  Let's keep the distinction
between general zoned devices and host-managed zoned devices clear,
otherwise the code will get confusing if we ever want to treat
host-aware specially.

> +
>      BLK_PERM_ALL                = 0x1f,
>  
>      DEFAULT_PERM_PASSTHROUGH    = BLK_PERM_CONSISTENT_READ
>                                   | BLK_PERM_WRITE
>                                   | BLK_PERM_WRITE_UNCHANGED
> -                                 | BLK_PERM_RESIZE,
> +                                 | BLK_PERM_RESIZE
> +                                 | BLK_PERM_SUPPORT_ZONED,
>  
>      DEFAULT_PERM_UNCHANGED      = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH,
>  };
>  
>  char *bdrv_perm_names(uint64_t perm);
>  
> +/*
> + * Known zoned device models.
> + *
> + * TODO For a Linux host, it could be preferrable to include
> + * /usr/include/linux/blkzoned.h instead of defining ZBD-specific
> + * values here.

It depends.  If it's necessary to convert back to the Linux enum often
then I agree.  Otherwise the code is cleaner a QEMU enum is defined here
and we can avoid #ifdef __linux__.

> + */
> +enum blk_zoned_model {
> +    BLK_ZONED_MODEL_NONE, /* Regular block device */
> +    BLK_ZONED_MODEL_HA,   /* Host-aware zoned block device */
> +    BLK_ZONED_MODEL_HM,   /* Host-managed zoned block device */
> +};

Please use the same typedef enum approach as the rest of block.h:

  typedef enum {
      BDRV_ZONED_MODEL_NONE, /* Regular block device */
      BDRV_ZONED_MODEL_HA,   /* Host-aware zoned block device */
      BDRV_ZONED_MODEL_HM,   /* Host-managed zoned block device */
  } BdrvZonedModel;

> +
>  /* disk I/O throttling */
>  void bdrv_init(void);
>  void bdrv_init_with_whitelist(void);
> @@ -359,6 +376,8 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
>  BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
>                                 BlockDriverState *in_bs, Error **errp);
>  void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
> +uint8_t bdrv_get_zoned_model(BlockDriverState *bs);

Please use the enum:

  BdrvZonedModel bdrv_get_zoned_model(BlockDriverState *bs)

> +uint8_t bdrv_is_zoned(BlockDriverState *bs);

Please use bool instead of uint8_t.

>  void bdrv_refresh_limits(BlockDriverState *bs, Error **errp);
>  int bdrv_commit(BlockDriverState *bs);
>  int bdrv_change_backing_file(BlockDriverState *bs,
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index ceec8c2f56..91496e8149 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -415,6 +415,7 @@ struct BlockDriver {
>      bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag);
>  
>      void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp);
> +    void (*bdrv_get_zoned_info)(BlockDriverState *bs);

"get" is strange since this function returns void.  What is it supposed
to do, refresh just the BlockLimits::zoned_model field?  Should this be
called bdrv_refresh_zoned_model() instead?

>  
>      /*
>       * Returns 1 if newly created images are guaranteed to contain only
> @@ -620,6 +621,9 @@ typedef struct BlockLimits {
>  
>      /* maximum number of iovec elements */
>      int max_iov;
> +
> +    /* Zoned device model. Zero value indicates a regular block device */
> +    uint8_t zoned_model;

Please use the enum.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 19:49 [Qemu-devel] [PATCH v5 0/4] virtio/block: handle zoned backing devices Dmitry Fomichev
2019-08-23 19:49 ` [Qemu-devel] [PATCH v5 1/4] block: Add zoned device model property Dmitry Fomichev
2019-08-28  9:21   ` Stefan Hajnoczi [this message]
2019-08-23 19:49 ` [Qemu-devel] [PATCH v5 2/4] raw: Recognize zoned backing devices Dmitry Fomichev
2019-08-28  9:32   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2019-08-23 19:49 ` [Qemu-devel] [PATCH v5 3/4] block/ide/scsi: Set BLK_PERM_SUPPORT_ZONED Dmitry Fomichev
2019-08-28  9:34   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2019-08-23 19:49 ` [Qemu-devel] [PATCH v5 4/4] raw: Don't open ZBDs if backend can't handle them Dmitry Fomichev
2019-08-28  9:38   ` Stefan Hajnoczi
2019-08-23 20:08 ` [Qemu-devel] [PATCH v5 0/4] virtio/block: handle zoned backing devices no-reply
2019-08-28  9:41 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2019-09-04 21:11   ` Dmitry Fomichev

Reply instructions:

You may reply publically 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=20190828092106.GC5573@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@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

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org qemu-devel@archiver.kernel.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox