Skip to content

Commit 45fb19f

Browse files
sagigrimbergkeithbusch
authored andcommitted
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. Signed-off-by: Sagi Grimberg <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 76171c6 commit 45fb19f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/nvme/host/core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,6 +3252,16 @@ static ssize_t nvme_sysfs_show_hostnqn(struct device *dev,
32523252
}
32533253
static DEVICE_ATTR(hostnqn, S_IRUGO, nvme_sysfs_show_hostnqn, NULL);
32543254

3255+
static ssize_t nvme_sysfs_show_hostid(struct device *dev,
3256+
struct device_attribute *attr,
3257+
char *buf)
3258+
{
3259+
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
3260+
3261+
return snprintf(buf, PAGE_SIZE, "%pU\n", &ctrl->opts->host->id);
3262+
}
3263+
static DEVICE_ATTR(hostid, S_IRUGO, nvme_sysfs_show_hostid, NULL);
3264+
32553265
static ssize_t nvme_sysfs_show_address(struct device *dev,
32563266
struct device_attribute *attr,
32573267
char *buf)
@@ -3278,6 +3288,7 @@ static struct attribute *nvme_dev_attrs[] = {
32783288
&dev_attr_queue_count.attr,
32793289
&dev_attr_sqsize.attr,
32803290
&dev_attr_hostnqn.attr,
3291+
&dev_attr_hostid.attr,
32813292
NULL
32823293
};
32833294

@@ -3293,6 +3304,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
32933304
return 0;
32943305
if (a == &dev_attr_hostnqn.attr && !ctrl->opts)
32953306
return 0;
3307+
if (a == &dev_attr_hostid.attr && !ctrl->opts)
3308+
return 0;
32963309

32973310
return a->mode;
32983311
}

0 commit comments

Comments
 (0)