Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH v1 3/7] nvmet: implement namespace identify descriptor list
Date: Thu, 1 Jun 2017 08:42:33 +0200	[thread overview]
Message-ID: <20170601064233.GC16778@lst.de> (raw)
In-Reply-To: <d6782789a4c53be2244186588599cc017e3955ea.1496237370.git.jthumshirn@suse.de>

On Wed, May 31, 2017@03:32:13PM +0200, Johannes Thumshirn wrote:
> A NVMe Identify NS command with a CNS value of '3' is expecting a list
> of Namespace Identification Descriptor structures to be returned to
> the host for the namespace requested in the namespace identify
> command.
> 
> This Namespace Identification Descriptor structure consists of the
> type of the namespace identifier, the length of the identifier and the
> actual identifier.
> 
> Valid types are EUI-64, NGUID and UUID which we have saved in our
> nvme_ns structure if they have been configured via configfs. If no
> value has been assigened to one of these we return an "invalid opcode"
> back to the host to maintain backward compatibiliy with older
> implementations without Namespace Identify Descriptor list support.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/target/admin-cmd.c | 63 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/nvme.h            | 18 ++++++++++++

Can you split all the new structures in nvme.h into a separate patch
at the beginning of the series?

> +	static const int buf_size = SZ_4K;

Please add a NVME_IDENTIFY_DATA_SIZE define to nvme.h (and I'd slighty
prefer to define it to 4096 instead of the odd SZ_4K).  And also replace
all the places where we use a magic 4096 for the identify payload with
it.

> +	nid_list = kzalloc(buf_size, GFP_KERNEL);
> +	if (!nid_list) {
> +		status = NVME_SC_INTERNAL;
> +		goto out_put_ns;
> +	}
> +
> +	p = nid_list;

No need for the dynamic allocation.  Just do a straight nvmet_copy_to_sgl
from the stack for each element.

> +
> +	if (memchr_inv(&ns->uuid, 0, sizeof(ns->uuid))) {
> +		ns_nid = (struct nvme_ns_nid *)p;
> +		ns_nid->nidt = NVME_NIDT_UUID;
> +		ns_nid->nidl = NVME_NIDT_UUID_LEN;
> +		memcpy(&ns_nid->nid, &ns->uuid, sizeof(ns->uuid));
> +		pos += sizeof(struct nvme_ns_nid) + sizeof(ns->uuid);
> +		if (pos > buf_size) {
> +			status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
> +			goto out_free_nid_list;
> +		}
> +		p += pos;
> +	}

E.g. something like

	struct nvme_ns_identifier_hdr nih;

	...

		memset(&nih, 0, sizeof(nih));
		nih.nidt = NVME_NIDT_UUID;
		nih.nidl = NVME_NIDT_UUID_LEN;
		status = nvmet_copy_to_sgl(req, off, &nih, sizeof(nih));
		if (status)
			goto out_put_ns;
		off += sizeof(nih);

		status = nvmet_copy_to_sgl(req, off, &ns->uuid,
				sizeof(ns->uuid));
		if (status)
			goto out_put_ns;
		off += sizeof(ns->uuid);

  reply	other threads:[~2017-06-01  6:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 13:32 [PATCH v1 0/7] Implement NVMe Namespace Descriptor Identification Johannes Thumshirn
2017-05-31 13:32 ` [PATCH v1 1/7] nvme: rename uuid to nguid in nvme_ns Johannes Thumshirn
2017-06-01  6:33   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn
2017-06-01  6:34   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 3/7] nvmet: implement namespace identify descriptor list Johannes Thumshirn
2017-06-01  6:42   ` Christoph Hellwig [this message]
2017-05-31 13:32 ` [PATCH v1 4/7] nvme: get list of namespace descriptors Johannes Thumshirn
2017-05-31 19:13   ` Max Gurtovoy
2017-06-01  6:49   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 5/7] nvme: provide UUID value to userspace Johannes Thumshirn
2017-06-01  6:49   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 6/7] nvme: change magic 4096 to SZ_4K Johannes Thumshirn
2017-06-01  6:50   ` Christoph Hellwig
2017-05-31 13:32 ` [PATCH v1 7/7] nvmet: allow overriding the NVMe VS via configfs Johannes Thumshirn
2017-06-01  6:52   ` Christoph Hellwig
2017-06-01  6:59     ` Hannes Reinecke

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=20170601064233.GC16778@lst.de \
    --to=hch@lst.de \
    /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