Linux Device Mapper development
 help / color / mirror / Atom feed
From: Steffen Maier <maier@linux.ibm.com>
To: dm-devel@redhat.com, Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: Steffen Maier <maier@linux.ibm.com>,
	ShivaKrishna Merla <shivakrishna.merla@netapp.com>,
	Martin Wilck <martin.wilck@suse.com>
Subject: [dm-devel] [PATCH 1/2] libmultipath: support host adapter name lookup for s390x ccw bus
Date: Wed,  9 Feb 2022 20:47:12 +0100	[thread overview]
Message-ID: <20220209194713.56556-2-maier@linux.ibm.com> (raw)
In-Reply-To: <20220209194713.56556-1-maier@linux.ibm.com>

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@linux.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
---
 libmultipath/discovery.c | 41 +++++++++++++++++++++++++++++++++++++++-
 libmultipath/discovery.h |  1 +
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 7d939ae08004..bb4913d9b75f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -497,8 +497,12 @@ int sysfs_get_host_adapter_name(const struct path *pp, char *adapter_name)
 		return sysfs_get_iscsi_ip_address(pp, adapter_name);
 
 	/* fetch adapter pci name for other protocols
+	 * or try to get s390x channel subsystem FCP device bus-ID [zfcp]
 	 */
-	return sysfs_get_host_pci_name(pp, adapter_name);
+	if (sysfs_get_host_pci_name(pp, adapter_name))
+		return sysfs_get_host_ccw_name(pp, adapter_name);
+	else
+		return 0;
 }
 
 int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
@@ -545,6 +549,41 @@ int sysfs_get_host_pci_name(const struct path *pp, char *pci_name)
 	return 1;
 }
 
+int sysfs_get_host_ccw_name(const struct path *pp, char *ccw_name)
+{
+	struct udev_device *hostdev, *parent;
+	char host_name[HOST_NAME_LEN];
+	const char *value;
+
+	if (!pp || !ccw_name)
+		return 1;
+
+	sprintf(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_with_subsystem_devtype(hostdev, "ccw",
+							       NULL);
+	if (parent) {
+		/* s390x ccw FCP device found
+		 */
+		value = udev_device_get_sysname(parent);
+
+		if (!value) {
+			udev_device_unref(hostdev);
+			return 1;
+		}
+
+		strncpy(ccw_name, value, SLOT_NAME_SIZE);
+		udev_device_unref(hostdev);
+		return 0;
+	}
+	udev_device_unref(hostdev);
+	return 1;
+}
+
 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..0a58c725d700 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -44,6 +44,7 @@ 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_ccw_name(const struct path *pp, char *ccw_name);
 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,

base-commit: d9d7ae9e2125116b465b4ff4d98ce65fe0eac3cc
-- 
2.27.0

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


  reply	other threads:[~2022-02-10  8:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 19:47 [dm-devel] [PATCH 0/2] multipath-tools: FCP addressing display support (for s390x) Steffen Maier
2022-02-09 19:47 ` Steffen Maier [this message]
2022-02-10 18:41   ` [dm-devel] [PATCH 1/2] libmultipath: support host adapter name lookup for s390x ccw bus Benjamin Marzinski
2022-02-09 19:47 ` [dm-devel] [PATCH 2/2] libmultipath: add %L path wildcard for 64-bit hex LUN Steffen Maier
2022-02-10 18:42   ` Benjamin Marzinski
2022-02-10 19:54     ` Martin Wilck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220209194713.56556-2-maier@linux.ibm.com \
    --to=maier@linux.ibm.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=martin.wilck@suse.com \
    --cc=shivakrishna.merla@netapp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox