All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] multipathd: display the host WWNN fields When the iSCSI path information is displayed using the multipath command, the host WWNN in the path information is not fully displayed, as follows: Multipathd show paths format "%N %n" Host WWNN Target WWNN [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x
@ 2018-10-27  4:40 s90006763
  2018-11-02 12:42 ` Martin Wilck
  0 siblings, 1 reply; 2+ messages in thread
From: s90006763 @ 2018-10-27  4:40 UTC (permalink / raw)
  To: dm-devel, christophe.varoqui, hare, mwilck, bmarzins, xose.vazquez
  Cc: wangke16, guanjunxiong, chengjike.cheng, shenhong09, lixiaoying,
	sunao.sun

This patch solves this problem and gets the complete display of host
WWNN related fields,as follows:multipathd show paths format "%N %n"
Host WWNN Target WWPN
Iqn.xx-x.com.redhat:86329 iqn.xxx-xx.com.xx:oceanstor:xxxx::xx:x.x
Iqn.xx-x.com.redhat:86329 iqn.xxx-xx.com.xx:oceanstor:xxxx::xx:x.x
---
 libmultipath/print.c | 46 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/libmultipath/print.c b/libmultipath/print.c
index 7b610b94..956d705d 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -525,15 +525,13 @@ snprint_path_mpp (char * buff, size_t len, const struct path * pp)
 }
 
 static int
-snprint_host_attr (char * buff, size_t len, const struct path * pp, char *attr)
+snprint_fc_host_attr (char * buff, size_t len, const struct path * pp, char *attr)
 {
 	struct udev_device *host_dev = NULL;
 	char host_id[32];
 	const char *value = NULL;
 	int ret;
 
-	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
-		return snprintf(buff, len, "[undef]");
 	sprintf(host_id, "host%d", pp->sg_id.host_no);
 	host_dev = udev_device_new_from_subsystem_sysname(udev, "fc_host",
 							  host_id);
@@ -551,16 +549,54 @@ out:
 	return ret;
 }
 
+static int
+snprint_iscsi_host_attr (char * buff, size_t len, const struct path * pp, char *attr)
+{
+        struct udev_device *host_dev = NULL;
+        char host_id[32];
+        const char *value = NULL;
+        int ret;
+
+        sprintf(host_id, "session%d", pp->sg_id.transport_id);
+        host_dev = udev_device_new_from_subsystem_sysname(udev, "iscsi_session",
+                                                          host_id);
+        if (!host_dev) {
+                condlog(1, "%s: No iscsi_host device for '%s'", pp->dev, host_id);
+                goto out;
+        }
+        value = udev_device_get_sysattr_value(host_dev, attr);
+        if (value)
+                ret = snprint_str(buff, len, value);
+        udev_device_unref(host_dev);
+out:
+	if (!value)
+		ret = snprintf(buff, len, "[unknown]");
+	return ret;
+}
+
 int
 snprint_host_wwnn (char * buff, size_t len, const struct path * pp)
 {
-	return snprint_host_attr(buff, len, pp, "node_name");
+	if(pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
+	{
+		return snprint_iscsi_host_attr(buff, len, pp, "initiatorname");
+	}
+	else if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP)
+	{
+		return snprint_fc_host_attr(buff, len, pp, "node_name");
+	}
+	return snprintf(buff, len, "[undef]");
 }
 
 int
 snprint_host_wwpn (char * buff, size_t len, const struct path * pp)
 {
-	return snprint_host_attr(buff, len, pp, "port_name");
+	
+	if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP)
+	{
+		return snprint_fc_host_attr(buff, len, pp, "port_name");
+	}
+	return snprintf(buff, len, "[undef]");	
 }
 
 int
-- 
2.12.0.windows.1

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

* Re: [PATCH] multipathd: display the host WWNN fields When the iSCSI path information is displayed using the multipath command, the host WWNN in the path information is not fully displayed, as follows: Multipathd show paths format "%N %n" Host WWNN Target WWNN [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x
  2018-10-27  4:40 [PATCH] multipathd: display the host WWNN fields When the iSCSI path information is displayed using the multipath command, the host WWNN in the path information is not fully displayed, as follows: Multipathd show paths format "%N %n" Host WWNN Target WWNN [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x s90006763
@ 2018-11-02 12:42 ` Martin Wilck
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Wilck @ 2018-11-02 12:42 UTC (permalink / raw)
  To: s90006763, xose.vazquez, christophe.varoqui, bmarzins, dm-devel,
	hare, mwilck+gmail
  Cc: wangke16, guanjunxiong, chengjike.cheng, lixiaoying, shenhong09

Hello Sunao,

On Sat, 2018-10-27 at 12:40 +0800, s90006763 wrote:
> This patch solves this problem and gets the complete display of host
> WWNN related fields,as follows:multipathd show paths format "%N %n"
> Host WWNN Target WWPN
> Iqn.xx-x.com.redhat:86329 iqn.xxx-xx.com.xx:oceanstor:xxxx::xx:x.x
> Iqn.xx-x.com.redhat:86329 iqn.xxx-xx.com.xx:oceanstor:xxxx::xx:x.x
> ---
>  libmultipath/print.c | 46 +++++++++++++++++++++++++++++++++++++++++-
> ----
>  1 file changed, 41 insertions(+), 5 deletions(-)

Thanks again for the new submission.

Your patch still has lots of whitespace and other style issues. Please
use checkpatch.pl as I suggested in my previous review. Also, as I
already mentioned, please keep your subject line (summary) at a
readable length (75 chars) and add the other information in the
message body.

Apart from that, I only have one more minor nitpick, see below.
We are getting close.

Best regards,
Martin

> 
> diff --git a/libmultipath/print.c b/libmultipath/print.c
> index 7b610b94..956d705d 100644
> --- a/libmultipath/print.c
> +++ b/libmultipath/print.c
> @@ -525,15 +525,13 @@ snprint_path_mpp (char * buff, size_t len,
> const struct path * pp)
>  }
>  
>  static int
> -snprint_host_attr (char * buff, size_t len, const struct path * pp,
> char *attr)
> +snprint_fc_host_attr (char * buff, size_t len, const struct path *
> pp, char *attr)
>  {
>  	struct udev_device *host_dev = NULL;
>  	char host_id[32];
>  	const char *value = NULL;
>  	int ret;
>  
> -	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
> -		return snprintf(buff, len, "[undef]");
>  	sprintf(host_id, "host%d", pp->sg_id.host_no);
>  	host_dev = udev_device_new_from_subsystem_sysname(udev,
> "fc_host",
>  							  host_id);
> @@ -551,16 +549,54 @@ out:
>  	return ret;
>  }
>  
> +static int
> +snprint_iscsi_host_attr (char * buff, size_t len, const struct path
> * pp, char *attr)
> +{
> +        struct udev_device *host_dev = NULL;
> +        char host_id[32];
> +        const char *value = NULL;
> +        int ret;
> +
> +        sprintf(host_id, "session%d", pp->sg_id.transport_id);
> +        host_dev = udev_device_new_from_subsystem_sysname(udev,
> "iscsi_session",
> +                                                          host_id);
> +        if (!host_dev) {
> +                condlog(1, "%s: No iscsi_host device for '%s'", pp-
> >dev, host_id);
> +                goto out;
> +        }
> +        value = udev_device_get_sysattr_value(host_dev, attr);
> +        if (value)
> +                ret = snprint_str(buff, len, value);
> +        udev_device_unref(host_dev);
> +out:
> +	if (!value)
> +		ret = snprintf(buff, len, "[unknown]");

Please use "undef" here, for consistency.

> +	return ret;
> +}
> +
>  int
>  snprint_host_wwnn (char * buff, size_t len, const struct path * pp)
>  {
> -	return snprint_host_attr(buff, len, pp, "node_name");
> +	if(pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
> +	{
> +		return snprint_iscsi_host_attr(buff, len, pp,
> "initiatorname");
> +	}
> +	else if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP)
> +	{
> +		return snprint_fc_host_attr(buff, len, pp,
> "node_name");
> +	}
> +	return snprintf(buff, len, "[undef]");
>  }
>  
>  int
>  snprint_host_wwpn (char * buff, size_t len, const struct path * pp)
>  {
> -	return snprint_host_attr(buff, len, pp, "port_name");
> +	
> +	if (pp->sg_id.proto_id == SCSI_PROTOCOL_FCP)
> +	{
> +		return snprint_fc_host_attr(buff, len, pp,
> "port_name");
> +	}
> +	return snprintf(buff, len, "[undef]");	
>  }
>  
>  int

-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)


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

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

end of thread, other threads:[~2018-11-02 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-27  4:40 [PATCH] multipathd: display the host WWNN fields When the iSCSI path information is displayed using the multipath command, the host WWNN in the path information is not fully displayed, as follows: Multipathd show paths format "%N %n" Host WWNN Target WWNN [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x [undef] iqn.xxx-xx.com.xx:oceanstor:xxxx:: xx:x.x s90006763
2018-11-02 12:42 ` Martin Wilck

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.