multipath: add print_foreign option
Benjamin Marzinski
maintainerPATCH 1/1 multipath: add print_foreign option
This adds a print_foreign multipath.conf defaults option, that allows users to disable printing foreign devices and paths. It defaults to "yes".
--- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/defaults.h | 1 + libmultipath/dict.c | 4 ++++ multipath/main.c | 4 ++-- multipath/multipath.conf.5 | 12 ++++++++++++ multipathd/cli_handlers.c | 40 ++++++++++++++++++++++++++++++-------- 7 files changed, 53 insertions(+), 10 deletions(-)
libmultipath/config.c +1 -0
@@ -717,6 +717,7 @@ load_config (char * file) conf->remove_retries =0 ; conf->ghost_delay =DEFAULT_GHOST_DELAY ; conf->all_tg_pt =DEFAULT_ALL_TG_PT ; + conf->print_foreign =DEFAULT_PRINT_FOREIGN ;/* * preload default hwtable */
libmultipath/config.h +1 -0
@@ -187,6 +187,7 @@ struct config {int ghost_delay;int find_multipaths_timeout;int marginal_pathgroups; +int print_foreign;unsigned int version[3 ];char * multipath_dir;
libmultipath/defaults.h +1 -0
@@ -48,6 +48,7 @@#define DEFAULT_FIND_MULTIPATHS_TIMEOUT -10#define DEFAULT_UNKNOWN_FIND_MULTIPATHS_TIMEOUT 1#define DEFAULT_ALL_TG_PT ALL_TG_PT_OFF +#define DEFAULT_PRINT_FOREIGN 1#define CHECKINT_UNDEF (~0U)#define DEFAULT_CHECKINT 5
libmultipath/dict.c +4 -0
@@ -1342,6 +1342,9 @@ declare_hw_snprint(all_tg_pt, print_yes_no_undef) declare_def_handler(marginal_pathgroups, set_yes_no) declare_def_snprint(marginal_pathgroups, print_yes_no) +declare_def_handler(print_foreign, set_yes_no) +declare_def_snprint(print_foreign, print_yes_no) +static int def_uxsock_timeout_handler (struct config *conf,vector strvec) {
@@ -1713,6 +1716,7 @@ init_keywords(vector keywords) &def_find_multipaths_timeout_handler, &snprint_def_find_multipaths_timeout);install_keyword ("marginal_pathgroups" , &def_marginal_pathgroups_handler, &snprint_def_marginal_pathgroups); +install_keyword ("print_foreign" , &def_print_foreign_handler, &snprint_def_print_foreign);__deprecated install_keyword ("default_selector" , &def_selector_handler,NULL );__deprecated install_keyword ("default_path_grouping_policy" , &def_pgpolicy_handler,NULL );__deprecated install_keyword ("default_uid_attribute" , &def_uid_attribute_handler,NULL );
multipath/main.c +2 -2
@@ -304,8 +304,8 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)if (cmd ==CMD_LIST_SHORT || cmd ==CMD_LIST_LONG ) {struct config *conf =get_multipath_config (); - -print_foreign_topology (conf->verbosity); +if (conf->print_foreign) +print_foreign_topology (conf->verbosity);put_multipath_config (conf); }
multipath/multipath.conf.5 +12 -0
@@ -1224,6 +1224,18 @@ The default is: \fBno\fR .RE . . +.TP +.B print_foreign +This controls whether or not multipath's path and device listings show natively +multipathed devices, that are not managed by the multipath and multipathd +programs. Currently this only controls wherely native nvme multipathed +devices and paths will be shown. +.RS +.TP +The default is: \fByes\fR +.RE +. +. .\" ---------------------------------------------------------------------------- .SH "blacklist and blacklist_exceptions sections" .\" ----------------------------------------------------------------------------
multipathd/cli_handlers.c +32 -8
@@ -42,9 +42,16 @@ show_paths (char ** r, int * len, struct vectors * vecs, char * style,char * reply, * header;unsigned int maxlen =INITIAL_REPLY_LEN ;int again =1 ; +struct config *conf; +int print_foreign; + + conf =get_multipath_config (); + print_foreign = conf->print_foreign; +put_multipath_config (conf);get_path_layout (vecs->pathvec,1 ); -foreign_path_layout (); +if (print_foreign) +foreign_path_layout (); reply =MALLOC (maxlen);
@@ -63,8 +70,9 @@ show_paths (char ** r, int * len, struct vectors * vecs, char * style, c +=snprint_path (c, reply + maxlen - c, style, pp, pretty); - c +=snprint_foreign_paths (c, reply + maxlen - c, - style, pretty); +if (print_foreign) + c +=snprint_foreign_paths (c, reply + maxlen - c, + style, pretty); again = ((c - reply) == (maxlen -1 ));
@@ -149,9 +157,16 @@ show_maps_topology (char ** r, int * len, struct vectors * vecs)char * reply;unsigned int maxlen =INITIAL_REPLY_LEN ;int again =1 ; +struct config *conf; +int print_foreign; + + conf =get_multipath_config (); + print_foreign = conf->print_foreign; +put_multipath_config (conf);get_path_layout (vecs->pathvec,0 ); -foreign_path_layout (); +if (print_foreign) +foreign_path_layout (); reply =MALLOC (maxlen);
@@ -169,7 +184,8 @@ show_maps_topology (char ** r, int * len, struct vectors * vecs) c +=snprint_multipath_topology (c, reply + maxlen - c, mpp,2 ); } - c +=snprint_foreign_topology (c, reply + maxlen - c,2 ); +if (print_foreign) + c +=snprint_foreign_topology (c, reply + maxlen - c,2 ); again = ((c - reply) == (maxlen -1 ));
@@ -506,9 +522,16 @@ show_maps (char ** r, int *len, struct vectors * vecs, char * style,char * reply;unsigned int maxlen =INITIAL_REPLY_LEN ;int again =1 ; +struct config *conf; +int print_foreign; + + conf =get_multipath_config (); + print_foreign = conf->print_foreign; +put_multipath_config (conf);get_multipath_layout (vecs->mpvec,1 ); -foreign_multipath_layout (); +if (print_foreign) +foreign_multipath_layout (); reply =MALLOC (maxlen);
@@ -531,8 +554,9 @@ show_maps (char ** r, int *len, struct vectors * vecs, char * style, style, mpp, pretty); } - c +=snprint_foreign_multipaths (c, reply + maxlen - c, - style, pretty); +if (print_foreign) + c +=snprint_foreign_multipaths (c, reply + maxlen - c, + style, pretty); again = ((c - reply) == (maxlen -1 ));REALLOC_REPLY (reply, again, maxlen);
Signature · 1 line
2.17.2
Quoted 5 lines · Benjamin Marzinski
This adds a
print_foreignmultipath.conf defaults option, that allows users to disable printing foreign devices and paths. It defaults to "yes".Signed-off-by Benjamin Marzinski <[email protected]>
Quoted 11 lines
--- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/defaults.h | 1 + libmultipath/dict.c | 4 ++++ multipath/main.c | 4 ++-- multipath/multipath.conf.5 | 12 ++++++++++++ multipathd/cli_handlers.c | 40 ++++++++++++++++++++++++++++++---- ---- 7 files changed, 53 insertions(+), 10 deletions(-)
The general idea is good, and has been requested from SUSE, too.
But, as "foreign" is designed to be generic and different foreign libraries might be possible in the future, I'd like to this a bit differently:
enable_foreign = "$REGEXP"
Where REGEXP would be used to match the foreign library names. The default value of REGEXP would be ".*" or "nvme". Users who want to disable printing foreign maps would set it e.g. to "^$", or "NONE".
I'll send a patch soon.
Regards,
Martin