nvme: expose hostnqn via sysfs for fabrics controllers
Sagi Grimberg
maintainerPATCH v2 1/2 nvme: expose hostnqn via sysfs for fabrics controllers
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.
---
Changes from v1:
- fix changelog
drivers/nvme/host/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/nvme/host/core.c +13 -0
@@ -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; }
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerPATCH v2 2/2 nvme: expose hostid via sysfs for fabrics controllers
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.
---
Changes from v1:
- fix changelog
drivers/nvme/host/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/nvme/host/core.c +13 -0
@@ -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; }
Signature · 7 lines
2.20.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH v2 2/2] nvme: expose hostid via sysfs for fabrics controllers
Quoted 2 lines · Sagi Grimberg
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/'.
Quoted 5 lines
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<[email protected]>
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH v2 2/2] nvme: expose hostid via sysfs for fabrics controllers
In reply to Sagi Grimbergdrivers/nvme/host/core.c static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj, · line 3308
Quoted 6 lines · Sagi Grimberg
drivers/nvme/host/core.c +2
-0@@ -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:
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 2 lines · Sagi Grimberg
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/'
Quoted 5 lines
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<[email protected]>
With small comment.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 43 lines · Sagi Grimberg
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 <[email protected]>---
Changes from v1:
- fix changelogdrivers/nvme/host/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/nvme/host/core.c +11
-0@@ -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 };
drivers/nvme/host/core.c static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj, · line 3294
Quoted 4 lines
drivers/nvme/host/core.c +1
-0@@ -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:
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme