[dm-devel] [PATCH 2/3] libmultipath: sysfs_set_nexus_loss_tmo(): support SAS expanders

Benjamin Marzinski bmarzins at redhat.com
Tue Feb 2 04:00:20 UTC 2021


On Thu, Jan 28, 2021 at 09:45:43PM +0100, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
> 
> 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 at suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---
>  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




More information about the dm-devel mailing list