All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-devel] [PATCH v2 1/3] libmultipath: use 3rd digit as transport_id for expanders
@ 2021-02-02  9:43 mwilck
  2021-02-02  9:45 ` Martin Wilck
  2021-02-02 17:24 ` Benjamin Marzinski
  0 siblings, 2 replies; 3+ messages in thread
From: mwilck @ 2021-02-02  9:43 UTC (permalink / raw)
  To: Benjamin Marzinski, Christophe Varoqui; +Cc: dm-devel, Martin Wilck

From: Martin Wilck <mwilck@suse.com>

On SAS expanders, node id's have 3 digits. sysfs paths look like this:

/sys/devices/pci0000:80/0000:80:02.0/0000:8b:00.0/0000:8c:09.0/0000:8f:00.0/host9/port-9:0/expander-9:0/port-9:0:13/expander-9:1/port-9:1:12/expander-9:2/port-9:2:4/end_device-9:2:4/target9:0:29/9:0:29:0/block/sdac

In that case, we should use the last digit as transport id.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/discovery.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index e818585..6d74cc0 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -358,10 +358,17 @@ sysfs_get_tgt_nodename(struct path *pp, char *node)
 	if (value) {
 		tgtdev = udev_device_get_parent(parent);
 		while (tgtdev) {
+			char c;
+
 			tgtname = udev_device_get_sysname(tgtdev);
-			if (tgtname && sscanf(tgtname, "end_device-%d:%d",
-				   &host, &tgtid) == 2)
-				break;
+			if (tgtname) {
+				if (sscanf(tgtname, "end_device-%d:%d:%d%c",
+					   &host, &channel, &tgtid, &c) == 3)
+					break;
+				if (sscanf(tgtname, "end_device-%d:%d%c",
+					   &host, &tgtid, &c) == 2)
+					break;
+			}
 			tgtdev = udev_device_get_parent(tgtdev);
 			tgtid = -1;
 		}
-- 
2.29.2


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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [dm-devel] [PATCH v2 1/3] libmultipath: use 3rd digit as transport_id for expanders
  2021-02-02  9:43 [dm-devel] [PATCH v2 1/3] libmultipath: use 3rd digit as transport_id for expanders mwilck
@ 2021-02-02  9:45 ` Martin Wilck
  2021-02-02 17:24 ` Benjamin Marzinski
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Wilck @ 2021-02-02  9:45 UTC (permalink / raw)
  To: Benjamin Marzinski, Christophe Varoqui; +Cc: dm-devel

On Tue, 2021-02-02 at 10:43 +0100, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> On SAS expanders, node id's have 3 digits. sysfs paths look like
> this:
> 
> /sys/devices/pci0000:80/0000:80:02.0/0000:8b:00.0/0000:8c:09.0/0000:8
> f:00.0/host9/port-9:0/expander-9:0/port-9:0:13/expander-9:1/port-
> 9:1:12/expander-9:2/port-9:2:4/end_device-
> 9:2:4/target9:0:29/9:0:29:0/block/sdac
> 
> In that case, we should use the last digit as transport id.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>

Sorry, I forgot:

v1 -> v2:
   avoid endless loop if udev_device_get_sysname() returns NULL
   (Ben Marzinski)


> ---
>  libmultipath/discovery.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index e818585..6d74cc0 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -358,10 +358,17 @@ sysfs_get_tgt_nodename(struct path *pp, char
> *node)
>         if (value) {
>                 tgtdev = udev_device_get_parent(parent);
>                 while (tgtdev) {
> +                       char c;
> +
>                         tgtname = udev_device_get_sysname(tgtdev);
> -                       if (tgtname && sscanf(tgtname, "end_device-
> %d:%d",
> -                                  &host, &tgtid) == 2)
> -                               break;
> +                       if (tgtname) {
> +                               if (sscanf(tgtname, "end_device-
> %d:%d:%d%c",
> +                                          &host, &channel, &tgtid,
> &c) == 3)
> +                                       break;
> +                               if (sscanf(tgtname, "end_device-
> %d:%d%c",
> +                                          &host, &tgtid, &c) == 2)
> +                                       break;
> +                       }
>                         tgtdev = udev_device_get_parent(tgtdev);
>                         tgtid = -1;
>                 }



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dm-devel] [PATCH v2 1/3] libmultipath: use 3rd digit as transport_id for expanders
  2021-02-02  9:43 [dm-devel] [PATCH v2 1/3] libmultipath: use 3rd digit as transport_id for expanders mwilck
  2021-02-02  9:45 ` Martin Wilck
@ 2021-02-02 17:24 ` Benjamin Marzinski
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Marzinski @ 2021-02-02 17:24 UTC (permalink / raw)
  To: mwilck; +Cc: dm-devel

On Tue, Feb 02, 2021 at 10:43:12AM +0100, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> On SAS expanders, node id's have 3 digits. sysfs paths look like this:
> 
> /sys/devices/pci0000:80/0000:80:02.0/0000:8b:00.0/0000:8c:09.0/0000:8f:00.0/host9/port-9:0/expander-9:0/port-9:0:13/expander-9:1/port-9:1:12/expander-9:2/port-9:2:4/end_device-9:2:4/target9:0:29/9:0:29:0/block/sdac
> 
> In that case, we should use the last digit as transport id.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  libmultipath/discovery.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> index e818585..6d74cc0 100644
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -358,10 +358,17 @@ sysfs_get_tgt_nodename(struct path *pp, char *node)
>  	if (value) {
>  		tgtdev = udev_device_get_parent(parent);
>  		while (tgtdev) {
> +			char c;
> +
>  			tgtname = udev_device_get_sysname(tgtdev);
> -			if (tgtname && sscanf(tgtname, "end_device-%d:%d",
> -				   &host, &tgtid) == 2)
> -				break;
> +			if (tgtname) {
> +				if (sscanf(tgtname, "end_device-%d:%d:%d%c",
> +					   &host, &channel, &tgtid, &c) == 3)
> +					break;
> +				if (sscanf(tgtname, "end_device-%d:%d%c",
> +					   &host, &tgtid, &c) == 2)
> +					break;
> +			}
>  			tgtdev = udev_device_get_parent(tgtdev);
>  			tgtid = -1;
>  		}
> -- 
> 2.29.2

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-02 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02  9:43 [dm-devel] [PATCH v2 1/3] libmultipath: use 3rd digit as transport_id for expanders mwilck
2021-02-02  9:45 ` Martin Wilck
2021-02-02 17:24 ` Benjamin Marzinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.