linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers
@ 2020-02-08  1:13 Sagi Grimberg
  2020-02-08  1:13 ` [PATCH v2 2/2] nvme: expose hostid " Sagi Grimberg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sagi Grimberg @ 2020-02-08  1:13 UTC (permalink / raw)
  To: linux-nvme, Keith Busch, Christoph Hellwig

We allow userspace to connect with a custom hostnqn which
is useful for certain use-cases. however there is is no way
to tell what is the hostnqn used to connect to a given controller.

Expose this so userspace can correlate controllers based on hostnqn.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
Changes from v1:
- fix changelog
 drivers/nvme/host/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 5dc32b72e7fa..29a4f14360fa 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3242,6 +3242,16 @@ static ssize_t nvme_sysfs_show_subsysnqn(struct device *dev,
 }
 static DEVICE_ATTR(subsysnqn, S_IRUGO, nvme_sysfs_show_subsysnqn, NULL);
 
+static ssize_t nvme_sysfs_show_hostnqn(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", ctrl->opts->host->nqn);
+}
+static DEVICE_ATTR(hostnqn, S_IRUGO, nvme_sysfs_show_hostnqn, NULL);
+
 static ssize_t nvme_sysfs_show_address(struct device *dev,
 					 struct device_attribute *attr,
 					 char *buf)
@@ -3267,6 +3277,7 @@ static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_numa_node.attr,
 	&dev_attr_queue_count.attr,
 	&dev_attr_sqsize.attr,
+	&dev_attr_hostnqn.attr,
 	NULL
 };
 
@@ -3280,6 +3291,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
 		return 0;
 	if (a == &dev_attr_address.attr && !ctrl->ops->get_address)
 		return 0;
+	if (a == &dev_attr_hostnqn.attr && (!ctrl->opts))
+		return 0;
 
 	return a->mode;
 }
-- 
2.20.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* [PATCH v2 2/2] nvme: expose hostid via sysfs for fabrics controllers
  2020-02-08  1:13 [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers Sagi Grimberg
@ 2020-02-08  1:13 ` Sagi Grimberg
  2020-02-09 23:56   ` Chaitanya Kulkarni
  2020-02-19 15:10   ` Christoph Hellwig
  2020-02-09 23:55 ` [PATCH v2 1/2] nvme: expose hostnqn " Chaitanya Kulkarni
  2020-02-19 15:09 ` Christoph Hellwig
  2 siblings, 2 replies; 6+ messages in thread
From: Sagi Grimberg @ 2020-02-08  1:13 UTC (permalink / raw)
  To: linux-nvme, Keith Busch, Christoph Hellwig

We allow userspace to connect with a custom hostid which
is useful for certain use-cases. however there is is no way
to tell what is the hostid used to connect to a given controller.

Expose this so userspace can correlate controllers based on hostid.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
Changes from v1:
- fix changelog
 drivers/nvme/host/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 29a4f14360fa..c2aba7d700ff 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3252,6 +3252,16 @@ static ssize_t nvme_sysfs_show_hostnqn(struct device *dev,
 }
 static DEVICE_ATTR(hostnqn, S_IRUGO, nvme_sysfs_show_hostnqn, NULL);
 
+static ssize_t nvme_sysfs_show_hostid(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+
+	return snprintf(buf, PAGE_SIZE, "%pU\n", &ctrl->opts->host->id);
+}
+static DEVICE_ATTR(hostid, S_IRUGO, nvme_sysfs_show_hostid, NULL);
+
 static ssize_t nvme_sysfs_show_address(struct device *dev,
 					 struct device_attribute *attr,
 					 char *buf)
@@ -3278,6 +3288,7 @@ static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_queue_count.attr,
 	&dev_attr_sqsize.attr,
 	&dev_attr_hostnqn.attr,
+	&dev_attr_hostid.attr,
 	NULL
 };
 
@@ -3293,6 +3304,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
 		return 0;
 	if (a == &dev_attr_hostnqn.attr && (!ctrl->opts))
 		return 0;
+	if (a == &dev_attr_hostid.attr && (!ctrl->opts))
+		return 0;
 
 	return a->mode;
 }
-- 
2.20.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers
  2020-02-08  1:13 [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers Sagi Grimberg
  2020-02-08  1:13 ` [PATCH v2 2/2] nvme: expose hostid " Sagi Grimberg
@ 2020-02-09 23:55 ` Chaitanya Kulkarni
  2020-02-19 15:09 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-09 23:55 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, Keith Busch, Christoph Hellwig

On 02/07/2020 05:14 PM, Sagi Grimberg wrote:
> We allow userspace to connect with a custom hostnqn which
> is useful for certain use-cases. however there is is no way
nit :- can be done when applying patch.
's/however/However/'
> to tell what is the hostnqn used to connect to a given controller.
>
> Expose this so userspace can correlate controllers based on hostnqn.
>
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

With small comment.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH v2 2/2] nvme: expose hostid via sysfs for fabrics controllers
  2020-02-08  1:13 ` [PATCH v2 2/2] nvme: expose hostid " Sagi Grimberg
@ 2020-02-09 23:56   ` Chaitanya Kulkarni
  2020-02-19 15:10   ` Christoph Hellwig
  1 sibling, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-09 23:56 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, Keith Busch, Christoph Hellwig

On 02/07/2020 05:14 PM, Sagi Grimberg wrote:
> We allow userspace to connect with a custom hostid which
> is useful for certain use-cases. however there is is no way
Same here :- 's/however/However'. 's/is is/is/'.
> to tell what is the hostid used to connect to a given controller.
>
> Expose this so userspace can correlate controllers based on hostid.
>
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers
  2020-02-08  1:13 [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers Sagi Grimberg
  2020-02-08  1:13 ` [PATCH v2 2/2] nvme: expose hostid " Sagi Grimberg
  2020-02-09 23:55 ` [PATCH v2 1/2] nvme: expose hostnqn " Chaitanya Kulkarni
@ 2020-02-19 15:09 ` Christoph Hellwig
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2020-02-19 15:09 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Keith Busch, Christoph Hellwig, linux-nvme

On Fri, Feb 07, 2020 at 05:13:53PM -0800, Sagi Grimberg wrote:
> We allow userspace to connect with a custom hostnqn which
> is useful for certain use-cases. however there is is no way
> to tell what is the hostnqn used to connect to a given controller.
> 
> Expose this so userspace can correlate controllers based on hostnqn.
> 
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
> Changes from v1:
> - fix changelog
>  drivers/nvme/host/core.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 5dc32b72e7fa..29a4f14360fa 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3242,6 +3242,16 @@ static ssize_t nvme_sysfs_show_subsysnqn(struct device *dev,
>  }
>  static DEVICE_ATTR(subsysnqn, S_IRUGO, nvme_sysfs_show_subsysnqn, NULL);
>  
> +static ssize_t nvme_sysfs_show_hostnqn(struct device *dev,
> +					struct device_attribute *attr,
> +					char *buf)
> +{
> +	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
> +
> +	return snprintf(buf, PAGE_SIZE, "%s\n", ctrl->opts->host->nqn);
> +}
> +static DEVICE_ATTR(hostnqn, S_IRUGO, nvme_sysfs_show_hostnqn, NULL);
> +
>  static ssize_t nvme_sysfs_show_address(struct device *dev,
>  					 struct device_attribute *attr,
>  					 char *buf)
> @@ -3267,6 +3277,7 @@ static struct attribute *nvme_dev_attrs[] = {
>  	&dev_attr_numa_node.attr,
>  	&dev_attr_queue_count.attr,
>  	&dev_attr_sqsize.attr,
> +	&dev_attr_hostnqn.attr,
>  	NULL
>  };
>  
> @@ -3280,6 +3291,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
>  		return 0;
>  	if (a == &dev_attr_address.attr && !ctrl->ops->get_address)
>  		return 0;
> +	if (a == &dev_attr_hostnqn.attr && (!ctrl->opts))

No nee for the inner braces here.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH v2 2/2] nvme: expose hostid via sysfs for fabrics controllers
  2020-02-08  1:13 ` [PATCH v2 2/2] nvme: expose hostid " Sagi Grimberg
  2020-02-09 23:56   ` Chaitanya Kulkarni
@ 2020-02-19 15:10   ` Christoph Hellwig
  1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2020-02-19 15:10 UTC (permalink / raw)
  To: Sagi Grimberg; +Cc: Keith Busch, Christoph Hellwig, linux-nvme

On Fri, Feb 07, 2020 at 05:13:54PM -0800, Sagi Grimberg wrote:
> @@ -3293,6 +3304,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
>  		return 0;
>  	if (a == &dev_attr_hostnqn.attr && (!ctrl->opts))
>  		return 0;
> +	if (a == &dev_attr_hostid.attr && (!ctrl->opts))
> +		return 0;

No need for the braces either.

Otherwise:

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

end of thread, other threads:[~2020-02-19 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-08  1:13 [PATCH v2 1/2] nvme: expose hostnqn via sysfs for fabrics controllers Sagi Grimberg
2020-02-08  1:13 ` [PATCH v2 2/2] nvme: expose hostid " Sagi Grimberg
2020-02-09 23:56   ` Chaitanya Kulkarni
2020-02-19 15:10   ` Christoph Hellwig
2020-02-09 23:55 ` [PATCH v2 1/2] nvme: expose hostnqn " Chaitanya Kulkarni
2020-02-19 15:09 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).