libmultipath: ignore natively multipathed NVME devices
authorMartin Wilck <mwilck@suse.com>
Fri, 19 Jan 2018 00:19:43 +0000 (01:19 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 7 Mar 2018 08:41:02 +0000 (09:41 +0100)
Such devices have a parent with SUBSYSTEM="nvme-subsystem", not "nvme".
Furthermore, avoid a possible segfaults NULL checks.

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/discovery.c

index 9b22bd9..88fc8d7 100644 (file)
@@ -1200,6 +1200,7 @@ nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
 {
        struct udev_device *parent;
        const char *attr_path = NULL;
+       const char *attr;
 
        attr_path = udev_device_get_sysname(pp->udev);
        if (!attr_path)
@@ -1209,14 +1210,17 @@ nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
                   &pp->sg_id.host_no,
                   &pp->sg_id.scsi_id) != 2)
                return 1;
-       pp->sg_id.channel = 0;
-       pp->sg_id.lun = atoi(udev_device_get_sysattr_value(pp->udev, "nsid"));
 
-       parent = udev_device_get_parent(pp->udev);
+       parent = udev_device_get_parent_with_subsystem_devtype(pp->udev,
+                                                              "nvme", NULL);
        if (!parent)
                return 1;
 
-       pp->sg_id.channel = atoi(udev_device_get_sysattr_value(parent, "cntlid"));
+       attr = udev_device_get_sysattr_value(pp->udev, "nsid");
+       pp->sg_id.lun = attr ? atoi(attr) : 0;
+
+       attr = udev_device_get_sysattr_value(parent, "cntlid");
+       pp->sg_id.channel = attr ? atoi(attr) : 0;
 
        snprintf(pp->vendor_id, SCSI_VENDOR_SIZE, "NVME");
        snprintf(pp->product_id, SCSI_PRODUCT_SIZE, "%s",