From: Martin Wilck <mwilck@xxxxxxxx> 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. Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> --- libmultipath/discovery.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index f3ce3f8..7878454 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.29.2 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel