qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Cc: "Fam Zheng" <fam@euphon.net>, "Kevin Wolf" <kwolf@redhat.com>,
	"Damien Le Moal" <damien.lemoal@wdc.com>,
	qemu-block@nongnu.org, "Niklas Cassel" <niklas.cassel@wdc.com>,
	"Klaus Jensen" <k.jensen@samsung.com>,
	qemu-devel@nongnu.org, "Maxim Levitsky" <mlevitsk@redhat.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Matias Bjorling" <matias.bjorling@wdc.com>
Subject: Re: [PATCH v6 02/11] hw/block/nvme: Generate namespace UUIDs
Date: Wed, 14 Oct 2020 13:40:42 +0200	[thread overview]
Message-ID: <20201014114042.GA357831@apples.localdomain> (raw)
In-Reply-To: <20201013214212.2152-3-dmitry.fomichev@wdc.com>

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

On Oct 14 06:42, Dmitry Fomichev wrote:
> In NVMe 1.4, a namespace must report an ID descriptor of UUID type
> if it doesn't support EUI64 or NGUID. Add a new namespace property,
> "uuid", that provides the user the option to either specify the UUID
> explicitly or have a UUID generated automatically every time a
> namespace is initialized.
> 
> Suggested-by: Klaus Jansen <its@irrelevant.dk>
> Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>

> ---
>  hw/block/nvme-ns.c | 1 +
>  hw/block/nvme-ns.h | 1 +
>  hw/block/nvme.c    | 9 +++++----
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c
> index b69cdaf27e..de735eb9f3 100644
> --- a/hw/block/nvme-ns.c
> +++ b/hw/block/nvme-ns.c
> @@ -129,6 +129,7 @@ static void nvme_ns_realize(DeviceState *dev, Error **errp)
>  static Property nvme_ns_props[] = {
>      DEFINE_BLOCK_PROPERTIES(NvmeNamespace, blkconf),
>      DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0),
> +    DEFINE_PROP_UUID("uuid", NvmeNamespace, params.uuid),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h
> index ea8c2f785d..a38071884a 100644
> --- a/hw/block/nvme-ns.h
> +++ b/hw/block/nvme-ns.h
> @@ -21,6 +21,7 @@
>  
>  typedef struct NvmeNamespaceParams {
>      uint32_t nsid;
> +    QemuUUID uuid;
>  } NvmeNamespaceParams;
>  
>  typedef struct NvmeNamespace {
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index ee0eff98da..89d91926d9 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1571,6 +1571,7 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req)
>  
>  static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req)
>  {
> +    NvmeNamespace *ns;
>      NvmeIdentify *c = (NvmeIdentify *)&req->cmd;
>      uint32_t nsid = le32_to_cpu(c->nsid);
>      uint8_t list[NVME_IDENTIFY_DATA_SIZE];
> @@ -1590,7 +1591,8 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req)
>          return NVME_INVALID_NSID | NVME_DNR;
>      }
>  
> -    if (unlikely(!nvme_ns(n, nsid))) {
> +    ns = nvme_ns(n, nsid);
> +    if (unlikely(!ns)) {
>          return NVME_INVALID_FIELD | NVME_DNR;
>      }
>  
> @@ -1599,12 +1601,11 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req)
>      /*
>       * Because the NGUID and EUI64 fields are 0 in the Identify Namespace data
>       * structure, a Namespace UUID (nidt = 0x3) must be reported in the
> -     * Namespace Identification Descriptor. Add a very basic Namespace UUID
> -     * here.
> +     * Namespace Identification Descriptor. Add the namespace UUID here.
>       */
>      ns_descrs->uuid.hdr.nidt = NVME_NIDT_UUID;
>      ns_descrs->uuid.hdr.nidl = NVME_NIDT_UUID_LEN;
> -    stl_be_p(&ns_descrs->uuid.v, nsid);
> +    memcpy(&ns_descrs->uuid.v, ns->params.uuid.data, NVME_NIDT_UUID_LEN);
>  
>      return nvme_dma(n, list, NVME_IDENTIFY_DATA_SIZE,
>                      DMA_DIRECTION_FROM_DEVICE, req);
> -- 
> 2.21.0
> 
> 

-- 
One of us - No more doubt, silence or taboo about mental illness.

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

  reply	other threads:[~2020-10-14 11:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 21:42 [PATCH v6 00/11] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 01/11] hw/block/nvme: Add Commands Supported and Effects log Dmitry Fomichev
2020-10-14  0:50   ` Keith Busch
2020-10-14 12:13     ` Niklas Cassel
2020-10-19  2:01     ` Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 02/11] hw/block/nvme: Generate namespace UUIDs Dmitry Fomichev
2020-10-14 11:40   ` Klaus Jensen [this message]
2020-10-13 21:42 ` [PATCH v6 03/11] hw/block/nvme: Add support for Namespace Types Dmitry Fomichev
2020-10-14 13:01   ` Niklas Cassel
2020-10-19  2:03     ` Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 04/11] hw/block/nvme: Support allocated CNS command variants Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 05/11] hw/block/nvme: Support Zoned Namespace Command Set Dmitry Fomichev
2020-10-14 11:59   ` Niklas Cassel
2020-10-19  2:02     ` Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 06/11] hw/block/nvme: Introduce max active and open zone limits Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 07/11] hw/block/nvme: Support Zone Descriptor Extensions Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 08/11] hw/block/nvme: Add injection of Offline/Read-Only zones Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 09/11] hw/block/nvme: Document zoned parameters in usage text Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 10/11] hw/block/nvme: Separate read and write handlers Dmitry Fomichev
2020-10-13 21:42 ` [PATCH v6 11/11] hw/block/nvme: Merge nvme_write_zeroes() with nvme_write() Dmitry Fomichev

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=20201014114042.GA357831@apples.localdomain \
    --to=its@irrelevant.dk \
    --cc=alistair.francis@wdc.com \
    --cc=damien.lemoal@wdc.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=fam@euphon.net \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=matias.bjorling@wdc.com \
    --cc=mlevitsk@redhat.com \
    --cc=niklas.cassel@wdc.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).