[PATCH v2 1/2] libmultipath: support host adapter name lookup for s390x ccw bus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are also (FCP) HBAs that appear on a bus different from PCI.

Complements v0.6.0 commit
01ab2a468ea2 ("libmultipath: Add additional path wildcards").

With that we can easily get the full FCP addressing triplet
(HBA, WWPN, LUN) from multipath tools without additional tools
and correlation:

$ multipathd -k'show paths format "%w|%i|%a|%r"'
uuid                             |hcil       |host adapter|target WWPN
36005076400820293e8000000000000a0|1:0:3:160  |0.0.5080    |0x500507680b25c449
36005076400820293e8000000000000a0|1:0:4:160  |0.0.5080    |0x500507680b25c448
36005076400820293e8000000000000a0|58:0:3:160 |0.0.50c0    |0x500507680b26c449
36005076400820293e8000000000000a0|58:0:4:160 |0.0.50c0    |0x500507680b26c448

                                              ^^^^^^^^
                                   instead of [undef]

As a side effect this patch theoretically also enables group by
host adapter for s390x based on v0.6.0 commit a28e61e5cc9a
("Crafted ordering of child paths for round robin path selector").

Reviewed-by: Benjamin Block <bblock@xxxxxxxxxxxxx>
Signed-off-by: Steffen Maier <maier@xxxxxxxxxxxxx>
---

Notes:
    Changes since v1:
    - Make sysfs_get_host_pci_name() static and generalize for adapters
      on different bus types, in order to reduce code duplication (Ben).
      The ancestor walk is always the same based on kernel driver core
      with the only difference that PCI matches against driver name
      whereas CCW matches against subsystem name.
      Unfortunately, the diffstat increased because I had to move the
      new static sysfs_get_host_bus_id() in front of its only user
      sysfs_get_host_adapter_name() [or else a strange upfront prototype
      would have been necessary].

 libmultipath/discovery.c | 69 ++++++++++++++++++++++------------------
 libmultipath/discovery.h |  1 -
 2 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 7d939ae08004..5aba7e8d495f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -475,39 +475,13 @@ 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);
@@ -525,10 +499,17 @@ int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
 		}
 		if (!strcmp(driver_name, "pcieport"))
 			break;
+		subsystem_name = udev_device_get_subsystem(parent);
+		if (!subsystem_name) {
+			parent = udev_device_get_parent(parent);
+			continue;
+		}
+		if (!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 +518,7 @@ int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
 			return 1;
 		}
 
-		strncpy(pci_name, value, SLOT_NAME_SIZE);
+		strncpy(bus_id, value, SLOT_NAME_SIZE);
 		udev_device_unref(hostdev);
 		return 0;
 	}
@@ -545,6 +526,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;
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index 095657bb9de4..466af34504de 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -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);
-- 
2.27.0

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux