All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Implement NVMe Namespace Descriptor Identification
@ 2017-05-30  8:08 ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

This patchset implemets NVMe Namespace Descriptor Identification as of
NVMe 1.3. The Namespace Descriptor Identification allows a NVMe host
to query several Namespace Identification mechanisms, such as EUI-64,
NGUID and UUID from the target. If more than one value is set by the
target, it can transmit all set values to the host.

The Namespace Identification Descriptor list is the only way a target
can identify itself via the newly introduced UUID to the host (instead
of the EUI-64 or NGUID).

Both the Host and Target side are implemented. In order to get the
Linux Host to send the Linux target implementation a Namespace
Descriptor Identification command, you have to change the target's
announced version code to at least 1.3. 

Unfortunately the host side already did have a sysfs attribute called
'uuid' which represented the NGUID, so precautions have been taken to
not break any existing userspace.

While I was already touching the relevant code paths, I decided to
also include the EUI-64 in the 'Identify Namespace' command response.

The code is tested using the nvme-loop loopback target and cut against
the nvme tree's nvme-4.12 branch.

A patch for nvmetcli will follow shortly.

Johannes Thumshirn (7):
  nvme: rename uuid to nguid in nvme_ns
  nvmet: add uuid field to nvme_ns and populate via configfs
  nvmet: add eui64 field to nvme_ns and populate via configfs
  nvme: also report include the EUI-64 in identify NS report
  nvmet: implement namespace identify descriptor list
  nvme: get list of namespace descriptors
  nvme: provide UUID value to userspace

 drivers/nvme/host/core.c        | 116 ++++++++++++++++++++++++++++++++++++++--
 drivers/nvme/host/nvme.h        |   1 +
 drivers/nvme/target/admin-cmd.c |  76 ++++++++++++++++++++++++++
 drivers/nvme/target/configfs.c  |  96 +++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h     |   2 +
 include/linux/nvme.h            |  14 +++++
 6 files changed, 301 insertions(+), 4 deletions(-)

-- 
2.12.0

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 0/7] Implement NVMe Namespace Descriptor Identification
@ 2017-05-30  8:08 ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


This patchset implemets NVMe Namespace Descriptor Identification as of
NVMe 1.3. The Namespace Descriptor Identification allows a NVMe host
to query several Namespace Identification mechanisms, such as EUI-64,
NGUID and UUID from the target. If more than one value is set by the
target, it can transmit all set values to the host.

The Namespace Identification Descriptor list is the only way a target
can identify itself via the newly introduced UUID to the host (instead
of the EUI-64 or NGUID).

Both the Host and Target side are implemented. In order to get the
Linux Host to send the Linux target implementation a Namespace
Descriptor Identification command, you have to change the target's
announced version code to at least 1.3. 

Unfortunately the host side already did have a sysfs attribute called
'uuid' which represented the NGUID, so precautions have been taken to
not break any existing userspace.

While I was already touching the relevant code paths, I decided to
also include the EUI-64 in the 'Identify Namespace' command response.

The code is tested using the nvme-loop loopback target and cut against
the nvme tree's nvme-4.12 branch.

A patch for nvmetcli will follow shortly.

Johannes Thumshirn (7):
  nvme: rename uuid to nguid in nvme_ns
  nvmet: add uuid field to nvme_ns and populate via configfs
  nvmet: add eui64 field to nvme_ns and populate via configfs
  nvme: also report include the EUI-64 in identify NS report
  nvmet: implement namespace identify descriptor list
  nvme: get list of namespace descriptors
  nvme: provide UUID value to userspace

 drivers/nvme/host/core.c        | 116 ++++++++++++++++++++++++++++++++++++++--
 drivers/nvme/host/nvme.h        |   1 +
 drivers/nvme/target/admin-cmd.c |  76 ++++++++++++++++++++++++++
 drivers/nvme/target/configfs.c  |  96 +++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h     |   2 +
 include/linux/nvme.h            |  14 +++++
 6 files changed, 301 insertions(+), 4 deletions(-)

-- 
2.12.0

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 1/7] nvme: rename uuid to nguid in nvme_ns
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

The uuid field in the nvme_ns structure represents the nguid field
from the identify namespace command. And as NVMe 1.3 introduced an
UUID in the NVMe Namespace Identification Descriptor this will
collide.

So rename the uuid to nguid to prevent any further
confusion. Unfortunately we export the nguid to sysfs in the uuid
sysfs attribute, but this can't be changed anymore without possibly
breaking existing userspace.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/host/core.c | 10 +++++-----
 drivers/nvme/host/nvme.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a60926410438..7b254be16887 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1016,7 +1016,7 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
 	if (ns->ctrl->vs >= NVME_VS(1, 1, 0))
 		memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
 	if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
-		memcpy(ns->uuid, (*id)->nguid, sizeof(ns->uuid));
+		memcpy(ns->nguid, (*id)->nguid, sizeof(ns->nguid));
 
 	return 0;
 }
@@ -1784,8 +1784,8 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
 	int serial_len = sizeof(ctrl->serial);
 	int model_len = sizeof(ctrl->model);
 
-	if (memchr_inv(ns->uuid, 0, sizeof(ns->uuid)))
-		return sprintf(buf, "eui.%16phN\n", ns->uuid);
+	if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
+		return sprintf(buf, "eui.%16phN\n", ns->nguid);
 
 	if (memchr_inv(ns->eui, 0, sizeof(ns->eui)))
 		return sprintf(buf, "eui.%8phN\n", ns->eui);
@@ -1804,7 +1804,7 @@ static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
 								char *buf)
 {
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
-	return sprintf(buf, "%pU\n", ns->uuid);
+	return sprintf(buf, "%pU\n", ns->nguid);
 }
 static DEVICE_ATTR(uuid, S_IRUGO, uuid_show, NULL);
 
@@ -1839,7 +1839,7 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
 
 	if (a == &dev_attr_uuid.attr) {
-		if (!memchr_inv(ns->uuid, 0, sizeof(ns->uuid)))
+		if (!memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
 			return 0;
 	}
 	if (a == &dev_attr_eui.attr) {
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 9d6a070d4391..5004f0c41397 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -189,7 +189,7 @@ struct nvme_ns {
 	int instance;
 
 	u8 eui[8];
-	u8 uuid[16];
+	u8 nguid[16];
 
 	unsigned ns_id;
 	int lba_shift;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 1/7] nvme: rename uuid to nguid in nvme_ns
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


The uuid field in the nvme_ns structure represents the nguid field
from the identify namespace command. And as NVMe 1.3 introduced an
UUID in the NVMe Namespace Identification Descriptor this will
collide.

So rename the uuid to nguid to prevent any further
confusion. Unfortunately we export the nguid to sysfs in the uuid
sysfs attribute, but this can't be changed anymore without possibly
breaking existing userspace.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/host/core.c | 10 +++++-----
 drivers/nvme/host/nvme.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a60926410438..7b254be16887 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1016,7 +1016,7 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
 	if (ns->ctrl->vs >= NVME_VS(1, 1, 0))
 		memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
 	if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
-		memcpy(ns->uuid, (*id)->nguid, sizeof(ns->uuid));
+		memcpy(ns->nguid, (*id)->nguid, sizeof(ns->nguid));
 
 	return 0;
 }
@@ -1784,8 +1784,8 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
 	int serial_len = sizeof(ctrl->serial);
 	int model_len = sizeof(ctrl->model);
 
-	if (memchr_inv(ns->uuid, 0, sizeof(ns->uuid)))
-		return sprintf(buf, "eui.%16phN\n", ns->uuid);
+	if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
+		return sprintf(buf, "eui.%16phN\n", ns->nguid);
 
 	if (memchr_inv(ns->eui, 0, sizeof(ns->eui)))
 		return sprintf(buf, "eui.%8phN\n", ns->eui);
@@ -1804,7 +1804,7 @@ static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
 								char *buf)
 {
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
-	return sprintf(buf, "%pU\n", ns->uuid);
+	return sprintf(buf, "%pU\n", ns->nguid);
 }
 static DEVICE_ATTR(uuid, S_IRUGO, uuid_show, NULL);
 
@@ -1839,7 +1839,7 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
 
 	if (a == &dev_attr_uuid.attr) {
-		if (!memchr_inv(ns->uuid, 0, sizeof(ns->uuid)))
+		if (!memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
 			return 0;
 	}
 	if (a == &dev_attr_eui.attr) {
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 9d6a070d4391..5004f0c41397 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -189,7 +189,7 @@ struct nvme_ns {
 	int instance;
 
 	u8 eui[8];
-	u8 uuid[16];
+	u8 nguid[16];
 
 	unsigned ns_id;
 	int lba_shift;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

Add the UUID field from the NVMe Namespace Identification Descriptor
to the nvmet_ns structure and allow it's population via configfs.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h    |  1 +
 2 files changed, 49 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index be8c800078e2..0529a36501f4 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -305,11 +305,58 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
 
 CONFIGFS_ATTR(nvmet_ns_, device_path);
 
+static ssize_t nvmet_ns_device_uuid_show(struct config_item *item, char *page)
+{
+	return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->uuid);
+}
+
+static ssize_t nvmet_ns_device_uuid_store(struct config_item *item,
+					  const char *page, size_t count)
+{
+	struct nvmet_ns *ns = to_nvmet_ns(item);
+	struct nvmet_subsys *subsys = ns->subsys;
+	u8 uuid[16];
+	const char *p = page;
+	int i;
+	int ret = 0;
+
+
+	mutex_lock(&subsys->lock);
+	if (ns->enabled) {
+		ret = -EBUSY;
+		goto out_unlock;
+	}
+
+	for (i = 0; i < 16; i++) {
+		if (p + 2 > page + count) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+		if (!isxdigit(p[0]) || !isxdigit(p[1])) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+
+		uuid[i] = (hex_to_bin(p[0]) << 4) | hex_to_bin(p[1]);
+		p += 2;
+
+		if (*p == '-' || *p == ':')
+			p++;
+	}
+
+	memcpy(&ns->uuid, uuid, sizeof(uuid));
+out_unlock:
+	mutex_unlock(&subsys->lock);
+	return ret ? ret : count;
+}
+
 static ssize_t nvmet_ns_device_nguid_show(struct config_item *item, char *page)
 {
 	return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->nguid);
 }
 
+CONFIGFS_ATTR(nvmet_ns_, device_uuid);
+
 static ssize_t nvmet_ns_device_nguid_store(struct config_item *item,
 		const char *page, size_t count)
 {
@@ -379,6 +426,7 @@ CONFIGFS_ATTR(nvmet_ns_, enable);
 static struct configfs_attribute *nvmet_ns_attrs[] = {
 	&nvmet_ns_attr_device_path,
 	&nvmet_ns_attr_device_nguid,
+	&nvmet_ns_attr_device_uuid,
 	&nvmet_ns_attr_enable,
 	NULL,
 };
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index cfc5c7fb0ab7..6ef7db521716 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -46,6 +46,7 @@ struct nvmet_ns {
 	u32			blksize_shift;
 	loff_t			size;
 	u8			nguid[16];
+	u8			uuid[16];
 
 	bool			enabled;
 	struct nvmet_subsys	*subsys;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


Add the UUID field from the NVMe Namespace Identification Descriptor
to the nvmet_ns structure and allow it's population via configfs.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h    |  1 +
 2 files changed, 49 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index be8c800078e2..0529a36501f4 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -305,11 +305,58 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
 
 CONFIGFS_ATTR(nvmet_ns_, device_path);
 
+static ssize_t nvmet_ns_device_uuid_show(struct config_item *item, char *page)
+{
+	return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->uuid);
+}
+
+static ssize_t nvmet_ns_device_uuid_store(struct config_item *item,
+					  const char *page, size_t count)
+{
+	struct nvmet_ns *ns = to_nvmet_ns(item);
+	struct nvmet_subsys *subsys = ns->subsys;
+	u8 uuid[16];
+	const char *p = page;
+	int i;
+	int ret = 0;
+
+
+	mutex_lock(&subsys->lock);
+	if (ns->enabled) {
+		ret = -EBUSY;
+		goto out_unlock;
+	}
+
+	for (i = 0; i < 16; i++) {
+		if (p + 2 > page + count) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+		if (!isxdigit(p[0]) || !isxdigit(p[1])) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+
+		uuid[i] = (hex_to_bin(p[0]) << 4) | hex_to_bin(p[1]);
+		p += 2;
+
+		if (*p == '-' || *p == ':')
+			p++;
+	}
+
+	memcpy(&ns->uuid, uuid, sizeof(uuid));
+out_unlock:
+	mutex_unlock(&subsys->lock);
+	return ret ? ret : count;
+}
+
 static ssize_t nvmet_ns_device_nguid_show(struct config_item *item, char *page)
 {
 	return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->nguid);
 }
 
+CONFIGFS_ATTR(nvmet_ns_, device_uuid);
+
 static ssize_t nvmet_ns_device_nguid_store(struct config_item *item,
 		const char *page, size_t count)
 {
@@ -379,6 +426,7 @@ CONFIGFS_ATTR(nvmet_ns_, enable);
 static struct configfs_attribute *nvmet_ns_attrs[] = {
 	&nvmet_ns_attr_device_path,
 	&nvmet_ns_attr_device_nguid,
+	&nvmet_ns_attr_device_uuid,
 	&nvmet_ns_attr_enable,
 	NULL,
 };
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index cfc5c7fb0ab7..6ef7db521716 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -46,6 +46,7 @@ struct nvmet_ns {
 	u32			blksize_shift;
 	loff_t			size;
 	u8			nguid[16];
+	u8			uuid[16];
 
 	bool			enabled;
 	struct nvmet_subsys	*subsys;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

Add the EUI-64 field from the NVMe Namespace Identification Descriptor
to the nvmet_ns structure and allow it's population via configfs.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h    |  1 +
 2 files changed, 49 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 0529a36501f4..0c6351253c3f 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -305,6 +305,53 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
 
 CONFIGFS_ATTR(nvmet_ns_, device_path);
 
+static ssize_t nvmet_ns_device_eui64_show(struct config_item *item, char *page)
+{
+	return sprintf(page, "%8phN\n", &to_nvmet_ns(item)->eui64);
+}
+
+static ssize_t nvmet_ns_device_eui64_store(struct config_item *item,
+					   const char *page, size_t count)
+{
+	struct nvmet_ns *ns = to_nvmet_ns(item);
+	struct nvmet_subsys *subsys = ns->subsys;
+	u8 eui64[8];
+	const char *p = page;
+	int i;
+	int ret = 0;
+
+
+	mutex_lock(&subsys->lock);
+	if (ns->enabled) {
+		ret = -EBUSY;
+		goto out_unlock;
+	}
+
+	for (i = 0; i < 8; i++) {
+		if (p + 2 > page + count) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+		if (!isxdigit(p[0]) || !isxdigit(p[1])) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+
+		eui64[i] = (hex_to_bin(p[0]) << 4) | hex_to_bin(p[1]);
+		p += 2;
+
+		if (*p == '-')
+			p++;
+	}
+
+	memcpy(&ns->eui64, eui64, sizeof(eui64));
+out_unlock:
+	mutex_unlock(&subsys->lock);
+	return ret ? ret : count;
+}
+
+CONFIGFS_ATTR(nvmet_ns_, device_eui64);
+
 static ssize_t nvmet_ns_device_uuid_show(struct config_item *item, char *page)
 {
 	return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->uuid);
@@ -427,6 +474,7 @@ static struct configfs_attribute *nvmet_ns_attrs[] = {
 	&nvmet_ns_attr_device_path,
 	&nvmet_ns_attr_device_nguid,
 	&nvmet_ns_attr_device_uuid,
+	&nvmet_ns_attr_device_eui64,
 	&nvmet_ns_attr_enable,
 	NULL,
 };
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 6ef7db521716..ee936c2f394a 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -47,6 +47,7 @@ struct nvmet_ns {
 	loff_t			size;
 	u8			nguid[16];
 	u8			uuid[16];
+	u8			eui64[8];
 
 	bool			enabled;
 	struct nvmet_subsys	*subsys;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


Add the EUI-64 field from the NVMe Namespace Identification Descriptor
to the nvmet_ns structure and allow it's population via configfs.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/target/nvmet.h    |  1 +
 2 files changed, 49 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 0529a36501f4..0c6351253c3f 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -305,6 +305,53 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
 
 CONFIGFS_ATTR(nvmet_ns_, device_path);
 
+static ssize_t nvmet_ns_device_eui64_show(struct config_item *item, char *page)
+{
+	return sprintf(page, "%8phN\n", &to_nvmet_ns(item)->eui64);
+}
+
+static ssize_t nvmet_ns_device_eui64_store(struct config_item *item,
+					   const char *page, size_t count)
+{
+	struct nvmet_ns *ns = to_nvmet_ns(item);
+	struct nvmet_subsys *subsys = ns->subsys;
+	u8 eui64[8];
+	const char *p = page;
+	int i;
+	int ret = 0;
+
+
+	mutex_lock(&subsys->lock);
+	if (ns->enabled) {
+		ret = -EBUSY;
+		goto out_unlock;
+	}
+
+	for (i = 0; i < 8; i++) {
+		if (p + 2 > page + count) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+		if (!isxdigit(p[0]) || !isxdigit(p[1])) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+
+		eui64[i] = (hex_to_bin(p[0]) << 4) | hex_to_bin(p[1]);
+		p += 2;
+
+		if (*p == '-')
+			p++;
+	}
+
+	memcpy(&ns->eui64, eui64, sizeof(eui64));
+out_unlock:
+	mutex_unlock(&subsys->lock);
+	return ret ? ret : count;
+}
+
+CONFIGFS_ATTR(nvmet_ns_, device_eui64);
+
 static ssize_t nvmet_ns_device_uuid_show(struct config_item *item, char *page)
 {
 	return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->uuid);
@@ -427,6 +474,7 @@ static struct configfs_attribute *nvmet_ns_attrs[] = {
 	&nvmet_ns_attr_device_path,
 	&nvmet_ns_attr_device_nguid,
 	&nvmet_ns_attr_device_uuid,
+	&nvmet_ns_attr_device_eui64,
 	&nvmet_ns_attr_enable,
 	NULL,
 };
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 6ef7db521716..ee936c2f394a 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -47,6 +47,7 @@ struct nvmet_ns {
 	loff_t			size;
 	u8			nguid[16];
 	u8			uuid[16];
+	u8			eui64[8];
 
 	bool			enabled;
 	struct nvmet_subsys	*subsys;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

Now that we can configure a namespace's EUI-64, report it back to the
host in an 'Identify Namespace' command reply.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/target/admin-cmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index ff1f97006322..60c9eec57986 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -322,6 +322,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
 	id->nmic = (1 << 0);
 
 	memcpy(&id->nguid, &ns->nguid, sizeof(uuid_le));
+	memcpy(&id->eui64, &ns->eui64, sizeof(ns->eui64));
 
 	id->lbaf[0].ds = ns->blksize_shift;
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


Now that we can configure a namespace's EUI-64, report it back to the
host in an 'Identify Namespace' command reply.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/target/admin-cmd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index ff1f97006322..60c9eec57986 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -322,6 +322,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
 	id->nmic = (1 << 0);
 
 	memcpy(&id->nguid, &ns->nguid, sizeof(uuid_le));
+	memcpy(&id->eui64, &ns->eui64, sizeof(ns->eui64));
 
 	id->lbaf[0].ds = ns->blksize_shift;
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 5/7] nvmet: implement namespace identify descriptor list
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

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@suse.de>
---
 drivers/nvme/target/admin-cmd.c | 75 +++++++++++++++++++++++++++++++++++++++++
 include/linux/nvme.h            | 14 ++++++++
 2 files changed, 89 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 60c9eec57986..2290301a6172 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -368,6 +368,78 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
+static void nvmet_execute_identify_desclist(struct nvmet_req *req)
+{
+	static const int buf_size = 4069;
+	struct nvmet_ns *ns;
+	struct nvme_ns_nid *ns_nid;
+	u8 *nid_list;
+	u16 status = 0;
+	int pos = 0;
+	const u8 *p;
+
+	ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
+	if (!ns) {
+		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
+		goto out;
+	}
+
+	nid_list = kzalloc(buf_size, GFP_KERNEL);
+	if (!nid_list) {
+		status = NVME_SC_INTERNAL;
+		goto out_put_ns;
+	}
+
+	p = nid_list;
+
+	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 = 16;
+		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;
+	}
+	if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid))) {
+		ns_nid = (struct nvme_ns_nid *)p;
+		ns_nid->nidt = NVME_NIDT_NGUID;
+		ns_nid->nidl = 16;
+		memcpy(&ns_nid->nid, &ns->nguid, sizeof(ns->nguid));
+		pos += sizeof(struct nvme_ns_nid) + sizeof(ns->nguid);
+		if (pos > buf_size) {
+			status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+			goto out_free_nid_list;
+		}
+		p += pos;
+	}
+	if (memchr_inv(ns->eui64, 0, sizeof(ns->eui64))) {
+		ns_nid = (struct nvme_ns_nid *)p;
+		ns_nid->nidt = NVME_NIDT_EUI64;
+		ns_nid->nidl = 8;
+		memcpy(&ns_nid->nid, &ns->eui64, sizeof(ns->eui64));
+		pos += sizeof(struct nvme_ns_nid) + sizeof(ns->eui64);
+		if (pos > buf_size) {
+			status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+			goto out_free_nid_list;
+		}
+		p += pos;
+	}
+
+	status = nvmet_copy_to_sgl(req, 0, nid_list, buf_size);
+
+out_free_nid_list:
+	kfree(nid_list);
+
+out_put_ns:
+	nvmet_put_namespace(ns);
+out:
+	nvmet_req_complete(req, status);
+}
+
 /*
  * A "mimimum viable" abort implementation: the command is mandatory in the
  * spec, but we are not required to do any useful work.  We couldn't really
@@ -516,6 +588,9 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 		case NVME_ID_CNS_NS_ACTIVE_LIST:
 			req->execute = nvmet_execute_identify_nslist;
 			return 0;
+		case NVME_ID_CNS_NS_DESC_LIST:
+			req->execute = nvmet_execute_identify_desclist;
+			return 0;
 		}
 		break;
 	case nvme_admin_abort_cmd:
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index b625bacf37ef..cad0e19f0bba 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -288,6 +288,7 @@ enum {
 	NVME_ID_CNS_NS			= 0x00,
 	NVME_ID_CNS_CTRL		= 0x01,
 	NVME_ID_CNS_NS_ACTIVE_LIST	= 0x02,
+	NVME_ID_CNS_NS_DESC_LIST	= 0x03,
 	NVME_ID_CNS_NS_PRESENT_LIST	= 0x10,
 	NVME_ID_CNS_NS_PRESENT		= 0x11,
 	NVME_ID_CNS_CTRL_NS_LIST	= 0x12,
@@ -314,6 +315,19 @@ enum {
 	NVME_NS_DPS_PI_TYPE3	= 3,
 };
 
+struct nvme_ns_nid {
+	__u8 nidt;
+	__u8 nidl;
+	__le16 reserved;
+	__u8 nid[0];
+};
+
+enum {
+	NVME_NIDT_EUI64		= 0x01,
+	NVME_NIDT_NGUID		= 0x02,
+	NVME_NIDT_UUID		= 0x03,
+};
+
 struct nvme_smart_log {
 	__u8			critical_warning;
 	__u8			temperature[2];
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 5/7] nvmet: implement namespace identify descriptor list
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


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 | 75 +++++++++++++++++++++++++++++++++++++++++
 include/linux/nvme.h            | 14 ++++++++
 2 files changed, 89 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 60c9eec57986..2290301a6172 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -368,6 +368,78 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
+static void nvmet_execute_identify_desclist(struct nvmet_req *req)
+{
+	static const int buf_size = 4069;
+	struct nvmet_ns *ns;
+	struct nvme_ns_nid *ns_nid;
+	u8 *nid_list;
+	u16 status = 0;
+	int pos = 0;
+	const u8 *p;
+
+	ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
+	if (!ns) {
+		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
+		goto out;
+	}
+
+	nid_list = kzalloc(buf_size, GFP_KERNEL);
+	if (!nid_list) {
+		status = NVME_SC_INTERNAL;
+		goto out_put_ns;
+	}
+
+	p = nid_list;
+
+	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 = 16;
+		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;
+	}
+	if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid))) {
+		ns_nid = (struct nvme_ns_nid *)p;
+		ns_nid->nidt = NVME_NIDT_NGUID;
+		ns_nid->nidl = 16;
+		memcpy(&ns_nid->nid, &ns->nguid, sizeof(ns->nguid));
+		pos += sizeof(struct nvme_ns_nid) + sizeof(ns->nguid);
+		if (pos > buf_size) {
+			status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+			goto out_free_nid_list;
+		}
+		p += pos;
+	}
+	if (memchr_inv(ns->eui64, 0, sizeof(ns->eui64))) {
+		ns_nid = (struct nvme_ns_nid *)p;
+		ns_nid->nidt = NVME_NIDT_EUI64;
+		ns_nid->nidl = 8;
+		memcpy(&ns_nid->nid, &ns->eui64, sizeof(ns->eui64));
+		pos += sizeof(struct nvme_ns_nid) + sizeof(ns->eui64);
+		if (pos > buf_size) {
+			status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
+			goto out_free_nid_list;
+		}
+		p += pos;
+	}
+
+	status = nvmet_copy_to_sgl(req, 0, nid_list, buf_size);
+
+out_free_nid_list:
+	kfree(nid_list);
+
+out_put_ns:
+	nvmet_put_namespace(ns);
+out:
+	nvmet_req_complete(req, status);
+}
+
 /*
  * A "mimimum viable" abort implementation: the command is mandatory in the
  * spec, but we are not required to do any useful work.  We couldn't really
@@ -516,6 +588,9 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 		case NVME_ID_CNS_NS_ACTIVE_LIST:
 			req->execute = nvmet_execute_identify_nslist;
 			return 0;
+		case NVME_ID_CNS_NS_DESC_LIST:
+			req->execute = nvmet_execute_identify_desclist;
+			return 0;
 		}
 		break;
 	case nvme_admin_abort_cmd:
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index b625bacf37ef..cad0e19f0bba 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -288,6 +288,7 @@ enum {
 	NVME_ID_CNS_NS			= 0x00,
 	NVME_ID_CNS_CTRL		= 0x01,
 	NVME_ID_CNS_NS_ACTIVE_LIST	= 0x02,
+	NVME_ID_CNS_NS_DESC_LIST	= 0x03,
 	NVME_ID_CNS_NS_PRESENT_LIST	= 0x10,
 	NVME_ID_CNS_NS_PRESENT		= 0x11,
 	NVME_ID_CNS_CTRL_NS_LIST	= 0x12,
@@ -314,6 +315,19 @@ enum {
 	NVME_NS_DPS_PI_TYPE3	= 3,
 };
 
+struct nvme_ns_nid {
+	__u8 nidt;
+	__u8 nidl;
+	__le16 reserved;
+	__u8 nid[0];
+};
+
+enum {
+	NVME_NIDT_EUI64		= 0x01,
+	NVME_NIDT_NGUID		= 0x02,
+	NVME_NIDT_UUID		= 0x03,
+};
+
 struct nvme_smart_log {
 	__u8			critical_warning;
 	__u8			temperature[2];
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 6/7] nvme: get list of namespace descriptors
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

If a target identifies itself as NVMe 1.3 compliant, try to get the
list of Namespace Identification Descriptors and populate the UUID,
NGUID and EUI64 fileds in the NVMe namespace structure with these
values.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/host/core.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/host/nvme.h |  1 +
 2 files changed, 89 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7b254be16887..d2365f7ea612 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -643,6 +643,71 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
 	return error;
 }
 
+static void nvme_parse_ns_descs(struct nvme_ns *ns, void *ns_nid)
+{
+	struct nvme_ns_nid *cur;
+	const u8 *p;
+	int pos = 0;
+	int len;
+
+	p = (u8 *)ns_nid;
+
+	for (;;) {
+		cur = (struct nvme_ns_nid *)p;
+
+		switch (cur->nidl) {
+		case 0:
+			return;
+		case 8:
+		case 16:
+			break;
+		default:
+			dev_warn(ns->ctrl->dev,
+				 "Target returned bogus Namespace Identification Descriptor length: %d\n",
+				 cur->nidl);
+			return;
+
+		}
+
+		switch (cur->nidt) {
+		case NVME_NIDT_EUI64:
+			len = 8;
+			memcpy(ns->eui, cur->nid, len);
+			break;
+		case NVME_NIDT_NGUID:
+			len = 16;
+			memcpy(ns->nguid, cur->nid, len);
+			break;
+		case NVME_NIDT_UUID:
+			len = 16;
+			memcpy(ns->uuid, cur->nid, len);
+			break;
+		default:
+			dev_warn(ns->ctrl->dev,
+				 "Invalid Namespace Identification Descriptor Type: %d\n",
+				 cur->nidt);
+			return;
+		}
+
+		pos += sizeof(struct nvme_ns_nid) + len;
+		if (pos >= 4096)
+			return;
+		p += pos;
+	}
+}
+
+static int nvme_identify_ns_descs(struct nvme_ctrl *dev, unsigned nsid,
+				  void *ns_nid)
+{
+	struct nvme_command c = { };
+
+	c.identify.opcode = nvme_admin_identify;
+	c.identify.nsid = cpu_to_le32(nsid);
+	c.identify.cns = NVME_ID_CNS_NS_DESC_LIST;
+
+	return nvme_submit_sync_cmd(dev->admin_q, &c, ns_nid, 4096);
+}
+
 static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *ns_list)
 {
 	struct nvme_command c = { };
@@ -1017,6 +1082,29 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
 		memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
 	if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
 		memcpy(ns->nguid, (*id)->nguid, sizeof(ns->nguid));
+	if (ns->ctrl->vs >= NVME_VS(1, 3, 0)) {
+		void *ns_nid;
+		int ret;
+
+
+		ns_nid = kzalloc(4096, GFP_KERNEL);
+		if (!ns_nid) {
+			dev_warn(ns->ctrl->dev,
+				 "%s: Identify Descriptors failed\n", __func__);
+			return 0;
+		}
+
+		ret = nvme_identify_ns_descs(ns->ctrl, ns->ns_id, ns_nid);
+		if (ret) {
+			dev_warn(ns->ctrl->dev,
+				 "%s: Identify Descriptors failed\n", __func__);
+			 /* Don't treat error as fatal we potentially
+			  * already have a NGUID or EUI-64 */
+			return 0;
+		}
+		nvme_parse_ns_descs(ns, ns_nid);
+		kfree(ns_nid);
+	}
 
 	return 0;
 }
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 5004f0c41397..7007521e8194 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -190,6 +190,7 @@ struct nvme_ns {
 
 	u8 eui[8];
 	u8 nguid[16];
+	u8 uuid[16];
 
 	unsigned ns_id;
 	int lba_shift;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 6/7] nvme: get list of namespace descriptors
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


If a target identifies itself as NVMe 1.3 compliant, try to get the
list of Namespace Identification Descriptors and populate the UUID,
NGUID and EUI64 fileds in the NVMe namespace structure with these
values.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/host/core.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/nvme/host/nvme.h |  1 +
 2 files changed, 89 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7b254be16887..d2365f7ea612 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -643,6 +643,71 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
 	return error;
 }
 
+static void nvme_parse_ns_descs(struct nvme_ns *ns, void *ns_nid)
+{
+	struct nvme_ns_nid *cur;
+	const u8 *p;
+	int pos = 0;
+	int len;
+
+	p = (u8 *)ns_nid;
+
+	for (;;) {
+		cur = (struct nvme_ns_nid *)p;
+
+		switch (cur->nidl) {
+		case 0:
+			return;
+		case 8:
+		case 16:
+			break;
+		default:
+			dev_warn(ns->ctrl->dev,
+				 "Target returned bogus Namespace Identification Descriptor length: %d\n",
+				 cur->nidl);
+			return;
+
+		}
+
+		switch (cur->nidt) {
+		case NVME_NIDT_EUI64:
+			len = 8;
+			memcpy(ns->eui, cur->nid, len);
+			break;
+		case NVME_NIDT_NGUID:
+			len = 16;
+			memcpy(ns->nguid, cur->nid, len);
+			break;
+		case NVME_NIDT_UUID:
+			len = 16;
+			memcpy(ns->uuid, cur->nid, len);
+			break;
+		default:
+			dev_warn(ns->ctrl->dev,
+				 "Invalid Namespace Identification Descriptor Type: %d\n",
+				 cur->nidt);
+			return;
+		}
+
+		pos += sizeof(struct nvme_ns_nid) + len;
+		if (pos >= 4096)
+			return;
+		p += pos;
+	}
+}
+
+static int nvme_identify_ns_descs(struct nvme_ctrl *dev, unsigned nsid,
+				  void *ns_nid)
+{
+	struct nvme_command c = { };
+
+	c.identify.opcode = nvme_admin_identify;
+	c.identify.nsid = cpu_to_le32(nsid);
+	c.identify.cns = NVME_ID_CNS_NS_DESC_LIST;
+
+	return nvme_submit_sync_cmd(dev->admin_q, &c, ns_nid, 4096);
+}
+
 static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *ns_list)
 {
 	struct nvme_command c = { };
@@ -1017,6 +1082,29 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
 		memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
 	if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
 		memcpy(ns->nguid, (*id)->nguid, sizeof(ns->nguid));
+	if (ns->ctrl->vs >= NVME_VS(1, 3, 0)) {
+		void *ns_nid;
+		int ret;
+
+
+		ns_nid = kzalloc(4096, GFP_KERNEL);
+		if (!ns_nid) {
+			dev_warn(ns->ctrl->dev,
+				 "%s: Identify Descriptors failed\n", __func__);
+			return 0;
+		}
+
+		ret = nvme_identify_ns_descs(ns->ctrl, ns->ns_id, ns_nid);
+		if (ret) {
+			dev_warn(ns->ctrl->dev,
+				 "%s: Identify Descriptors failed\n", __func__);
+			 /* Don't treat error as fatal we potentially
+			  * already have a NGUID or EUI-64 */
+			return 0;
+		}
+		nvme_parse_ns_descs(ns, ns_nid);
+		kfree(ns_nid);
+	}
 
 	return 0;
 }
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 5004f0c41397..7007521e8194 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -190,6 +190,7 @@ struct nvme_ns {
 
 	u8 eui[8];
 	u8 nguid[16];
+	u8 uuid[16];
 
 	unsigned ns_id;
 	int lba_shift;
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 7/7] nvme: provide UUID value to userspace
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-30  8:08   ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)
  To: Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux NVMe Mailinglist, Linux Kernel Mailinglist, Johannes Thumshirn

Now that we have a way for getting the UUID from a target, provide it
to userspace as well.

Unfortunately there is already a sysfs attribute called UUID which is
a misnomer as it holds the NGUID value. So instead of creating yet
another wrong name, create a new 'nguid' sysfs attribute for the
NGUID. For the UUID attribute add a check wheter the namespace has a
UUID assigned to it and return this or return the NGUID to maintain
backwards compatibility. This should give userspace a chance to catch
up.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/nvme/host/core.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d2365f7ea612..96c063bad48e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1888,11 +1888,25 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(wwid, S_IRUGO, wwid_show, NULL);
 
+static ssize_t nguid_show(struct device *dev, struct device_attribute *attr,
+			  char *buf)
+{
+	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
+	return sprintf(buf, "%pU\n", ns->nguid);
+}
+static DEVICE_ATTR(nguid, S_IRUGO, nguid_show, NULL);
+
 static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
 								char *buf)
 {
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
-	return sprintf(buf, "%pU\n", ns->nguid);
+
+	/* For backward compatibility expose the NGUID to userspace if
+	 * we have no UUID set
+	 */
+	if (!memchr_inv(ns->uuid, 0, sizeof(ns->uuid)))
+		return sprintf(buf, "%pU\n", ns->nguid);
+	return sprintf(buf, "%pU\n", ns->uuid);
 }
 static DEVICE_ATTR(uuid, S_IRUGO, uuid_show, NULL);
 
@@ -1915,6 +1929,7 @@ static DEVICE_ATTR(nsid, S_IRUGO, nsid_show, NULL);
 static struct attribute *nvme_ns_attrs[] = {
 	&dev_attr_wwid.attr,
 	&dev_attr_uuid.attr,
+	&dev_attr_nguid.attr,
 	&dev_attr_eui.attr,
 	&dev_attr_nsid.attr,
 	NULL,
@@ -1927,6 +1942,11 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
 
 	if (a == &dev_attr_uuid.attr) {
+		if (!memchr_inv(ns->uuid, 0, sizeof(ns->uuid)) ||
+		    !memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
+			return 0;
+	}
+	if (a == &dev_attr_nguid.attr) {
 		if (!memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
 			return 0;
 	}
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 7/7] nvme: provide UUID value to userspace
@ 2017-05-30  8:08   ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  8:08 UTC (permalink / raw)


Now that we have a way for getting the UUID from a target, provide it
to userspace as well.

Unfortunately there is already a sysfs attribute called UUID which is
a misnomer as it holds the NGUID value. So instead of creating yet
another wrong name, create a new 'nguid' sysfs attribute for the
NGUID. For the UUID attribute add a check wheter the namespace has a
UUID assigned to it and return this or return the NGUID to maintain
backwards compatibility. This should give userspace a chance to catch
up.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/host/core.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d2365f7ea612..96c063bad48e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1888,11 +1888,25 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(wwid, S_IRUGO, wwid_show, NULL);
 
+static ssize_t nguid_show(struct device *dev, struct device_attribute *attr,
+			  char *buf)
+{
+	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
+	return sprintf(buf, "%pU\n", ns->nguid);
+}
+static DEVICE_ATTR(nguid, S_IRUGO, nguid_show, NULL);
+
 static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
 								char *buf)
 {
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
-	return sprintf(buf, "%pU\n", ns->nguid);
+
+	/* For backward compatibility expose the NGUID to userspace if
+	 * we have no UUID set
+	 */
+	if (!memchr_inv(ns->uuid, 0, sizeof(ns->uuid)))
+		return sprintf(buf, "%pU\n", ns->nguid);
+	return sprintf(buf, "%pU\n", ns->uuid);
 }
 static DEVICE_ATTR(uuid, S_IRUGO, uuid_show, NULL);
 
@@ -1915,6 +1929,7 @@ static DEVICE_ATTR(nsid, S_IRUGO, nsid_show, NULL);
 static struct attribute *nvme_ns_attrs[] = {
 	&dev_attr_wwid.attr,
 	&dev_attr_uuid.attr,
+	&dev_attr_nguid.attr,
 	&dev_attr_eui.attr,
 	&dev_attr_nsid.attr,
 	NULL,
@@ -1927,6 +1942,11 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
 	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
 
 	if (a == &dev_attr_uuid.attr) {
+		if (!memchr_inv(ns->uuid, 0, sizeof(ns->uuid)) ||
+		    !memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
+			return 0;
+	}
+	if (a == &dev_attr_nguid.attr) {
 		if (!memchr_inv(ns->nguid, 0, sizeof(ns->nguid)))
 			return 0;
 	}
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH 1/7] nvme: rename uuid to nguid in nvme_ns
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:18     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:18 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> The uuid field in the nvme_ns structure represents the nguid field
> from the identify namespace command. And as NVMe 1.3 introduced an
> UUID in the NVMe Namespace Identification Descriptor this will
> collide.
> 
> So rename the uuid to nguid to prevent any further
> confusion. Unfortunately we export the nguid to sysfs in the uuid
> sysfs attribute, but this can't be changed anymore without possibly
> breaking existing userspace.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/host/core.c | 10 +++++-----
>  drivers/nvme/host/nvme.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 1/7] nvme: rename uuid to nguid in nvme_ns
@ 2017-05-30  8:18     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:18 UTC (permalink / raw)


On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> The uuid field in the nvme_ns structure represents the nguid field
> from the identify namespace command. And as NVMe 1.3 introduced an
> UUID in the NVMe Namespace Identification Descriptor this will
> collide.
> 
> So rename the uuid to nguid to prevent any further
> confusion. Unfortunately we export the nguid to sysfs in the uuid
> sysfs attribute, but this can't be changed anymore without possibly
> breaking existing userspace.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/host/core.c | 10 +++++-----
>  drivers/nvme/host/nvme.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:20     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:20 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Add the UUID field from the NVMe Namespace Identification Descriptor
> to the nvmet_ns structure and allow it's population via configfs.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/target/nvmet.h    |  1 +
>  2 files changed, 49 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
@ 2017-05-30  8:20     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:20 UTC (permalink / raw)


On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Add the UUID field from the NVMe Namespace Identification Descriptor
> to the nvmet_ns structure and allow it's population via configfs.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/target/nvmet.h    |  1 +
>  2 files changed, 49 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:21     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:21 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Add the EUI-64 field from the NVMe Namespace Identification Descriptor
> to the nvmet_ns structure and allow it's population via configfs.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/target/nvmet.h    |  1 +
>  2 files changed, 49 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
@ 2017-05-30  8:21     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:21 UTC (permalink / raw)


On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Add the EUI-64 field from the NVMe Namespace Identification Descriptor
> to the nvmet_ns structure and allow it's population via configfs.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/target/configfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/target/nvmet.h    |  1 +
>  2 files changed, 49 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:22     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:22 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Now that we can configure a namespace's EUI-64, report it back to the
> host in an 'Identify Namespace' command reply.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/target/admin-cmd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index ff1f97006322..60c9eec57986 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -322,6 +322,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
>  	id->nmic = (1 << 0);
>  
>  	memcpy(&id->nguid, &ns->nguid, sizeof(uuid_le));
> +	memcpy(&id->eui64, &ns->eui64, sizeof(ns->eui64));
>  
>  	id->lbaf[0].ds = ns->blksize_shift;
>  
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report
@ 2017-05-30  8:22     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:22 UTC (permalink / raw)


On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Now that we can configure a namespace's EUI-64, report it back to the
> host in an 'Identify Namespace' command reply.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/target/admin-cmd.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index ff1f97006322..60c9eec57986 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -322,6 +322,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
>  	id->nmic = (1 << 0);
>  
>  	memcpy(&id->nguid, &ns->nguid, sizeof(uuid_le));
> +	memcpy(&id->eui64, &ns->eui64, sizeof(ns->eui64));
>  
>  	id->lbaf[0].ds = ns->blksize_shift;
>  
> 
Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 5/7] nvmet: implement namespace identify descriptor list
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:24     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:24 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, 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@suse.de>
> ---
>  drivers/nvme/target/admin-cmd.c | 75 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/nvme.h            | 14 ++++++++
>  2 files changed, 89 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 5/7] nvmet: implement namespace identify descriptor list
@ 2017-05-30  8:24     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:24 UTC (permalink / raw)


On 05/30/2017 10:08 AM, 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 | 75 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/nvme.h            | 14 ++++++++
>  2 files changed, 89 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 6/7] nvme: get list of namespace descriptors
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:30     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:30 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> If a target identifies itself as NVMe 1.3 compliant, try to get the
> list of Namespace Identification Descriptors and populate the UUID,
> NGUID and EUI64 fileds in the NVMe namespace structure with these
> values.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/host/core.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/host/nvme.h |  1 +
>  2 files changed, 89 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 7b254be16887..d2365f7ea612 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -643,6 +643,71 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
>  	return error;
>  }
>  
> +static void nvme_parse_ns_descs(struct nvme_ns *ns, void *ns_nid)
> +{
> +	struct nvme_ns_nid *cur;
> +	const u8 *p;
> +	int pos = 0;
> +	int len;
> +
> +	p = (u8 *)ns_nid;
> +
> +	for (;;) {
> +		cur = (struct nvme_ns_nid *)p;
> +
> +		switch (cur->nidl) {
> +		case 0:
> +			return;
> +		case 8:
> +		case 16:
> +			break;
> +		default:
> +			dev_warn(ns->ctrl->dev,
> +				 "Target returned bogus Namespace Identification Descriptor length: %d\n",
> +				 cur->nidl);
> +			return;
> +
> +		}
> +
> +		switch (cur->nidt) {
> +		case NVME_NIDT_EUI64:
> +			len = 8;
> +			memcpy(ns->eui, cur->nid, len);
> +			break;
> +		case NVME_NIDT_NGUID:
> +			len = 16;
> +			memcpy(ns->nguid, cur->nid, len);
> +			break;
> +		case NVME_NIDT_UUID:
> +			len = 16;
> +			memcpy(ns->uuid, cur->nid, len);
> +			break;
> +		default:
> +			dev_warn(ns->ctrl->dev,
> +				 "Invalid Namespace Identification Descriptor Type: %d\n",
> +				 cur->nidt);
> +			return;
> +		}
> +
> +		pos += sizeof(struct nvme_ns_nid) + len;
> +		if (pos >= 4096)
> +			return;
> +		p += pos;
> +	}
> +}
> +
> +static int nvme_identify_ns_descs(struct nvme_ctrl *dev, unsigned nsid,
> +				  void *ns_nid)
> +{
> +	struct nvme_command c = { };
> +
> +	c.identify.opcode = nvme_admin_identify;
> +	c.identify.nsid = cpu_to_le32(nsid);
> +	c.identify.cns = NVME_ID_CNS_NS_DESC_LIST;
> +
> +	return nvme_submit_sync_cmd(dev->admin_q, &c, ns_nid, 4096);
> +}
> +
>  static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *ns_list)
>  {
>  	struct nvme_command c = { };
> @@ -1017,6 +1082,29 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
>  		memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
>  	if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
>  		memcpy(ns->nguid, (*id)->nguid, sizeof(ns->nguid));
> +	if (ns->ctrl->vs >= NVME_VS(1, 3, 0)) {
> +		void *ns_nid;
> +		int ret;
> +
> +
> +		ns_nid = kzalloc(4096, GFP_KERNEL);
> +		if (!ns_nid) {
> +			dev_warn(ns->ctrl->dev,
> +				 "%s: Identify Descriptors failed\n", __func__);
> +			return 0;
> +		}
> +
> +		ret = nvme_identify_ns_descs(ns->ctrl, ns->ns_id, ns_nid);
> +		if (ret) {
> +			dev_warn(ns->ctrl->dev,
> +				 "%s: Identify Descriptors failed\n", __func__);
> +			 /* Don't treat error as fatal we potentially
> +			  * already have a NGUID or EUI-64 */
> +			return 0;
> +		}
> +		nvme_parse_ns_descs(ns, ns_nid);
> +		kfree(ns_nid);
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 5004f0c41397..7007521e8194 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -190,6 +190,7 @@ struct nvme_ns {
>  
>  	u8 eui[8];
>  	u8 nguid[16];
> +	u8 uuid[16];
>  
>  	unsigned ns_id;
>  	int lba_shift;
> 
Personally, I don't like the dependency on version 1.3; especially
seeing that we're not supporting all 1.3 features (yet).

Meaning to test this we'd need to keep an additional out-of-tree patch,
which is not very appealing to me.

Maybe it's an idea to add another sysfs attribute to nvmet allowing us
to specify the version number? That would make life _so_ much easier.

But the patch itself is okay.

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 6/7] nvme: get list of namespace descriptors
@ 2017-05-30  8:30     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:30 UTC (permalink / raw)


On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> If a target identifies itself as NVMe 1.3 compliant, try to get the
> list of Namespace Identification Descriptors and populate the UUID,
> NGUID and EUI64 fileds in the NVMe namespace structure with these
> values.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/host/core.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/nvme/host/nvme.h |  1 +
>  2 files changed, 89 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 7b254be16887..d2365f7ea612 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -643,6 +643,71 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
>  	return error;
>  }
>  
> +static void nvme_parse_ns_descs(struct nvme_ns *ns, void *ns_nid)
> +{
> +	struct nvme_ns_nid *cur;
> +	const u8 *p;
> +	int pos = 0;
> +	int len;
> +
> +	p = (u8 *)ns_nid;
> +
> +	for (;;) {
> +		cur = (struct nvme_ns_nid *)p;
> +
> +		switch (cur->nidl) {
> +		case 0:
> +			return;
> +		case 8:
> +		case 16:
> +			break;
> +		default:
> +			dev_warn(ns->ctrl->dev,
> +				 "Target returned bogus Namespace Identification Descriptor length: %d\n",
> +				 cur->nidl);
> +			return;
> +
> +		}
> +
> +		switch (cur->nidt) {
> +		case NVME_NIDT_EUI64:
> +			len = 8;
> +			memcpy(ns->eui, cur->nid, len);
> +			break;
> +		case NVME_NIDT_NGUID:
> +			len = 16;
> +			memcpy(ns->nguid, cur->nid, len);
> +			break;
> +		case NVME_NIDT_UUID:
> +			len = 16;
> +			memcpy(ns->uuid, cur->nid, len);
> +			break;
> +		default:
> +			dev_warn(ns->ctrl->dev,
> +				 "Invalid Namespace Identification Descriptor Type: %d\n",
> +				 cur->nidt);
> +			return;
> +		}
> +
> +		pos += sizeof(struct nvme_ns_nid) + len;
> +		if (pos >= 4096)
> +			return;
> +		p += pos;
> +	}
> +}
> +
> +static int nvme_identify_ns_descs(struct nvme_ctrl *dev, unsigned nsid,
> +				  void *ns_nid)
> +{
> +	struct nvme_command c = { };
> +
> +	c.identify.opcode = nvme_admin_identify;
> +	c.identify.nsid = cpu_to_le32(nsid);
> +	c.identify.cns = NVME_ID_CNS_NS_DESC_LIST;
> +
> +	return nvme_submit_sync_cmd(dev->admin_q, &c, ns_nid, 4096);
> +}
> +
>  static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *ns_list)
>  {
>  	struct nvme_command c = { };
> @@ -1017,6 +1082,29 @@ static int nvme_revalidate_ns(struct nvme_ns *ns, struct nvme_id_ns **id)
>  		memcpy(ns->eui, (*id)->eui64, sizeof(ns->eui));
>  	if (ns->ctrl->vs >= NVME_VS(1, 2, 0))
>  		memcpy(ns->nguid, (*id)->nguid, sizeof(ns->nguid));
> +	if (ns->ctrl->vs >= NVME_VS(1, 3, 0)) {
> +		void *ns_nid;
> +		int ret;
> +
> +
> +		ns_nid = kzalloc(4096, GFP_KERNEL);
> +		if (!ns_nid) {
> +			dev_warn(ns->ctrl->dev,
> +				 "%s: Identify Descriptors failed\n", __func__);
> +			return 0;
> +		}
> +
> +		ret = nvme_identify_ns_descs(ns->ctrl, ns->ns_id, ns_nid);
> +		if (ret) {
> +			dev_warn(ns->ctrl->dev,
> +				 "%s: Identify Descriptors failed\n", __func__);
> +			 /* Don't treat error as fatal we potentially
> +			  * already have a NGUID or EUI-64 */
> +			return 0;
> +		}
> +		nvme_parse_ns_descs(ns, ns_nid);
> +		kfree(ns_nid);
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 5004f0c41397..7007521e8194 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -190,6 +190,7 @@ struct nvme_ns {
>  
>  	u8 eui[8];
>  	u8 nguid[16];
> +	u8 uuid[16];
>  
>  	unsigned ns_id;
>  	int lba_shift;
> 
Personally, I don't like the dependency on version 1.3; especially
seeing that we're not supporting all 1.3 features (yet).

Meaning to test this we'd need to keep an additional out-of-tree patch,
which is not very appealing to me.

Maybe it's an idea to add another sysfs attribute to nvmet allowing us
to specify the version number? That would make life _so_ much easier.

But the patch itself is okay.

Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 7/7] nvme: provide UUID value to userspace
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  8:31     ` Hannes Reinecke
  -1 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:31 UTC (permalink / raw)
  To: Johannes Thumshirn, Sagi Grimberg, Keith Busch, Christoph Hellwig
  Cc: Linux Kernel Mailinglist, Linux NVMe Mailinglist

On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Now that we have a way for getting the UUID from a target, provide it
> to userspace as well.
> 
> Unfortunately there is already a sysfs attribute called UUID which is
> a misnomer as it holds the NGUID value. So instead of creating yet
> another wrong name, create a new 'nguid' sysfs attribute for the
> NGUID. For the UUID attribute add a check wheter the namespace has a
> UUID assigned to it and return this or return the NGUID to maintain
> backwards compatibility. This should give userspace a chance to catch
> up.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/nvme/host/core.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 7/7] nvme: provide UUID value to userspace
@ 2017-05-30  8:31     ` Hannes Reinecke
  0 siblings, 0 replies; 56+ messages in thread
From: Hannes Reinecke @ 2017-05-30  8:31 UTC (permalink / raw)


On 05/30/2017 10:08 AM, Johannes Thumshirn wrote:
> Now that we have a way for getting the UUID from a target, provide it
> to userspace as well.
> 
> Unfortunately there is already a sysfs attribute called UUID which is
> a misnomer as it holds the NGUID value. So instead of creating yet
> another wrong name, create a new 'nguid' sysfs attribute for the
> NGUID. For the UUID attribute add a check wheter the namespace has a
> UUID assigned to it and return this or return the NGUID to maintain
> backwards compatibility. This should give userspace a chance to catch
> up.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
> ---
>  drivers/nvme/host/core.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke <hare at suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  9:24     ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:24 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Sagi Grimberg, Keith Busch, Christoph Hellwig,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

This should be stored as a uuid_t (or rather uuid_be in the current
kernel, but I'm about to rename it), and use uuid_be_to_bin / uuid_to_bin
for parsing.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
@ 2017-05-30  9:24     ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:24 UTC (permalink / raw)


This should be stored as a uuid_t (or rather uuid_be in the current
kernel, but I'm about to rename it), and use uuid_be_to_bin / uuid_to_bin
for parsing.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  9:25     ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:25 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Sagi Grimberg, Keith Busch, Christoph Hellwig,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

On Tue, May 30, 2017 at 10:08:18AM +0200, Johannes Thumshirn wrote:
> Add the EUI-64 field from the NVMe Namespace Identification Descriptor
> to the nvmet_ns structure and allow it's population via configfs.

Is there any good use case for bothering with this identifier that's
too short to actually be useful?

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
@ 2017-05-30  9:25     ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:25 UTC (permalink / raw)


On Tue, May 30, 2017@10:08:18AM +0200, Johannes Thumshirn wrote:
> Add the EUI-64 field from the NVMe Namespace Identification Descriptor
> to the nvmet_ns structure and allow it's population via configfs.

Is there any good use case for bothering with this identifier that's
too short to actually be useful?

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  9:27     ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:27 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Sagi Grimberg, Keith Busch, Christoph Hellwig,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

This should have had a nvmet: prefix, and probably be merged into the
previous patch.  But I don't really thing we should at it all, see
my previous comment.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report
@ 2017-05-30  9:27     ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:27 UTC (permalink / raw)


This should have had a nvmet: prefix, and probably be merged into the
previous patch.  But I don't really thing we should at it all, see
my previous comment.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 7/7] nvme: provide UUID value to userspace
  2017-05-30  8:08   ` Johannes Thumshirn
@ 2017-05-30  9:30     ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:30 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Sagi Grimberg, Keith Busch, Christoph Hellwig,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

On Tue, May 30, 2017 at 10:08:22AM +0200, Johannes Thumshirn wrote:
> Now that we have a way for getting the UUID from a target, provide it
> to userspace as well.
> 
> Unfortunately there is already a sysfs attribute called UUID which is
> a misnomer as it holds the NGUID value. So instead of creating yet
> another wrong name, create a new 'nguid' sysfs attribute for the
> NGUID. For the UUID attribute add a check wheter the namespace has a
> UUID assigned to it and return this or return the NGUID to maintain
> backwards compatibility. This should give userspace a chance to catch
> up.

Eww.  This looks pretty sketchy and at least needs a good comment in
the source.  Maybe even a printk_ratelimited warning.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 7/7] nvme: provide UUID value to userspace
@ 2017-05-30  9:30     ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-30  9:30 UTC (permalink / raw)


On Tue, May 30, 2017@10:08:22AM +0200, Johannes Thumshirn wrote:
> Now that we have a way for getting the UUID from a target, provide it
> to userspace as well.
> 
> Unfortunately there is already a sysfs attribute called UUID which is
> a misnomer as it holds the NGUID value. So instead of creating yet
> another wrong name, create a new 'nguid' sysfs attribute for the
> NGUID. For the UUID attribute add a check wheter the namespace has a
> UUID assigned to it and return this or return the NGUID to maintain
> backwards compatibility. This should give userspace a chance to catch
> up.

Eww.  This looks pretty sketchy and at least needs a good comment in
the source.  Maybe even a printk_ratelimited warning.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
  2017-05-30  9:25     ` Christoph Hellwig
@ 2017-05-30  9:45       ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  9:45 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, Linux NVMe Mailinglist,
	Linux Kernel Mailinglist

On 05/30/2017 11:25 AM, Christoph Hellwig wrote:
> On Tue, May 30, 2017 at 10:08:18AM +0200, Johannes Thumshirn wrote:
>> Add the EUI-64 field from the NVMe Namespace Identification Descriptor
>> to the nvmet_ns structure and allow it's population via configfs.
> 
> Is there any good use case for bothering with this identifier that's
> too short to actually be useful?

Mostly consistency. The current nvme host code has the EUI sprinkled all
around. Sure I can drop it, but then what's the point in evaluating it
on the host side? Other targets may send it, so we need in on the host
and do we care about potentially awkward host implementations with Linux
as a target? Also it's rather handy for testing as well, after all it's
not too much and complex code.
 --
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
@ 2017-05-30  9:45       ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  9:45 UTC (permalink / raw)


On 05/30/2017 11:25 AM, Christoph Hellwig wrote:
> On Tue, May 30, 2017@10:08:18AM +0200, Johannes Thumshirn wrote:
>> Add the EUI-64 field from the NVMe Namespace Identification Descriptor
>> to the nvmet_ns structure and allow it's population via configfs.
> 
> Is there any good use case for bothering with this identifier that's
> too short to actually be useful?

Mostly consistency. The current nvme host code has the EUI sprinkled all
around. Sure I can drop it, but then what's the point in evaluating it
on the host side? Other targets may send it, so we need in on the host
and do we care about potentially awkward host implementations with Linux
as a target? Also it's rather handy for testing as well, after all it's
not too much and complex code.
 --
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
  2017-05-30  9:24     ` Christoph Hellwig
@ 2017-05-30  9:48       ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  9:48 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, Linux NVMe Mailinglist,
	Linux Kernel Mailinglist

On 05/30/2017 11:24 AM, Christoph Hellwig wrote:
> This should be stored as a uuid_t (or rather uuid_be in the current
> kernel, but I'm about to rename it), and use uuid_be_to_bin / uuid_to_bin
> for parsing.

OK, thought you ask me to do that. Which one do you prefer?

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
@ 2017-05-30  9:48       ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30  9:48 UTC (permalink / raw)


On 05/30/2017 11:24 AM, Christoph Hellwig wrote:
> This should be stored as a uuid_t (or rather uuid_be in the current
> kernel, but I'm about to rename it), and use uuid_be_to_bin / uuid_to_bin
> for parsing.

OK, thought you ask me to do that. Which one do you prefer?

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 7/7] nvme: provide UUID value to userspace
  2017-05-30  9:30     ` Christoph Hellwig
@ 2017-05-30 10:23       ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30 10:23 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, Linux NVMe Mailinglist,
	Linux Kernel Mailinglist

On 05/30/2017 11:30 AM, Christoph Hellwig wrote:
> Eww.  This looks pretty sketchy and at least needs a good comment in
> the source.  Maybe even a printk_ratelimited warning.

Comment sure, but do we really need a warning?


-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 7/7] nvme: provide UUID value to userspace
@ 2017-05-30 10:23       ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30 10:23 UTC (permalink / raw)


On 05/30/2017 11:30 AM, Christoph Hellwig wrote:
> Eww.  This looks pretty sketchy and at least needs a good comment in
> the source.  Maybe even a printk_ratelimited warning.

Comment sure, but do we really need a warning?


-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 5/7] nvmet: implement namespace identify descriptor list
  2017-05-30  8:08   ` Johannes Thumshirn
  (?)
  (?)
@ 2017-05-30 11:04   ` Max Gurtovoy
  2017-05-30 14:20     ` Johannes Thumshirn
  -1 siblings, 1 reply; 56+ messages in thread
From: Max Gurtovoy @ 2017-05-30 11:04 UTC (permalink / raw)


Hi Johannes,

On 5/30/2017 11:08 AM, 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 | 75 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/nvme.h            | 14 ++++++++
>  2 files changed, 89 insertions(+)
>
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 60c9eec57986..2290301a6172 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -368,6 +368,78 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
>  	nvmet_req_complete(req, status);
>  }
>
> +static void nvmet_execute_identify_desclist(struct nvmet_req *req)
> +{
> +	static const int buf_size = 4069;

Shouldn't it be 4096 ?

> +	struct nvmet_ns *ns;
> +	struct nvme_ns_nid *ns_nid;
> +	u8 *nid_list;
> +	u16 status = 0;
> +	int pos = 0;
> +	const u8 *p;
> +
> +	ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
> +	if (!ns) {
> +		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
> +		goto out;
> +	}
> +
> +	nid_list = kzalloc(buf_size, GFP_KERNEL);
> +	if (!nid_list) {
> +		status = NVME_SC_INTERNAL;
> +		goto out_put_ns;
> +	}
> +
> +	p = nid_list;
> +
> +	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 = 16;

maybe define NVME_NIDT_UUID_LEN instead of 16 ?
this way you can use it in the host side too.

> +		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;
> +	}
> +	if (memchr_inv(ns->nguid, 0, sizeof(ns->nguid))) {
> +		ns_nid = (struct nvme_ns_nid *)p;
> +		ns_nid->nidt = NVME_NIDT_NGUID;
> +		ns_nid->nidl = 16;

see above comment.

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

see above.

> +		memcpy(&ns_nid->nid, &ns->eui64, sizeof(ns->eui64));
> +		pos += sizeof(struct nvme_ns_nid) + sizeof(ns->eui64);
> +		if (pos > buf_size) {
> +			status = NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
> +			goto out_free_nid_list;
> +		}
> +		p += pos;
> +	}
> +
> +	status = nvmet_copy_to_sgl(req, 0, nid_list, buf_size);
> +
> +out_free_nid_list:
> +	kfree(nid_list);
> +
> +out_put_ns:
> +	nvmet_put_namespace(ns);
> +out:
> +	nvmet_req_complete(req, status);
> +}
> +
>  /*
>   * A "mimimum viable" abort implementation: the command is mandatory in the
>   * spec, but we are not required to do any useful work.  We couldn't really
> @@ -516,6 +588,9 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
>  		case NVME_ID_CNS_NS_ACTIVE_LIST:
>  			req->execute = nvmet_execute_identify_nslist;
>  			return 0;
> +		case NVME_ID_CNS_NS_DESC_LIST:
> +			req->execute = nvmet_execute_identify_desclist;
> +			return 0;
>  		}
>  		break;
>  	case nvme_admin_abort_cmd:
> diff --git a/include/linux/nvme.h b/include/linux/nvme.h
> index b625bacf37ef..cad0e19f0bba 100644
> --- a/include/linux/nvme.h
> +++ b/include/linux/nvme.h
> @@ -288,6 +288,7 @@ enum {
>  	NVME_ID_CNS_NS			= 0x00,
>  	NVME_ID_CNS_CTRL		= 0x01,
>  	NVME_ID_CNS_NS_ACTIVE_LIST	= 0x02,
> +	NVME_ID_CNS_NS_DESC_LIST	= 0x03,
>  	NVME_ID_CNS_NS_PRESENT_LIST	= 0x10,
>  	NVME_ID_CNS_NS_PRESENT		= 0x11,
>  	NVME_ID_CNS_CTRL_NS_LIST	= 0x12,
> @@ -314,6 +315,19 @@ enum {
>  	NVME_NS_DPS_PI_TYPE3	= 3,
>  };
>
> +struct nvme_ns_nid {
> +	__u8 nidt;
> +	__u8 nidl;
> +	__le16 reserved;
> +	__u8 nid[0];
> +};
> +
> +enum {
> +	NVME_NIDT_EUI64		= 0x01,
> +	NVME_NIDT_NGUID		= 0x02,
> +	NVME_NIDT_UUID		= 0x03,
> +};
> +
>  struct nvme_smart_log {
>  	__u8			critical_warning;
>  	__u8			temperature[2];
>

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 5/7] nvmet: implement namespace identify descriptor list
  2017-05-30 11:04   ` Max Gurtovoy
@ 2017-05-30 14:20     ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-30 14:20 UTC (permalink / raw)


On 05/30/2017 01:04 PM, Max Gurtovoy wrote:
>> +static void nvmet_execute_identify_desclist(struct nvmet_req *req)
>> +{
>> +    static const int buf_size = 4069;
> 
> Shouldn't it be 4096 ?
> 

Good catch, thanks. Should probably change all to SZ_4K.

[...]

>> +    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 = 16;
> 
> maybe define NVME_NIDT_UUID_LEN instead of 16 ?
> this way you can use it in the host side too.
> 

Good point, will do in v2.


-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 0/7] Implement NVMe Namespace Descriptor Identification
  2017-05-30  8:08 ` Johannes Thumshirn
@ 2017-05-31  9:43   ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-31  9:43 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Sagi Grimberg, Keith Busch, Christoph Hellwig,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

On Tue, May 30, 2017 at 10:08:15AM +0200, Johannes Thumshirn wrote:
> A patch for nvmetcli will follow shortly.

Thanks.  No really required but nice would be a nvme-cli subcommand
to read the values as well.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 0/7] Implement NVMe Namespace Descriptor Identification
@ 2017-05-31  9:43   ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-31  9:43 UTC (permalink / raw)


On Tue, May 30, 2017@10:08:15AM +0200, Johannes Thumshirn wrote:
> A patch for nvmetcli will follow shortly.

Thanks.  No really required but nice would be a nvme-cli subcommand
to read the values as well.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
  2017-05-30  9:48       ` Johannes Thumshirn
@ 2017-05-31  9:45         ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-31  9:45 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

On Tue, May 30, 2017 at 11:48:09AM +0200, Johannes Thumshirn wrote:
> On 05/30/2017 11:24 AM, Christoph Hellwig wrote:
> > This should be stored as a uuid_t (or rather uuid_be in the current
> > kernel, but I'm about to rename it), and use uuid_be_to_bin / uuid_to_bin
> > for parsing.
> 
> OK, thought you ask me to do that. Which one do you prefer?

I think you'll have to use the old names, unless we get the uuid
changes stabilized soon and can pull the branch for it into the
nvme / block tree.  So go with those for now, and I'll do any
after the fact cleanup later.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs
@ 2017-05-31  9:45         ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-31  9:45 UTC (permalink / raw)


On Tue, May 30, 2017@11:48:09AM +0200, Johannes Thumshirn wrote:
> On 05/30/2017 11:24 AM, Christoph Hellwig wrote:
> > This should be stored as a uuid_t (or rather uuid_be in the current
> > kernel, but I'm about to rename it), and use uuid_be_to_bin / uuid_to_bin
> > for parsing.
> 
> OK, thought you ask me to do that. Which one do you prefer?

I think you'll have to use the old names, unless we get the uuid
changes stabilized soon and can pull the branch for it into the
nvme / block tree.  So go with those for now, and I'll do any
after the fact cleanup later.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
  2017-05-30  9:45       ` Johannes Thumshirn
@ 2017-05-31  9:46         ` Christoph Hellwig
  -1 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-31  9:46 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
	Linux NVMe Mailinglist, Linux Kernel Mailinglist

On Tue, May 30, 2017 at 11:45:25AM +0200, Johannes Thumshirn wrote:
> Mostly consistency. The current nvme host code has the EUI sprinkled all
> around. Sure I can drop it, but then what's the point in evaluating it
> on the host side? Other targets may send it, so we need in on the host
> and do we care about potentially awkward host implementations with Linux
> as a target? Also it's rather handy for testing as well, after all it's
> not too much and complex code.

There's only one place in the host code proper (discounting the
scsi translation mess), and that's because the field is still better
than not having any uniqueue identifier.  But I don't think we should
spread it any further.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
@ 2017-05-31  9:46         ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2017-05-31  9:46 UTC (permalink / raw)


On Tue, May 30, 2017@11:45:25AM +0200, Johannes Thumshirn wrote:
> Mostly consistency. The current nvme host code has the EUI sprinkled all
> around. Sure I can drop it, but then what's the point in evaluating it
> on the host side? Other targets may send it, so we need in on the host
> and do we care about potentially awkward host implementations with Linux
> as a target? Also it's rather handy for testing as well, after all it's
> not too much and complex code.

There's only one place in the host code proper (discounting the
scsi translation mess), and that's because the field is still better
than not having any uniqueue identifier.  But I don't think we should
spread it any further.

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 0/7] Implement NVMe Namespace Descriptor Identification
  2017-05-31  9:43   ` Christoph Hellwig
@ 2017-05-31 11:22     ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-31 11:22 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, Linux NVMe Mailinglist,
	Linux Kernel Mailinglist

On 05/31/2017 11:43 AM, Christoph Hellwig wrote:
> On Tue, May 30, 2017 at 10:08:15AM +0200, Johannes Thumshirn wrote:
>> A patch for nvmetcli will follow shortly.
> 
> Thanks.  No really required but nice would be a nvme-cli subcommand
> to read the values as well.

Yes, together with other fabric specifics. I have a customer request for
it as well, just didn't have the time to do so yet.

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 0/7] Implement NVMe Namespace Descriptor Identification
@ 2017-05-31 11:22     ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-31 11:22 UTC (permalink / raw)


On 05/31/2017 11:43 AM, Christoph Hellwig wrote:
> On Tue, May 30, 2017@10:08:15AM +0200, Johannes Thumshirn wrote:
>> A patch for nvmetcli will follow shortly.
> 
> Thanks.  No really required but nice would be a nvme-cli subcommand
> to read the values as well.

Yes, together with other fabric specifics. I have a customer request for
it as well, just didn't have the time to do so yet.

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
  2017-05-31  9:46         ` Christoph Hellwig
@ 2017-05-31 11:24           ` Johannes Thumshirn
  -1 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-31 11:24 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Sagi Grimberg, Keith Busch, Linux NVMe Mailinglist,
	Linux Kernel Mailinglist

On 05/31/2017 11:46 AM, Christoph Hellwig wrote:
> On Tue, May 30, 2017 at 11:45:25AM +0200, Johannes Thumshirn wrote:
>> Mostly consistency. The current nvme host code has the EUI sprinkled all
>> around. Sure I can drop it, but then what's the point in evaluating it
>> on the host side? Other targets may send it, so we need in on the host
>> and do we care about potentially awkward host implementations with Linux
>> as a target? Also it's rather handy for testing as well, after all it's
>> not too much and complex code.
> 
> There's only one place in the host code proper (discounting the
> scsi translation mess), and that's because the field is still better
> than not having any uniqueue identifier.  But I don't think we should
> spread it any further.

OK I'll drop it in my next re-send (which should hopefully be somewhen
today)

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 3/7] nvmet: add eui64 field to nvme_ns and populate via configfs
@ 2017-05-31 11:24           ` Johannes Thumshirn
  0 siblings, 0 replies; 56+ messages in thread
From: Johannes Thumshirn @ 2017-05-31 11:24 UTC (permalink / raw)


On 05/31/2017 11:46 AM, Christoph Hellwig wrote:
> On Tue, May 30, 2017@11:45:25AM +0200, Johannes Thumshirn wrote:
>> Mostly consistency. The current nvme host code has the EUI sprinkled all
>> around. Sure I can drop it, but then what's the point in evaluating it
>> on the host side? Other targets may send it, so we need in on the host
>> and do we care about potentially awkward host implementations with Linux
>> as a target? Also it's rather handy for testing as well, after all it's
>> not too much and complex code.
> 
> There's only one place in the host code proper (discounting the
> scsi translation mess), and that's because the field is still better
> than not having any uniqueue identifier.  But I don't think we should
> spread it any further.

OK I'll drop it in my next re-send (which should hopefully be somewhen
today)

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2017-05-31 11:24 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30  8:08 [PATCH 0/7] Implement NVMe Namespace Descriptor Identification Johannes Thumshirn
2017-05-30  8:08 ` Johannes Thumshirn
2017-05-30  8:08 ` [PATCH 1/7] nvme: rename uuid to nguid in nvme_ns Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:18   ` Hannes Reinecke
2017-05-30  8:18     ` Hannes Reinecke
2017-05-30  8:08 ` [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:20   ` Hannes Reinecke
2017-05-30  8:20     ` Hannes Reinecke
2017-05-30  9:24   ` Christoph Hellwig
2017-05-30  9:24     ` Christoph Hellwig
2017-05-30  9:48     ` Johannes Thumshirn
2017-05-30  9:48       ` Johannes Thumshirn
2017-05-31  9:45       ` Christoph Hellwig
2017-05-31  9:45         ` Christoph Hellwig
2017-05-30  8:08 ` [PATCH 3/7] nvmet: add eui64 " Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:21   ` Hannes Reinecke
2017-05-30  8:21     ` Hannes Reinecke
2017-05-30  9:25   ` Christoph Hellwig
2017-05-30  9:25     ` Christoph Hellwig
2017-05-30  9:45     ` Johannes Thumshirn
2017-05-30  9:45       ` Johannes Thumshirn
2017-05-31  9:46       ` Christoph Hellwig
2017-05-31  9:46         ` Christoph Hellwig
2017-05-31 11:24         ` Johannes Thumshirn
2017-05-31 11:24           ` Johannes Thumshirn
2017-05-30  8:08 ` [PATCH 4/7] nvme: also report include the EUI-64 in identify NS report Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:22   ` Hannes Reinecke
2017-05-30  8:22     ` Hannes Reinecke
2017-05-30  9:27   ` Christoph Hellwig
2017-05-30  9:27     ` Christoph Hellwig
2017-05-30  8:08 ` [PATCH 5/7] nvmet: implement namespace identify descriptor list Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:24   ` Hannes Reinecke
2017-05-30  8:24     ` Hannes Reinecke
2017-05-30 11:04   ` Max Gurtovoy
2017-05-30 14:20     ` Johannes Thumshirn
2017-05-30  8:08 ` [PATCH 6/7] nvme: get list of namespace descriptors Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:30   ` Hannes Reinecke
2017-05-30  8:30     ` Hannes Reinecke
2017-05-30  8:08 ` [PATCH 7/7] nvme: provide UUID value to userspace Johannes Thumshirn
2017-05-30  8:08   ` Johannes Thumshirn
2017-05-30  8:31   ` Hannes Reinecke
2017-05-30  8:31     ` Hannes Reinecke
2017-05-30  9:30   ` Christoph Hellwig
2017-05-30  9:30     ` Christoph Hellwig
2017-05-30 10:23     ` Johannes Thumshirn
2017-05-30 10:23       ` Johannes Thumshirn
2017-05-31  9:43 ` [PATCH 0/7] Implement NVMe Namespace Descriptor Identification Christoph Hellwig
2017-05-31  9:43   ` Christoph Hellwig
2017-05-31 11:22   ` Johannes Thumshirn
2017-05-31 11:22     ` Johannes Thumshirn

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.