add %g format specifier to 'multipathd show paths format' command
PATCH 1/3 add %g format specifier to 'multipathd show paths format' command
The %g specifier will print the group number of the path when used with multipathd show paths format.
--- libmultipath/print.c | 7 +++++++ 1 file changed, 7 insertions(+)
libmultipath/print.c +7 -0
@@ -293,6 +293,12 @@ snprint_path_uuid (char * buff, size_t len, struct path * pp)return snprint_str (buff, len, pp->wwid); } +static int snprint_path_groupnumber (char * buff,size_t len,struct path * pp) +{ +return snprint_int (buff, len, pp->pgindex); +} + +static int snprint_hcil (char * buff,size_t len,struct path * pp) {
@@ -576,6 +582,7 @@ struct path_data pd[] = { {'i', "hcil", 0, snprint_hcil}, {'d', "dev", 0, snprint_dev}, {'D', "dev_t", 0, snprint_dev_t}, + {'g', "group", 0, snprint_path_groupnumber}, {'t', "dm_st", 0, snprint_dm_path_state}, {'o', "dev_st", 0, snprint_offline}, {'T', "chk_st", 0, snprint_chk_state},
Signature · 1 line
2.5.0
PATCH 2/3 add 'show groups' command to multipathd
Command allows user to display pathgroups. This is a step towards allowing a user to parse the output of multipathd and be able to understand the groups.
--- libmultipath/print.c | 73 +++++++++++++++++++++++++++++++++++++++++------ libmultipath/print.h | 9 ++++-- multipathd/cli.c | 2 ++ multipathd/cli.h | 2 ++ multipathd/cli_handlers.c | 59 ++++++++++++++++++++++++++++++++++++++ multipathd/cli_handlers.h | 1 + multipathd/main.c | 1 + 7 files changed, 137 insertions(+), 10 deletions(-)
libmultipath/print.c +65 -8
@@ -406,13 +406,13 @@ snprint_pri (char * buff, size_t len, struct path * pp) }static int -snprint_pg_selector (char * buff,size_t len,struct pathgroup * pgp) +snprint_pg_selector (char * buff,size_t len,struct pathgroup * pgp,int group) {return snprint_str (buff, len, pgp->selector); }static int -snprint_pg_pri (char * buff,size_t len,struct pathgroup * pgp) +snprint_pg_pri (char * buff,size_t len,struct pathgroup * pgp,int group) {/* * path group priority is not updated for every path prio change,
@@ -425,7 +425,7 @@ snprint_pg_pri (char * buff, size_t len, struct pathgroup * pgp) }static int -snprint_pg_state (char * buff,size_t len,struct pathgroup * pgp) +snprint_pg_state (char * buff,size_t len,struct pathgroup * pgp,int group) {switch (pgp->status) {case PGSTATE_ENABLED :
@@ -648,6 +648,30 @@ get_path_layout (vector pathvec, int header) } } +void +get_pathgroup_layout (vector mpvec,int header) +{ +int i, j, k; +char buff[MAX_FIELD_LEN ]; +struct pathgroup * pgp; +struct multipath * mpp; + +for (i =0 ; pgd[i].header; i++) { +if (header) + pgd[i].width =strlen (pgd[i].header); +else + pgd[i].width =0 ; + + vector_foreach_slot (mpvec, mpp, j) { + vector_foreach_slot (mpp->pg, pgp, k) { + pgp->selector = mpp->selector;/* hack */ + pgd[i].snprint (buff,MAX_FIELD_LEN , pgp, k); + pgd[i].width =MAX (pgd[i].width,strlen (buff)); + } + } + } +} +static void reset_multipath_layout (void ) {
@@ -856,7 +880,7 @@ snprint_path (char * line, int len, char * format,int snprint_pathgroup (char * line,int len,char * format, -struct pathgroup * pgp) +struct pathgroup * pgp,int group) {char * c = line;/* line cursor */ char * s = line;/* for padding */
@@ -881,7 +905,7 @@ snprint_pathgroup (char * line, int len, char * format,if (!(data =pgd_lookup (*f)))continue ; - data->snprint (buff,MAX_FIELD_LEN , pgp); + data->snprint (buff,MAX_FIELD_LEN , pgp, group);TAIL ,"%s" , buff);PAD (data->width); }while (*f++);
@@ -890,6 +914,39 @@ snprint_pathgroup (char * line, int len, char * format,return (c - line); } +int +snprint_pathgroup_header (char * line,int len,char * format) +{ +char * c = line;/* line cursor */ +char * s = line;/* for padding */ +char * f = format;/* format string cursor */ +int fwd; +struct pathgroup_data * data; + +memset (line,0 , len); + +do { +if (!TAIL ) +break ; + +if (*f !='%' ) { + *c++ = *f; +NOPAD ; +continue ; + } + f++; + +if (!(data =pgd_lookup (*f))) +continue ;/* unknown wildcard */ + +TAIL ,"%s" , data->header); +PAD (data->width); + }while (*f++); + +ENDLINE ; +return (c - line); +} +extern void print_multipath_topology (struct multipath * mpp,int verbosity) {
@@ -976,7 +1033,7 @@ snprint_multipath_topology (char * buff, int len, struct multipath * mpp,strcpy (f,"|-+- " PRINT_PG_INDENT ); }else strcpy (f,"`-+- " PRINT_PG_INDENT ); - fwd +=snprint_pathgroup (buff + fwd, len - fwd, fmt, pgp); + fwd +=snprint_pathgroup (buff + fwd, len - fwd, fmt, pgp, j);if (fwd > len)return len;
@@ -1566,12 +1623,12 @@ print_multipath (struct multipath * mpp, char * style) }extern void -print_pathgroup (struct pathgroup * pgp,char * style) +print_pathgroup (struct pathgroup * pgp,char * style,int group) {char line[MAX_LINE_LEN ];memset (&line[0 ],0 ,MAX_LINE_LEN ); -snprint_pathgroup (&line[0 ],MAX_LINE_LEN , style, pgp); +snprint_pathgroup (&line[0 ],MAX_LINE_LEN , style, pgp, group);printf ("%s" , line); }
libmultipath/print.h +7 -2
@@ -1,6 +1,7 @@#define PRINT_PATH_LONG "%w %i %d %D %p %t %T %s %o"#define PRINT_PATH_INDENT "%i %d %D %t %T %o"#define PRINT_PATH_CHECKER "%i %d %D %p %t %T %o %C" +#define PRINT_GROUP_CHECKER "%s %p %t"#define PRINT_MAP_STATUS "%n %F %Q %N %t %r"#define PRINT_MAP_STATS "%n %0 %1 %2 %3 %4"#define PRINT_MAP_NAMES "%n %d %w"
@@ -30,14 +31,18 @@ struct pathgroup_data {char wildcard;char * header;int width; -int (*snprint)(char * buff,size_t len,struct pathgroup * pgp); +int (*snprint)(char * buff,size_t len,struct pathgroup * pgp,int group); };void get_path_layout (vector pathvec,int header);void get_multipath_layout (vector mpvec,int header); +void get_pathgroup_layout (vector mpvec,int header);int snprint_path_header (char *,int ,char *);int snprint_multipath_header (char *,int ,char *); +int snprint_pathgroup_header (char *,int ,char *);int snprint_path (char *,int ,char *,struct path *,int ); +int snprint_pathgroup (char * line,int len,char * format, +struct pathgroup * pgp,int group);int snprint_multipath (char *,int ,char *,struct multipath *,int );int snprint_multipath_topology (char *,int ,struct multipath * mpp,int verbosity);
@@ -55,7 +60,7 @@ int snprint_overrides (char *, int, struct hwentry *);void print_multipath_topology (struct multipath * mpp,int verbosity);void print_path (struct path * pp,char * style);void print_multipath (struct multipath * mpp,char * style); -void print_pathgroup (struct pathgroup * pgp,char * style); +void print_pathgroup (struct pathgroup * pgp,char * style,int group);void print_map (struct multipath * mpp,char * params);void print_all_paths (vector pathvec,int banner);void print_all_paths_custo (vector pathvec,int banner,char *fmt);
multipathd/cli.c +2 -0
@@ -168,6 +168,7 @@ load_keys (void) r +=add_key (keys,"paths" ,PATHS ,0 ); r +=add_key (keys,"maps" ,MAPS ,0 ); r +=add_key (keys,"multipaths" ,MAPS ,0 ); + r +=add_key (keys,"groups" ,GROUPS ,0 ); r +=add_key (keys,"path" ,PATH ,1 ); r +=add_key (keys,"map" ,MAP ,1 ); r +=add_key (keys,"multipath" ,MAP ,1 );
@@ -474,6 +475,7 @@ cli_init (void) {add_handler (LIST +MAPS +FMT ,NULL );add_handler (LIST +MAPS +RAW +FMT ,NULL );add_handler (LIST +MAPS +TOPOLOGY ,NULL ); +add_handler (LIST +GROUPS ,NULL );add_handler (LIST +TOPOLOGY ,NULL );add_handler (LIST +MAP +TOPOLOGY ,NULL );add_handler (LIST +CONFIG ,NULL );
multipathd/cli.h +2 -0
@@ -15,6 +15,7 @@ enum { __RESTOREQ, __PATHS, __MAPS, + __GROUPS, __PATH, __MAP, __GROUP,
@@ -55,6 +56,7 @@ enum {#define PATH (1 << __PATH)#define MAP (1 << __MAP)#define GROUP (1 << __GROUP) +#define GROUPS (1 << __GROUPS)#define RECONFIGURE (1 << __RECONFIGURE)#define DAEMON (1 << __DAEMON)#define STATUS (1 << __STATUS)
multipathd/cli_handlers.c +59 -0
71 lines not on this page · raw message
multipathd/cli_handlers.h +1 -0
@@ -4,6 +4,7 @@ int cli_list_paths_raw (void * v, char ** reply, int * len, void * data);int cli_list_path (void * v,char ** reply,int * len,void * data);int cli_list_status (void * v,char ** reply,int * len,void * data);int cli_list_daemon (void * v,char ** reply,int * len,void * data); +int cli_list_groups (void * v,char ** reply,int * len,void * data);int cli_list_maps (void * v,char ** reply,int * len,void * data);int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data);int cli_list_maps_raw (void * v,char ** reply,int * len,void * data);
multipathd/main.c +1 -0
@@ -904,6 +904,7 @@ uxlsnrloop (void * ap)set_handler_callback (LIST +PATHS +RAW +FMT , cli_list_paths_raw);set_handler_callback (LIST +PATH , cli_list_path);set_handler_callback (LIST +MAPS , cli_list_maps); +set_handler_callback (LIST +GROUPS , cli_list_groups);set_handler_callback (LIST +STATUS , cli_list_status);set_handler_callback (LIST +DAEMON , cli_list_daemon);set_handler_callback (LIST +MAPS +STATUS , cli_list_maps_status);
Signature · 1 line
2.5.0
PATCH 3/3 add options to the show groups command
In reply to Todd GillOptions:
format - allow the user to specify output format via wildcards
raw - don't display headers for formatted output %w - display the WWN for the map that contains the group %g - display the group number
These options allow a user to parse the output to connect a pathgroup to the multipath map. It also allows a user to determine the member paths of a pathgroup.
--- libmultipath/print.c | 18 ++++++++++++++++++ libmultipath/print.h | 2 +- multipathd/cli.c | 2 ++ multipathd/cli_handlers.c | 22 ++++++++++++++++++++++ multipathd/cli_handlers.h | 2 ++ multipathd/main.c | 2 ++ 6 files changed, 47 insertions(+), 1 deletion(-)
libmultipath/print.c +18 -0
@@ -412,6 +412,22 @@ snprint_pg_selector (char * buff, size_t len, struct pathgroup * pgp, int group) }static int +snprint_pg_uuid (char * buff,size_t len,struct pathgroup * pgp,int group_num) +{ +struct path * pp; + + pp =VECTOR_LAST_SLOT (pgp->paths); +return snprint_str (buff, len, pp->wwid); +} + +static int +snprint_pg_group (char * buff,size_t len,struct pathgroup * pgp, +int group_num) +{ +return snprint_int (buff, len, group_num); +} + +static int snprint_pg_pri (char * buff,size_t len,struct pathgroup * pgp,int group) {/*
@@ -602,7 +618,9 @@ struct path_data pd[] = { };struct pathgroup_data pgd[] = { + {'w' ,"uuid" ,0 , snprint_pg_uuid}, {'s' ,"selector" ,0 , snprint_pg_selector}, + {'g' ,"group" ,0 , snprint_pg_group}, {'p' ,"pri" ,0 , snprint_pg_pri}, {'t' ,"dm_st" ,0 , snprint_pg_state}, {0 ,NULL ,0 ,NULL }
libmultipath/print.h +1 -1
@@ -1,7 +1,7 @@#define PRINT_PATH_LONG "%w %i %d %D %p %t %T %s %o"#define PRINT_PATH_INDENT "%i %d %D %t %T %o"#define PRINT_PATH_CHECKER "%i %d %D %p %t %T %o %C" -#define PRINT_GROUP_CHECKER "%s %p %t" +#define PRINT_GROUP_CHECKER "%w %g %s %p %t"#define PRINT_MAP_STATUS "%n %F %Q %N %t %r"#define PRINT_MAP_STATS "%n %0 %1 %2 %3 %4"#define PRINT_MAP_NAMES "%n %d %w"
multipathd/cli.c +2 -0
@@ -476,6 +476,8 @@ cli_init (void) {add_handler (LIST +MAPS +RAW +FMT ,NULL );add_handler (LIST +MAPS +TOPOLOGY ,NULL );add_handler (LIST +GROUPS ,NULL ); +add_handler (LIST +GROUPS +FMT ,NULL ); +add_handler (LIST +GROUPS +RAW +FMT ,NULL );add_handler (LIST +TOPOLOGY ,NULL );add_handler (LIST +MAP +TOPOLOGY ,NULL );add_handler (LIST +CONFIG ,NULL );
multipathd/cli_handlers.c +22 -0
@@ -444,6 +444,28 @@ cli_list_groups (void * v, char ** reply, int * len, void * data) }int +cli_list_groups_fmt (void * v,char ** reply,int * len,void * data) +{ +struct vectors * vecs = (struct vectors *)data; +char * fmt =get_keyparam (v,FMT ); + +condlog (3 ,"list groups (operator)" ); + +return show_groups (reply, len, vecs, fmt,1 ); +} + +int +cli_list_groups_raw (void * v,char ** reply,int * len,void * data) +{ +struct vectors * vecs = (struct vectors *)data; +char * fmt =get_keyparam (v,FMT ); + +condlog (3 ,"list groups (operator)" ); + +return show_groups (reply, len, vecs, fmt,0 ); +} + +int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data) {struct vectors * vecs = (struct vectors *)data;
multipathd/cli_handlers.h +2 -0
@@ -5,6 +5,8 @@ int cli_list_path (void * v, char ** reply, int * len, void * data);int cli_list_status (void * v,char ** reply,int * len,void * data);int cli_list_daemon (void * v,char ** reply,int * len,void * data);int cli_list_groups (void * v,char ** reply,int * len,void * data); +int cli_list_groups_fmt (void * v,char ** reply,int * len,void * data); +int cli_list_groups_raw (void * v,char ** reply,int * len,void * data);int cli_list_maps (void * v,char ** reply,int * len,void * data);int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data);int cli_list_maps_raw (void * v,char ** reply,int * len,void * data);
multipathd/main.c +2 -0
@@ -905,6 +905,8 @@ uxlsnrloop (void * ap)set_handler_callback (LIST +PATH , cli_list_path);set_handler_callback (LIST +MAPS , cli_list_maps);set_handler_callback (LIST +GROUPS , cli_list_groups); +set_handler_callback (LIST +GROUPS +FMT , cli_list_groups_fmt); +set_handler_callback (LIST +GROUPS +RAW +FMT , cli_list_groups_raw);set_handler_callback (LIST +STATUS , cli_list_status);set_handler_callback (LIST +DAEMON , cli_list_daemon);set_handler_callback (LIST +MAPS +STATUS , cli_list_maps_status);
Signature · 1 line
2.5.0
Benjamin Marzinski
maintainerQuoted 2 lines · Todd Gill
The %g specifier will print the group number of the path when used with multipathd show paths format.
The set looks good to me.
-Ben
Quoted 38 lines
Signed-off-by Todd Gill <[email protected]>--- libmultipath/print.c | 7 +++++++ 1 file changed, 7 insertions(+)libmultipath/print.c +7
-0@@ -293,6 +293,12 @@ snprint_path_uuid (char * buff, size_t len, struct path * pp)return snprint_str (buff, len, pp->wwid); } +static int snprint_path_groupnumber (char * buff,size_t len,struct path * pp) +{ +return snprint_int (buff, len, pp->pgindex); +} + +static int snprint_hcil (char * buff,size_t len,struct path * pp) {@@ -576,6 +582,7 @@ struct path_data pd[] = { {'i', "hcil", 0, snprint_hcil}, {'d', "dev", 0, snprint_dev}, {'D', "dev_t", 0, snprint_dev_t}, + {'g', "group", 0, snprint_path_groupnumber}, {'t', "dm_st", 0, snprint_dm_path_state}, {'o', "dev_st", 0, snprint_offline}, {'T', "chk_st", 0, snprint_chk_state},Signature · 6 lines
2.5.0 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
PATCH v2 1/3 Add %g format specifier to 'multipathd show paths format' command
In reply to Todd GillThe %g specifier will print the group number of the path when used with multipathd show paths format.
--- libmultipath/print.c | 6 ++++++ 1 file changed, 6 insertions(+)
libmultipath/print.c +6 -0
@@ -293,6 +293,11 @@ snprint_path_uuid (char * buff, size_t len, struct path * pp)return snprint_str (buff, len, pp->wwid); } +static int snprint_path_groupnumber (char * buff,size_t len,struct path * pp) +{ +return snprint_int (buff, len, pp->pgindex); +} +static int snprint_hcil (char * buff,size_t len,struct path * pp) {
@@ -576,6 +581,7 @@ struct path_data pd[] = { {'i', "hcil", 0, snprint_hcil}, {'d', "dev", 0, snprint_dev}, {'D', "dev_t", 0, snprint_dev_t}, + {'g', "group", 0, snprint_path_groupnumber}, {'t', "dm_st", 0, snprint_dm_path_state}, {'o', "dev_st", 0, snprint_offline}, {'T', "chk_st", 0, snprint_chk_state},
Signature · 1 line
2.5.0
PATCH v2 2/3 Add 'show groups' command to multipathd
Command allows user to display pathgroups. This is a step towards allowing a user to parse the output of multipathd and be able to understand the groups.
Changes by Gris: (changes since v1)
* Remove 'update_multipath()' in show_groups() as it only update path status which is not required for path group query.
* Disable white space padding in raw mode.
* Display first group as 1 not 0
--- libmultipath/print.c | 76 ++++++++++++++++++++++++++++++++++++++++++----- libmultipath/print.h | 9 ++++-- multipathd/cli.c | 2 ++ multipathd/cli.h | 4 ++- multipathd/cli_handlers.c | 58 ++++++++++++++++++++++++++++++++++-- multipathd/cli_handlers.h | 1 + multipathd/main.c | 1 + 7 files changed, 138 insertions(+), 13 deletions(-)
libmultipath/print.c +68 -8
@@ -405,13 +405,13 @@ snprint_pri (char * buff, size_t len, struct path * pp) }static int -snprint_pg_selector (char * buff,size_t len,struct pathgroup * pgp) +snprint_pg_selector (char * buff,size_t len,struct pathgroup * pgp,int group) {return snprint_str (buff, len, pgp->selector); }static int -snprint_pg_pri (char * buff,size_t len,struct pathgroup * pgp) +snprint_pg_pri (char * buff,size_t len,struct pathgroup * pgp,int group) {/* * path group priority is not updated for every path prio change,
@@ -424,7 +424,7 @@ snprint_pg_pri (char * buff, size_t len, struct pathgroup * pgp) }static int -snprint_pg_state (char * buff,size_t len,struct pathgroup * pgp) +snprint_pg_state (char * buff,size_t len,struct pathgroup * pgp,int group) {switch (pgp->status) {case PGSTATE_ENABLED :
@@ -647,6 +647,30 @@ get_path_layout (vector pathvec, int header) } } +void +get_pathgroup_layout (vector mpvec,int header) +{ +int i, j, k; +char buff[MAX_FIELD_LEN ]; +struct pathgroup * pgp; +struct multipath * mpp; + +for (i =0 ; pgd[i].header; i++) { +if (header) + pgd[i].width =strlen (pgd[i].header); +else + pgd[i].width =0 ; + + vector_foreach_slot (mpvec, mpp, j) { + vector_foreach_slot (mpp->pg, pgp, k) { + pgp->selector = mpp->selector;/* hack */ + pgd[i].snprint (buff,MAX_FIELD_LEN , pgp, k); + pgd[i].width =MAX (pgd[i].width,strlen (buff)); + } + } + } +} +static void reset_multipath_layout (void ) {
@@ -855,7 +879,7 @@ snprint_path (char * line, int len, char * format,int snprint_pathgroup (char * line,int len,char * format, -struct pathgroup * pgp) +struct pathgroup * pgp,int group,int pad) {char * c = line;/* line cursor */ char * s = line;/* for padding */
@@ -880,8 +904,42 @@ snprint_pathgroup (char * line, int len, char * format,if (!(data =pgd_lookup (*f)))continue ; - data->snprint (buff,MAX_FIELD_LEN , pgp); + data->snprint (buff,MAX_FIELD_LEN , pgp, group);TAIL ,"%s" , buff); +if (pad) +PAD (data->width); + }while (*f++); + +ENDLINE ; +return (c - line); +} + +int +snprint_pathgroup_header (char * line,int len,char * format) +{ +char * c = line;/* line cursor */ +char * s = line;/* for padding */ +char * f = format;/* format string cursor */ +int fwd; +struct pathgroup_data * data; + +memset (line,0 , len); + +do { +if (!TAIL ) +break ; + +if (*f !='%' ) { + *c++ = *f; +NOPAD ; +continue ; + } + f++; + +if (!(data =pgd_lookup (*f))) +continue ;/* unknown wildcard */ + +TAIL ,"%s" , data->header);PAD (data->width); }while (*f++);
@@ -975,7 +1033,8 @@ snprint_multipath_topology (char * buff, int len, struct multipath * mpp,strcpy (f,"|-+- " PRINT_PG_INDENT ); }else strcpy (f,"`-+- " PRINT_PG_INDENT ); - fwd +=snprint_pathgroup (buff + fwd, len - fwd, fmt, pgp); + fwd +=snprint_pathgroup (buff + fwd, len - fwd, fmt, pgp, j, +1 /*padding*/ );if (fwd > len)return len;
@@ -1565,12 +1624,13 @@ print_multipath (struct multipath * mpp, char * style) }extern void -print_pathgroup (struct pathgroup * pgp,char * style) +print_pathgroup (struct pathgroup * pgp,char * style,int group) {char line[MAX_LINE_LEN ];memset (&line[0 ],0 ,MAX_LINE_LEN ); -snprint_pathgroup (&line[0 ],MAX_LINE_LEN , style, pgp); +snprint_pathgroup (&line[0 ],MAX_LINE_LEN , style, pgp, group, +1 /*padding*/ );printf ("%s" , line); }
libmultipath/print.h +7 -2
@@ -1,6 +1,7 @@#define PRINT_PATH_LONG "%w %i %d %D %p %t %T %s %o"#define PRINT_PATH_INDENT "%i %d %D %t %T %o"#define PRINT_PATH_CHECKER "%i %d %D %p %t %T %o %C" +#define PRINT_GROUP_CHECKER "%s %p %t"#define PRINT_MAP_STATUS "%n %F %Q %N %t %r"#define PRINT_MAP_STATS "%n %0 %1 %2 %3 %4"#define PRINT_MAP_NAMES "%n %d %w"
@@ -30,14 +31,18 @@ struct pathgroup_data {char wildcard;char * header;int width; -int (*snprint)(char * buff,size_t len,struct pathgroup * pgp); +int (*snprint)(char * buff,size_t len,struct pathgroup * pgp,int group); };void get_path_layout (vector pathvec,int header);void get_multipath_layout (vector mpvec,int header); +void get_pathgroup_layout (vector mpvec,int header);int snprint_path_header (char *,int ,char *);int snprint_multipath_header (char *,int ,char *); +int snprint_pathgroup_header (char *,int ,char *);int snprint_path (char *,int ,char *,struct path *,int ); +int snprint_pathgroup (char * line,int len,char * format, +struct pathgroup * pgp,int group,int pad);int snprint_multipath (char *,int ,char *,struct multipath *,int );int snprint_multipath_topology (char *,int ,struct multipath * mpp,int verbosity);
@@ -55,7 +60,7 @@ int snprint_overrides (char *, int, struct hwentry *);void print_multipath_topology (struct multipath * mpp,int verbosity);void print_path (struct path * pp,char * style);void print_multipath (struct multipath * mpp,char * style); -void print_pathgroup (struct pathgroup * pgp,char * style); +void print_pathgroup (struct pathgroup * pgp,char * style,int group);void print_map (struct multipath * mpp,char * params);void print_all_paths (vector pathvec,int banner);void print_all_paths_custo (vector pathvec,int banner,char *fmt);
multipathd/cli.c +2 -0
@@ -168,6 +168,7 @@ load_keys (void) r +=add_key (keys,"paths" ,PATHS ,0 ); r +=add_key (keys,"maps" ,MAPS ,0 ); r +=add_key (keys,"multipaths" ,MAPS ,0 ); + r +=add_key (keys,"groups" ,GROUPS ,0 ); r +=add_key (keys,"path" ,PATH ,1 ); r +=add_key (keys,"map" ,MAP ,1 ); r +=add_key (keys,"multipath" ,MAP ,1 );
@@ -474,6 +475,7 @@ cli_init (void) {add_handler (LIST +MAPS +FMT ,NULL );add_handler (LIST +MAPS +RAW +FMT ,NULL );add_handler (LIST +MAPS +TOPOLOGY ,NULL ); +add_handler (LIST +GROUPS ,NULL );add_handler (LIST +TOPOLOGY ,NULL );add_handler (LIST +MAP +TOPOLOGY ,NULL );add_handler (LIST +CONFIG ,NULL );
multipathd/cli.h +3 -1
@@ -15,6 +15,7 @@ enum { __RESTOREQ, __PATHS, __MAPS, + __GROUPS, __PATH, __MAP, __GROUP,
@@ -55,6 +56,7 @@ enum {#define PATH (1 << __PATH)#define MAP (1 << __MAP)#define GROUP (1 << __GROUP) +#define GROUPS (1 << __GROUPS)#define RECONFIGURE (1 << __RECONFIGURE)#define DAEMON (1 << __DAEMON)#define STATUS (1 << __STATUS)
@@ -67,7 +69,7 @@ enum {#define COUNT (1 << __COUNT)#define WILDCARDS (1 << __WILDCARDS)#define QUIT (1 << __QUIT) -#define SHUTDOWN (1 << __SHUTDOWN) +#define SHUTDOWN (1UL << __SHUTDOWN)#define GETPRSTATUS (1UL << __GETPRSTATUS)#define SETPRSTATUS (1UL << __SETPRSTATUS)#define UNSETPRSTATUS (1UL << __UNSETPRSTATUS)
multipathd/cli_handlers.c +56 -2
82 lines not on this page · raw message
multipathd/cli_handlers.h +1 -0
@@ -4,6 +4,7 @@ int cli_list_paths_raw (void * v, char ** reply, int * len, void * data);int cli_list_path (void * v,char ** reply,int * len,void * data);int cli_list_status (void * v,char ** reply,int * len,void * data);int cli_list_daemon (void * v,char ** reply,int * len,void * data); +int cli_list_groups (void * v,char ** reply,int * len,void * data);int cli_list_maps (void * v,char ** reply,int * len,void * data);int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data);int cli_list_maps_raw (void * v,char ** reply,int * len,void * data);
multipathd/main.c +1 -0
@@ -904,6 +904,7 @@ uxlsnrloop (void * ap)set_handler_callback (LIST +PATHS +RAW +FMT , cli_list_paths_raw);set_handler_callback (LIST +PATH , cli_list_path);set_handler_callback (LIST +MAPS , cli_list_maps); +set_handler_callback (LIST +GROUPS , cli_list_groups);set_handler_callback (LIST +STATUS , cli_list_status);set_handler_callback (LIST +DAEMON , cli_list_daemon);set_handler_callback (LIST +MAPS +STATUS , cli_list_maps_status);
Signature · 1 line
2.5.0
PATCH v2 3/3 Add options to the show groups command
In reply to Todd GillOptions:
format - allow the user to specify output format via wildcards
raw - don't display headers for formatted output %w - display the WWN for the map that contains the group %g - display the group number
These options allow a user to parse the output to connect a pathgroup to the multipath map. It also allows a user to determine the member paths of a pathgroup.
--- libmultipath/print.c | 21 +++++++++++++++++++++ libmultipath/print.h | 2 +- multipathd/cli.c | 2 ++ multipathd/cli_handlers.c | 22 ++++++++++++++++++++++ multipathd/cli_handlers.h | 2 ++ multipathd/main.c | 2 ++ 6 files changed, 50 insertions(+), 1 deletion(-)
libmultipath/print.c +21 -0
@@ -411,6 +411,25 @@ snprint_pg_selector (char * buff, size_t len, struct pathgroup * pgp, int group) }static int +snprint_pg_uuid (char * buff,size_t len,struct pathgroup * pgp,int group_num) +{ +struct path * pp; + + pp =VECTOR_LAST_SLOT (pgp->paths); +if (pp !=NULL ) +return snprint_str (buff, len, pp->wwid); +else +return snprint_str (buff, len,"" ); +} + +static int +snprint_pg_group (char * buff,size_t len,struct pathgroup * pgp, +int group_num) +{ +return snprint_int (buff, len, group_num); +} + +static int snprint_pg_pri (char * buff,size_t len,struct pathgroup * pgp,int group) {/*
@@ -601,7 +620,9 @@ struct path_data pd[] = { };struct pathgroup_data pgd[] = { + {'w' ,"uuid" ,0 , snprint_pg_uuid}, {'s' ,"selector" ,0 , snprint_pg_selector}, + {'g' ,"group" ,0 , snprint_pg_group}, {'p' ,"pri" ,0 , snprint_pg_pri}, {'t' ,"dm_st" ,0 , snprint_pg_state}, {0 ,NULL ,0 ,NULL }
libmultipath/print.h +1 -1
@@ -1,7 +1,7 @@#define PRINT_PATH_LONG "%w %i %d %D %p %t %T %s %o"#define PRINT_PATH_INDENT "%i %d %D %t %T %o"#define PRINT_PATH_CHECKER "%i %d %D %p %t %T %o %C" -#define PRINT_GROUP_CHECKER "%s %p %t" +#define PRINT_GROUP_CHECKER "%w %g %s %p %t"#define PRINT_MAP_STATUS "%n %F %Q %N %t %r"#define PRINT_MAP_STATS "%n %0 %1 %2 %3 %4"#define PRINT_MAP_NAMES "%n %d %w"
multipathd/cli.c +2 -0
@@ -476,6 +476,8 @@ cli_init (void) {add_handler (LIST +MAPS +RAW +FMT ,NULL );add_handler (LIST +MAPS +TOPOLOGY ,NULL );add_handler (LIST +GROUPS ,NULL ); +add_handler (LIST +GROUPS +FMT ,NULL ); +add_handler (LIST +GROUPS +RAW +FMT ,NULL );add_handler (LIST +TOPOLOGY ,NULL );add_handler (LIST +MAP +TOPOLOGY ,NULL );add_handler (LIST +CONFIG ,NULL );
multipathd/cli_handlers.c +22 -0
@@ -439,6 +439,28 @@ cli_list_groups (void * v, char ** reply, int * len, void * data) }int +cli_list_groups_fmt (void * v,char ** reply,int * len,void * data) +{ +struct vectors * vecs = (struct vectors *)data; +char * fmt =get_keyparam (v,FMT ); + +condlog (3 ,"list groups (operator)" ); + +return show_groups (reply, len, vecs, fmt,1 ); +} + +int +cli_list_groups_raw (void * v,char ** reply,int * len,void * data) +{ +struct vectors * vecs = (struct vectors *)data; +char * fmt =get_keyparam (v,FMT ); + +condlog (3 ,"list groups (operator)" ); + +return show_groups (reply, len, vecs, fmt,0 ); +} + +int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data) {struct vectors * vecs = (struct vectors *)data;
multipathd/cli_handlers.h +2 -0
@@ -5,6 +5,8 @@ int cli_list_path (void * v, char ** reply, int * len, void * data);int cli_list_status (void * v,char ** reply,int * len,void * data);int cli_list_daemon (void * v,char ** reply,int * len,void * data);int cli_list_groups (void * v,char ** reply,int * len,void * data); +int cli_list_groups_fmt (void * v,char ** reply,int * len,void * data); +int cli_list_groups_raw (void * v,char ** reply,int * len,void * data);int cli_list_maps (void * v,char ** reply,int * len,void * data);int cli_list_maps_fmt (void * v,char ** reply,int * len,void * data);int cli_list_maps_raw (void * v,char ** reply,int * len,void * data);
multipathd/main.c +2 -0
@@ -905,6 +905,8 @@ uxlsnrloop (void * ap)set_handler_callback (LIST +PATH , cli_list_path);set_handler_callback (LIST +MAPS , cli_list_maps);set_handler_callback (LIST +GROUPS , cli_list_groups); +set_handler_callback (LIST +GROUPS +FMT , cli_list_groups_fmt); +set_handler_callback (LIST +GROUPS +RAW +FMT , cli_list_groups_raw);set_handler_callback (LIST +STATUS , cli_list_status);set_handler_callback (LIST +DAEMON , cli_list_daemon);set_handler_callback (LIST +MAPS +STATUS , cli_list_maps_status);
Signature · 1 line
2.5.0