Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fill NVMe specific path info
Signed-off-by: Keith Busch <keith.busch@intel.com>
  • Loading branch information
Keith Busch authored and cvaroqui committed Feb 27, 2017
1 parent b456c0b commit 4dd2578
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
35 changes: 35 additions & 0 deletions libmultipath/discovery.c
Expand Up @@ -1186,6 +1186,36 @@ scsi_sysfs_pathinfo (struct path * pp, vector hwtable)
return 0;
}

static int
nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
{
struct udev_device *parent, *nvme = NULL;

parent = pp->udev;
while (parent) {
const char *subsys = udev_device_get_subsystem(parent);

if (subsys && !strncmp(subsys, "nvme", 4)) {
nvme = parent;
break;
}
parent = udev_device_get_parent(parent);
}
if (!nvme)
return 1;

snprintf(pp->vendor_id, SCSI_VENDOR_SIZE, "NVME");
snprintf(pp->product_id, SCSI_PRODUCT_SIZE, "%s", udev_device_get_sysattr_value(nvme, "model"));
snprintf(pp->serial, SERIAL_SIZE, "%s", udev_device_get_sysattr_value(nvme, "serial"));
snprintf(pp->rev, SCSI_REV_SIZE, "%s", udev_device_get_sysattr_value(nvme, "firmware_rev"));

condlog(3, "%s: vendor:%s product:%s serial:%s rev:%s", pp->dev,
pp->vendor_id, pp->product_id, pp->serial, pp->rev);
pp->hwe = find_hwe(hwtable, pp->vendor_id, pp->product_id, NULL);

return 0;
}

static int
rbd_sysfs_pathinfo (struct path * pp, vector hwtable)
{
Expand Down Expand Up @@ -1405,6 +1435,8 @@ sysfs_pathinfo(struct path * pp, vector hwtable)
pp->bus = SYSFS_BUS_SCSI;
if (!strncmp(pp->dev,"rbd", 3))
pp->bus = SYSFS_BUS_RBD;
if (!strncmp(pp->dev,"nvme", 4))
pp->bus = SYSFS_BUS_NVME;

if (pp->bus == SYSFS_BUS_UNDEF)
return 0;
Expand All @@ -1420,6 +1452,9 @@ sysfs_pathinfo(struct path * pp, vector hwtable)
} else if (pp->bus == SYSFS_BUS_RBD) {
if (rbd_sysfs_pathinfo(pp, hwtable))
return 1;
} else if (pp->bus == SYSFS_BUS_NVME) {
if (nvme_sysfs_pathinfo(pp, hwtable))
return 1;
}
return 0;
}
Expand Down
10 changes: 10 additions & 0 deletions libmultipath/hwtable.c
Expand Up @@ -1073,6 +1073,16 @@ static struct hwentry default_hw[] = {
.prio_name = PRIO_ALUA,
.no_path_retry = 30,
},
/*
* Generic NVMe devices
*/
{
.vendor = "NVME",
.product = ".*",
.uid_attribute = "ID_WWN",
.checker_name = DIRECTIO,
.retain_hwhandler = RETAIN_HWHANDLER_OFF,
},
#if 0
/*
* Copy this TEMPLATE to add new hardware.
Expand Down
1 change: 1 addition & 0 deletions libmultipath/structs.h
Expand Up @@ -53,6 +53,7 @@ enum sysfs_buses {
SYSFS_BUS_CCW,
SYSFS_BUS_CCISS,
SYSFS_BUS_RBD,
SYSFS_BUS_NVME,
};

enum pathstates {
Expand Down

0 comments on commit 4dd2578

Please sign in to comment.