nvme: expose cntlid in sysfs
For NVMe over Fabrics, the cntlid will be used by systemd/udev to create link to the device, for example, /dev/disk/by-path/<fabrics-info>-<cntlid>-<namespace> -> /dev/nvme0n1 Signed-off-by: Ming Lin <ming.l@ssi.samsung.com> Reviewed-by: Keith Busch <keith.busch@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Родитель
1cb3cce5eb
Коммит
931e1c2204
|
@ -912,6 +912,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
|
||||||
ctrl->oncs = le16_to_cpup(&id->oncs);
|
ctrl->oncs = le16_to_cpup(&id->oncs);
|
||||||
atomic_set(&ctrl->abort_limit, id->acl + 1);
|
atomic_set(&ctrl->abort_limit, id->acl + 1);
|
||||||
ctrl->vwc = id->vwc;
|
ctrl->vwc = id->vwc;
|
||||||
|
ctrl->cntlid = le16_to_cpup(&id->cntlid);
|
||||||
memcpy(ctrl->serial, id->sn, sizeof(id->sn));
|
memcpy(ctrl->serial, id->sn, sizeof(id->sn));
|
||||||
memcpy(ctrl->model, id->mn, sizeof(id->mn));
|
memcpy(ctrl->model, id->mn, sizeof(id->mn));
|
||||||
memcpy(ctrl->firmware_rev, id->fr, sizeof(id->fr));
|
memcpy(ctrl->firmware_rev, id->fr, sizeof(id->fr));
|
||||||
|
@ -1099,7 +1100,7 @@ static const struct attribute_group nvme_ns_attr_group = {
|
||||||
.is_visible = nvme_attrs_are_visible,
|
.is_visible = nvme_attrs_are_visible,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define nvme_show_function(field) \
|
#define nvme_show_str_function(field) \
|
||||||
static ssize_t field##_show(struct device *dev, \
|
static ssize_t field##_show(struct device *dev, \
|
||||||
struct device_attribute *attr, char *buf) \
|
struct device_attribute *attr, char *buf) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -1108,15 +1109,26 @@ static ssize_t field##_show(struct device *dev, \
|
||||||
} \
|
} \
|
||||||
static DEVICE_ATTR(field, S_IRUGO, field##_show, NULL);
|
static DEVICE_ATTR(field, S_IRUGO, field##_show, NULL);
|
||||||
|
|
||||||
nvme_show_function(model);
|
#define nvme_show_int_function(field) \
|
||||||
nvme_show_function(serial);
|
static ssize_t field##_show(struct device *dev, \
|
||||||
nvme_show_function(firmware_rev);
|
struct device_attribute *attr, char *buf) \
|
||||||
|
{ \
|
||||||
|
struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \
|
||||||
|
return sprintf(buf, "%d\n", ctrl->field); \
|
||||||
|
} \
|
||||||
|
static DEVICE_ATTR(field, S_IRUGO, field##_show, NULL);
|
||||||
|
|
||||||
|
nvme_show_str_function(model);
|
||||||
|
nvme_show_str_function(serial);
|
||||||
|
nvme_show_str_function(firmware_rev);
|
||||||
|
nvme_show_int_function(cntlid);
|
||||||
|
|
||||||
static struct attribute *nvme_dev_attrs[] = {
|
static struct attribute *nvme_dev_attrs[] = {
|
||||||
&dev_attr_reset_controller.attr,
|
&dev_attr_reset_controller.attr,
|
||||||
&dev_attr_model.attr,
|
&dev_attr_model.attr,
|
||||||
&dev_attr_serial.attr,
|
&dev_attr_serial.attr,
|
||||||
&dev_attr_firmware_rev.attr,
|
&dev_attr_firmware_rev.attr,
|
||||||
|
&dev_attr_cntlid.attr,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ struct nvme_ctrl {
|
||||||
char serial[20];
|
char serial[20];
|
||||||
char model[40];
|
char model[40];
|
||||||
char firmware_rev[8];
|
char firmware_rev[8];
|
||||||
|
int cntlid;
|
||||||
|
|
||||||
u32 ctrl_config;
|
u32 ctrl_config;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче