Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1652919 > unrolled thread
| Started by | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| First post | 2017-05-30 10:10 +0200 |
| Last post | 2017-05-31 11:50 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn <jthumshirn@suse.de> - 2017-05-30 10:10 +0200
Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Hannes Reinecke <hare@suse.de> - 2017-05-30 10:30 +0200
Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Christoph Hellwig <hch@lst.de> - 2017-05-30 11:30 +0200
Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn <jthumshirn@suse.de> - 2017-05-30 11:50 +0200
Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs Christoph Hellwig <hch@lst.de> - 2017-05-31 11:50 +0200
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2017-05-30 10:10 +0200 |
| Subject | [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs |
| Message-ID | <tMKo1-4Kd-1@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Hannes Reinecke <hare@suse.de> |
|---|---|
| Date | 2017-05-30 10:30 +0200 |
| Subject | Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs |
| Message-ID | <tMKHo-4SA-25@gated-at.bofh.it> |
| In reply to | #1652919 |
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)
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-30 11:30 +0200 |
| Subject | Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs |
| Message-ID | <tMLDt-5ux-47@gated-at.bofh.it> |
| In reply to | #1652919 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2017-05-30 11:50 +0200 |
| Subject | Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs |
| Message-ID | <tMLWO-5BU-33@gated-at.bofh.it> |
| In reply to | #1653030 |
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
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-31 11:50 +0200 |
| Subject | Re: [PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs |
| Message-ID | <tN8ql-31c-7@gated-at.bofh.it> |
| In reply to | #1653052 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web