device-mapper-multipath/0114-libmultipath-sysfs_set_nexus_loss_tmo-support-SAS-ex.patch
Benjamin Marzinski 9fdf79cddf device-mapper-multipath-0.8.5-4
Update Source to upstream version 0.8.5 plus post tag commits
  * Patches 0001-0121 are from
    https://github.com/openSUSE/multipath-tools/tree/queue and are
    already queued for upstream
  * Patches 0122&0123 have been posted for upstream inclusion
Rename files
  * Previous patches 0103-0111 are now patches 0124-0132
2021-02-11 13:53:51 -06:00

58 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Fri, 13 Nov 2020 22:38:21 +0100
Subject: [PATCH] libmultipath: sysfs_set_nexus_loss_tmo(): support SAS
expanders
With SAS expanders, SAS node names have 3 digits. libmultipath
would fail to discover the sas_end_device matching a given SCSI
target in this case. Fix it.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/discovery.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 6d74cc07..921025d4 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -789,14 +789,28 @@ sysfs_set_session_tmo(struct multipath *mpp, struct path *pp)
static void
sysfs_set_nexus_loss_tmo(struct multipath *mpp, struct path *pp)
{
- struct udev_device *sas_dev = NULL;
- char end_dev_id[64];
+ struct udev_device *parent, *sas_dev = NULL;
+ const char *end_dev_id = NULL;
char value[11];
+ static const char ed_str[] = "end_device-";
- if (mpp->dev_loss == DEV_LOSS_TMO_UNSET)
+ if (!pp->udev || mpp->dev_loss == DEV_LOSS_TMO_UNSET)
return;
- sprintf(end_dev_id, "end_device-%d:%d",
- pp->sg_id.host_no, pp->sg_id.transport_id);
+
+ for (parent = udev_device_get_parent(pp->udev);
+ parent;
+ parent = udev_device_get_parent(parent)) {
+ const char *ed = udev_device_get_sysname(parent);
+
+ if (!strncmp(ed, ed_str, sizeof(ed_str) - 1)) {
+ end_dev_id = ed;
+ break;
+ }
+ }
+ if (!end_dev_id) {
+ condlog(1, "%s: No SAS end device", pp->dev);
+ return;
+ }
sas_dev = udev_device_new_from_subsystem_sysname(udev,
"sas_end_device", end_dev_id);
if (!sas_dev) {
--
2.17.2