add a cmd to display the topology links
PATCH 1/1 add a cmd to display the topology links
From: dingwenyi 00297106 <[email protected]>
This patch adds a new parameter which named -k to display links information in the multipath command. Command 'multipath -k' display paths with the same host wwn and target wwn as one link information.
The cmd display the following information to quickly and easily find the host and target information. [root@localhost mp]# ./multipath -k
link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2201333435363738 link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2211333435363738
--- libmultipath/config.h | 1 + libmultipath/discovery.c | 38 ++++++++++++++++++++++++++++++++++++++ libmultipath/discovery.h | 1 + libmultipath/print.c | 28 ++++++++++++++++++++++++++++ libmultipath/print.h | 4 +++- libmultipath/structs.c | 15 +++++++++++++++ libmultipath/structs.h | 1 + multipath/main.c | 10 +++++++++- 8 files changed, 96 insertions(+), 2 deletions(-)
libmultipath/config.h +1 -0
@@ -38,6 +38,7 @@ enum mpath_cmds {CMD_ADD_WWID ,CMD_USABLE_PATHS ,CMD_DUMP_CONFIG , + CMD_LIST_LINKS, }; enum force_reload_types {
libmultipath/discovery.c +38 -0
@@ -1992,3 +1992,41 @@ blank:return PATHINFO_OK ; } + +vector get_links_by_paths (vector pathvec) +{ +vector linkvec; +int i,j; +struct path * pp; +struct path * lp; +bool find; + + linkvec =vector_alloc (); +if (!linkvec) +return NULL ; + + vector_foreach_slot (pathvec, pp, i) { +if (!pp || pp->sg_id.host_no <0 ) +continue ; + + find = false; + vector_foreach_slot (linkvec, lp, j) { +if (!lp || lp->sg_id.host_no <0 ) +continue ; + +if (lp->sg_id.host_no == pp->sg_id.host_no && + lp->sg_id.channel == pp->sg_id.channel && + lp->sg_id.scsi_id == pp->sg_id.scsi_id) { + find = true; +continue ; + } + } + +if (find == false) +store_path (linkvec, pp); + } + +return linkvec; +} + +
libmultipath/discovery.h +1 -0
@@ -53,6 +53,7 @@ ssize_t sysfs_get_vpd (struct udev_device * udev, int pg, unsigned char * buff,int sysfs_get_asymmetric_access_state (struct path *pp,char *buff,int buflen);int get_uid (struct path * pp,int path_state,struct udev_device *udev); +vector get_links_by_paths (vector pathvec);/* * discovery bitmask
libmultipath/print.c +28 -0
@@ -2018,3 +2018,31 @@ void print_all_paths_custo(vector pathvec, int banner, char *fmt) vector_foreach_slot (pathvec, pp, i)print_path (pp, fmt); } + + +void print_all_links (vector pathvec,int banner) +{ +int i; +struct path * pp; +char *fmt =PRINT_LINK_SHORT ; +vector linkvec =NULL ; + +if (!VECTOR_SIZE (pathvec)) { +if (banner) +fprintf (stdout,"===== no links =====\n" ); +return ; + } + + linkvec =get_links_by_paths (pathvec); +if (NULL == linkvec || !VECTOR_SIZE (linkvec)) { +if (banner) +fprintf (stdout,"===== no links =====\n" ); +return ; + } + + vector_foreach_slot (linkvec, pp, i) +print_path (pp, fmt); + +free_linkvec (linkvec); +} +
libmultipath/print.h +3 -1
@@ -10,6 +10,7 @@#define PRINT_MAP_NAMES "%n %d %w"#define PRINT_MAP_PROPS "size=%S features='%f' hwhandler='%h' wp=%r"#define PRINT_PG_INDENT "policy='%s' prio=%p status=%t" +#define PRINT_LINK_SHORT "link host_wwnn=%N host_wwpn=%R target_wwnn=%n target_wwpn=%r"#define PRINT_JSON_MULTIPLIER 5#define PRINT_JSON_MAJOR_VERSION 0
@@ -68,7 +69,7 @@" \"target_wwpn\" : \"%r\",\n" \ " \"host_adapter\" : \"%a\"" -#define MAX_LINE_LEN 80 +#define MAX_LINE_LEN 128#define MAX_LINES 64#define MAX_FIELD_LEN 128#define PROGRESS_LEN 10
@@ -141,6 +142,7 @@ void _print_multipath_topology (const struct gen_multipath * gmp,void print_all_paths (vector pathvec,int banner);void print_all_paths_custo (vector pathvec,int banner,char *fmt); +void print_all_links (vector pathvec,int banner);int snprint_path_attr (const struct gen_path * gp,char *buf,int len,char wildcard);
libmultipath/structs.c +15 -0
@@ -292,6 +292,21 @@ free_multipathvec (vector mpvec, enum free_path_mode free_paths)vector_free (mpvec); } +void +free_linkvec (vector vec) +{ +int i; +struct path * pp; + +if (!vec || !VECTOR_SIZE (vec)) +return ; + + vector_foreach_slot(vec, pp, i) +vector_del_slot (vec, i); + +vector_free (vec); +} +int store_path (vector pathvec,struct path * pp) {
libmultipath/structs.h +1 -0
@@ -407,6 +407,7 @@ void free_multipath (struct multipath *, enum free_path_mode free_paths);void free_multipath_attributes (struct multipath *);void drop_multipath (vector mpvec,char * wwid,enum free_path_mode free_paths);void free_multipathvec (vector mpvec,enum free_path_mode free_paths); +void free_linkvec (vector vec);struct adapter_group *alloc_adaptergroup (void );struct host_group *alloc_hostgroup (void );
multipath/main.c +9 -1
@@ -126,6 +126,7 @@ usage (char * progname)fprintf (stderr," %s -l|-ll|-f [-v lvl] [-b fil] [-R num] [dev]\n" , progname);fprintf (stderr," %s -F [-v lvl] [-R num]\n" , progname);fprintf (stderr," %s [-t|-T]\n" , progname); +fprintf (stderr," %s -k\n" , progname);fprintf (stderr," %s -h\n" , progname);fprintf (stderr, "\n"
@@ -148,6 +149,7 @@ usage (char * progname)" -b fil bindings file location\n" " -w remove a device from the wwids file\n" " -W reset the wwids file include only the current devices\n" +" -k display the links between host and storage\n" " -p pol force all maps to specified path grouping policy :\n" " . failover one path per priority group\n" " . multibus all paths in one priority group\n"
@@ -683,6 +685,9 @@ configure (struct config *conf, enum mpath_cmds cmd,if (get_dm_mpvec (cmd, curmp, pathvec, refwwid)) goto out; +if (cmd ==CMD_LIST_LINKS ) +print_all_links (pathvec,1 ); +filter_pathvec (pathvec, refwwid);if (cmd ==CMD_DUMP_CONFIG ) {
@@ -870,7 +875,7 @@ main (int argc, char *argv[])exit (1 ); multipath_conf = conf; conf->retrigger_tries =0 ; -while ((arg =getopt (argc, argv,":adcChl::FfM:v:p:b:BrR:itTquUwW" )) !=EOF ) { +while ((arg =getopt (argc, argv,":adcChlk::FfM:v:p:b:BrR:itTquUwW" )) !=EOF ) {switch (arg) {case 1 :printf ("optarg : %s\n" ,optarg);break ;
@@ -957,6 +962,9 @@ main (int argc, char *argv[])case 'W' : cmd =CMD_RESET_WWIDS ;break ; +case 'k' : + cmd =CMD_LIST_LINKS ; +break ;case 'a' : cmd =CMD_ADD_WWID ;break ;
Signature · 1 line
2.12.0.windows.1
Hello Guan,
Quoted 13 lines · On Tue, 2018-08-07 at 11:03 +0800, guanjunxiong 00401709 wrote:
From: dingwenyi 00297106 <[email protected]>
This patch adds a new parameter which named -k to display links information in the multipath command.
Command 'multipath -k' display paths with the same host wwn and target wwn as one link information.
The cmd display the following information to quickly and easily find the host and target information.
[root@localhost mp]# ./multipath -k
link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2201333435363738 link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2211333435363738
Thanks for the patch. But I have to say I see little value in adding this option to multipath. What's wrong with simply running "multipathd list paths format %N %R %n %r", or wrapping that command in a simple shell script? Actually, this has nothing to do with multipath at all, it's really transport-related information similar to "lsscsi -t" output.
Regards,
Martin
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
Hi,Martin
Thanks for your reply.
The command "multipathd list paths format %N %R %n %r" or "lsscsi -t" shows all the paths. The new command "multipath -k" removes the path of information with the same host wwn and target wwn, only display the different physical path which is between a server and the storage device in storage networking. We think this command will make it easier to observe physical path information.
Best regards.
Quoted 24 lines · Martin Wilck
Hello Guan,
Quoted 13 lines · On Tue, 2018-08-07 at 11:03 +0800, guanjunxiong 00401709 wrote:
From: dingwenyi 00297106 <[email protected]>
This patch adds a new parameter which named -k to display links information in the multipath command.
Command 'multipath -k' display paths with the same host wwn and target wwn as one link information.
The cmd display the following information to quickly and easily find the host and target information.
[root@localhost mp]# ./multipath -k
link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2201333435363738 link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2211333435363738Thanks for the patch. But I have to say I see little value in adding this option to multipath. What's wrong with simply running "multipathd list paths format %N %R %n %r", or wrapping that command in a simple shell script? Actually, this has nothing to do with multipath at all, it's really transport-related information similar to "lsscsi -t" output.
Quoted 3 lines
Regards,
Martin
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 11 lines · Guan Junxiong
Hi,Martin
Thanks for your reply.
The command "multipathd list paths format %N %R %n %r" or "lsscsi -t" shows all the paths.
The new command "multipath -k" removes the path of information with the same host wwn and
target wwn, only display the different physical path which is between a server and the
storage device in storage networking. We think this command will make it easier to observe
physical path information.
Hm, I'm not getting it. Your own example (below) shows the same host/target WWNN/WWPN tuple twice. Looking at the code, you seem to group SCSI paths that have equal host, channel, device IDs (IOW, you ignore difference by LUN), and take just one path out of each group. I can see that this shortens and simplifies the output, but still it has nothing to do with multipath, and could be achieved otherwise. What about "multipathd list paths format %N %R %n %r | sort -u" ?
Maybe I'm still missing something, but anyway, my main objection is that multipath is not meant as a tool for printing fibre channel topology. There are other tools for this purpose.
Martin
Quoted 38 lines
Best regards.
Quoted 31 lines · Martin Wilck
Hello Guan,
Quoted 14 lines · On Tue, 2018-08-07 at 11:03 +0800, guanjunxiong 00401709 wrote:
From: dingwenyi 00297106 <[email protected]>
This patch adds a new parameter which named -k to display links information in the multipath command.
Command 'multipath -k' display paths with the same host wwn and target wwn as one link information.
The cmd display the following information to quickly and easily find
the host and target information.
[root@localhost mp]# ./multipath -k
link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2201333435363738 link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2211333435363738Thanks for the patch. But I have to say I see little value in adding
this option to multipath. What's wrong with simply running "multipathd list paths format %N %R %n %r", or wrapping that command in
a simple shell script? Actually, this has nothing to do with multipath
at all, it's really transport-related information similar to "lsscsi -t" output.Regards,
Martin
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
Quoted 6 lines · On 08/07/2018 05:03 AM, guanjunxiong 00401709 wrote:
This patch adds a new parameter which named -k to display links information in the multipath command. Command 'multipath -k' display paths with the same host wwn and target wwn as one link information.
The cmd display the following information to quickly and easily find the host and target information. [root@localhost mp]# ./multipath -k
link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2201333435363738 link host_wwnn=0x20000024ff2e8092 host_wwpn=0x21000024ff2e8092 target_wwnn=0x2100333435363738 target_wwpn=0x2211333435363738
This info, in plain text, and a lot more can be extracted from /sys.
There is a tool, systool, to beautify the output:
systool -v -c fc_host
systool -v -c fc_remote_ports
systool -v -c fc_transport
systool -v -c scsi_host
systool -v -c scsi_disk
systool -v -b scsi
systool -v -m lpfc # emulex
systool -v -m qla2xxx # qlogic