Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1659624

[PATCH v6 06/10] nvmet: add uuid field to nvme_ns and populate via configfs

From Johannes Thumshirn <jthumshirn@suse.de>
Newsgroups linux.kernel
Subject [PATCH v6 06/10] nvmet: add uuid field to nvme_ns and populate via configfs
Date 2017-06-07 11:50 +0200
Message-ID <tPFLc-4SX-43@gated-at.bofh.it> (permalink)
References <tPFLb-4SX-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View 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@suse.de>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.com>
---
 drivers/nvme/target/configfs.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index be8c800078e2..83bfe28fe7da 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -305,11 +305,41 @@ 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;
+	int ret = 0;
+
+
+	mutex_lock(&subsys->lock);
+	if (ns->enabled) {
+		ret = -EBUSY;
+		goto out_unlock;
+	}
+
+
+	if (uuid_parse(page, &ns->uuid))
+		ret = -EINVAL;
+
+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 +409,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,
 };
-- 
2.12.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 00/10] Implement NVMe Namespace Descriptor Identification Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-07 11:50 +0200
  [PATCH v6 09/10] nvmet: allow overriding the NVMe VS via configfs Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-07 11:50 +0200
    Re: [PATCH v6 09/10] nvmet: allow overriding the NVMe VS via         configfs Christoph Hellwig <hch@lst.de> - 2017-06-08 09:50 +0200
  [PATCH v6 03/10] nvme: introduce NVMe Namespace Identification Descriptor structures Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-07 11:50 +0200
    Re: [PATCH v6 03/10] nvme: introduce NVMe Namespace Identification         Descriptor structures Christoph Hellwig <hch@lst.de> - 2017-06-08 09:50 +0200
  [PATCH v6 05/10] nvmet: implement namespace identify descriptor list Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-07 11:50 +0200
    Re: [PATCH v6 05/10] nvmet: implement namespace identify descriptor  list Sagi Grimberg <sagi@grimberg.me> - 2017-06-07 12:00 +0200
    Re: [PATCH v6 05/10] nvmet: implement namespace identify         descriptor list Christoph Hellwig <hch@lst.de> - 2017-06-08 09:50 +0200
      Re: [PATCH v6 05/10] nvmet: implement namespace identify descriptor  list Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-08 09:50 +0200
        Re: [PATCH v6 05/10] nvmet: implement namespace identify descriptor  list Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-08 10:00 +0200
          Re: [PATCH v6 05/10] nvmet: implement namespace identify         descriptor list Christoph Hellwig <hch@lst.de> - 2017-06-08 10:00 +0200
        Re: [PATCH v6 05/10] nvmet: implement namespace identify         descriptor list Christoph Hellwig <hch@lst.de> - 2017-06-08 10:00 +0200
          Re: [PATCH v6 05/10] nvmet: implement namespace identify         descriptor list Christoph Hellwig <hch@lst.de> - 2017-06-12 18:20 +0200
  [PATCH v6 06/10] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-07 11:50 +0200
    Re: [PATCH v6 06/10] nvmet: add uuid field to nvme_ns and populate         via configfs Christoph Hellwig <hch@lst.de> - 2017-06-08 09:50 +0200
  [PATCH v6 07/10] nvme: get list of namespace descriptors Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-07 11:50 +0200
    Re: [PATCH v6 07/10] nvme: get list of namespace descriptors Christoph Hellwig <hch@lst.de> - 2017-06-08 09:50 +0200
  Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor         Identification Christoph Hellwig <hch@lst.de> - 2017-06-15 18:40 +0200
    Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor  Identification Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-16 10:30 +0200
      Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor         Identification Christoph Hellwig <hch@lst.de> - 2017-06-16 11:50 +0200
        Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor  Identification Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-16 11:50 +0200
          Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor  Identification Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-16 12:00 +0200
          Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor         Identification Christoph Hellwig <hch@lst.de> - 2017-06-16 12:00 +0200
            Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor Identification Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-16 15:30 +0200

csiph-web