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


Groups > linux.kernel > #1659619

[PATCH v6 09/10] nvmet: allow overriding the NVMe VS via configfs

From Johannes Thumshirn <jthumshirn@suse.de>
Newsgroups linux.kernel
Subject [PATCH v6 09/10] nvmet: allow overriding the NVMe VS via configfs
Date 2017-06-07 11:50 +0200
Message-ID <tPFLc-4SX-33@gated-at.bofh.it> (permalink)
References <tPFLb-4SX-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Allow overriding the announced NVMe Version of a via configfs.

This is particularly helpful when debugging new features for the host
or target side without bumping the hard coded version (as the target
might not be fully compliant to the announced version yet).

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Guan Junxiong <guanjunxiong@huawei.com>
---
 drivers/nvme/target/configfs.c | 37 +++++++++++++++++++++++++++++++++++++
 include/linux/nvme.h           |  4 ++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 83bfe28fe7da..a358ecd93e11 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -650,8 +650,45 @@ static ssize_t nvmet_subsys_attr_allow_any_host_store(struct config_item *item,
 
 CONFIGFS_ATTR(nvmet_subsys_, attr_allow_any_host);
 
+static ssize_t nvmet_subsys_version_show(struct config_item *item,
+					      char *page)
+{
+	struct nvmet_subsys *subsys = to_subsys(item);
+
+	if (NVME_TERTIARY(subsys->ver))
+		return snprintf(page, PAGE_SIZE, "%d.%d.%d\n",
+				(int)NVME_MAJOR(subsys->ver),
+				(int)NVME_MINOR(subsys->ver),
+				(int)NVME_TERTIARY(subsys->ver));
+	else
+		return snprintf(page, PAGE_SIZE, "%d.%d\n",
+				(int)NVME_MAJOR(subsys->ver),
+				(int)NVME_MINOR(subsys->ver));
+}
+
+static ssize_t nvmet_subsys_version_store(struct config_item *item,
+					       const char *page, size_t count)
+{
+	struct nvmet_subsys *subsys = to_subsys(item);
+	int major, minor, tertiary = 0;
+	int ret;
+
+
+	ret = sscanf(page, "%d.%d.%d\n", &major, &minor, &tertiary);
+	if (ret != 2 && ret != 3)
+		return -EINVAL;
+
+	down_write(&nvmet_config_sem);
+	subsys->ver = NVME_VS(major, minor, tertiary);
+	up_write(&nvmet_config_sem);
+
+	return count;
+}
+CONFIGFS_ATTR(nvmet_subsys_, version);
+
 static struct configfs_attribute *nvmet_subsys_attrs[] = {
 	&nvmet_subsys_attr_attr_allow_any_host,
+	&nvmet_subsys_attr_version,
 	NULL,
 };
 
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 01d75c2b32a6..350c32fca1f5 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1070,4 +1070,8 @@ struct nvme_completion {
 #define NVME_VS(major, minor, tertiary) \
 	(((major) << 16) | ((minor) << 8) | (tertiary))
 
+#define NVME_MAJOR(ver)		((ver) >> 16)
+#define NVME_MINOR(ver)		(((ver) >> 8) & 0xff)
+#define NVME_TERTIARY(ver)	((ver) & 0xff)
+
 #endif /* _LINUX_NVME_H */
-- 
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