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
PATCH 1/1 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
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(-)
libmultipath/print.c +41 -5
@@ -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
Signature · 1 line
2.12.0.windows.1
Hello Sunao,
Quoted 9 lines · 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
Quoted 45 lines
libmultipath/print.c +1
-3@@ -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]" );libmultipath/print.c +0
-0sprintf (host_id,"host%d" , pp->sg_id.host_no); host_dev = udev_device_new_from_subsystem_sysname(udev,"
fc_host",libmultipath/print.c +13
-0host_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-
libmultipath/print.c out: · line 576
Quoted 10 lines
libmultipath/print.c +9
-0>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.
Quoted 34 lines
libmultipath/print.c +16
-2+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");libmultipath/print.c +2
-0+ } +return snprintf (buff, len,"[undef]" ); }int
Signature · 9 lines
Dr. Martin Wilck <[email protected]>, 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 [email protected] https://www.redhat.com/mailman/listinfo/dm-devel