@@ -475,60 +475,33 @@ sysfs_get_tgt_nodename(struct path *pp, char *node)
return 0;
}
-int sysfs_get_host_adapter_name(const struct path *pp, char *adapter_name)
-{
- int proto_id;
-
- if (!pp || !adapter_name)
- return 1;
-
- proto_id = pp->sg_id.proto_id;
-
- if (proto_id != SCSI_PROTOCOL_FCP &&
- proto_id != SCSI_PROTOCOL_SAS &&
- proto_id != SCSI_PROTOCOL_ISCSI &&
- proto_id != SCSI_PROTOCOL_SRP) {
- return 1;
- }
- /* iscsi doesn't have adapter info in sysfs
- * get ip_address for grouping paths
- */
- if (pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
- return sysfs_get_iscsi_ip_address(pp, adapter_name);
-
- /* fetch adapter pci name for other protocols
- */
- return sysfs_get_host_pci_name(pp, adapter_name);
-}
-
-int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
+static int sysfs_get_host_bus_id(const struct path *pp, char *bus_id)
{
struct udev_device *hostdev, *parent;
char host_name[HOST_NAME_LEN];
- const char *driver_name, *value;
+ const char *driver_name, *subsystem_name, *value;
- if (!pp || !pci_name)
+ if (!pp || !bus_id)
return 1;
- sprintf(host_name, "host%d", pp->sg_id.host_no);
+ snprintf(host_name, sizeof(host_name), "host%d", pp->sg_id.host_no);
hostdev = udev_device_new_from_subsystem_sysname(udev,
"scsi_host", host_name);
if (!hostdev)
return 1;
- parent = udev_device_get_parent(hostdev);
- while (parent) {
+ for (parent = udev_device_get_parent(hostdev);
+ parent;
+ parent = udev_device_get_parent(parent)) {
driver_name = udev_device_get_driver(parent);
- if (!driver_name) {
- parent = udev_device_get_parent(parent);
- continue;
- }
- if (!strcmp(driver_name, "pcieport"))
+ subsystem_name = udev_device_get_subsystem(parent);
+ if (driver_name && !strcmp(driver_name, "pcieport"))
+ break;
+ if (subsystem_name && !strcmp(subsystem_name, "ccw"))
break;
- parent = udev_device_get_parent(parent);
}
if (parent) {
- /* pci_device found
+ /* pci_device or ccw fcp device found
*/
value = udev_device_get_sysname(parent);
@@ -537,7 +510,7 @@ int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
return 1;
}
- strncpy(pci_name, value, SLOT_NAME_SIZE);
+ strlcpy(bus_id, value, SLOT_NAME_SIZE);
udev_device_unref(hostdev);
return 0;
}
@@ -545,6 +518,32 @@ int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
return 1;
}
+int sysfs_get_host_adapter_name(const struct path *pp, char *adapter_name)
+{
+ int proto_id;
+
+ if (!pp || !adapter_name)
+ return 1;
+
+ proto_id = pp->sg_id.proto_id;
+
+ if (proto_id != SCSI_PROTOCOL_FCP &&
+ proto_id != SCSI_PROTOCOL_SAS &&
+ proto_id != SCSI_PROTOCOL_ISCSI &&
+ proto_id != SCSI_PROTOCOL_SRP) {
+ return 1;
+ }
+ /* iscsi doesn't have adapter info in sysfs
+ * get ip_address for grouping paths
+ */
+ if (pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
+ return sysfs_get_iscsi_ip_address(pp, adapter_name);
+
+ /* fetch adapter bus-ID for other protocols
+ */
+ return sysfs_get_host_bus_id(pp, adapter_name);
+}
+
int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address)
{
struct udev_device *hostdev;
@@ -44,7 +44,6 @@ int store_pathinfo (vector pathvec, struct config *conf,
struct path **pp_ptr);
int sysfs_set_scsi_tmo (struct multipath *mpp, unsigned int checkint);
int sysfs_get_timeout(const struct path *pp, unsigned int *timeout);
-int sysfs_get_host_pci_name(const struct path *pp, char *pci_name);
int sysfs_get_iscsi_ip_address(const struct path *pp, char *ip_address);
int sysfs_get_host_adapter_name(const struct path *pp,
char *adapter_name);