configuration overhaul and find_multipaths
Benjamin Marzinski
maintainercover configuration overhaul and find_multipaths
Since the first time I sent them, they got no response at all, I'm resending the alternative solution to my all_devs patch, which uses a whole new multipath.conf section. "overrides"
Adding an overrides section to the existing multipath configuration system would have involved a lot (over 1500 lines) of mostly copy/paste code. Intead of doing that, I overhauled dict.c and propsel.c to use macros to cut down on code duplication. This made adding the new section much easier.
Also, I'm resending my find_multipaths patch, based on the conversation I had here.
http://www.redhat.com/archives/dm-devel/2014-July/msg00029.html
Just to clarify. find_multipaths is a configurable option that when set to 'yes' will make multipath only run on devices have more than one path. This means that users can mostly leave the blacklist alone, and they will only get the multipath devices that they want. The only time the blacklist is necessary is when users actually have multiple paths to a device, but still don't want multipath set up on it. It's been around since RHEL6, and it is turned on in the default multipath.conf file in RHEL7. The internal default is "off".
Benjamin Marzinski (6):
libmultipath: rewrite dict.c with function generation macros
libmultipath: cleanup propsel.c with macros for common actions
libmultipath: add overrides section to multipath.conf add find_multipaths option
correctly set partition delimiter on rename
libmultipath: only add uninitialized paths in check_path
libmultipath/config.c | 10 +- libmultipath/config.h | 3 + libmultipath/configure.c | 11 + libmultipath/defaults.h | 3 +- libmultipath/devmapper.c | 14 +- libmultipath/dict.c | 3221 +++++++++++--------------------------------- libmultipath/dict.h | 7 + libmultipath/discovery.c | 2 + libmultipath/pgpolicies.c | 2 +- libmultipath/print.c | 30 + libmultipath/print.h | 1 + libmultipath/propsel.c | 761 +++++------ libmultipath/structs.c | 9 +- libmultipath/structs.h | 45 +- libmultipath/wwids.c | 26 + libmultipath/wwids.h | 1 + multipath.conf.annotated | 18 +- multipath.conf.defaults | 2 + multipath.conf.synthetic | 3 + multipath/main.c | 33 +- multipath/multipath.conf.5 | 57 + multipathd/cli_handlers.c | 10 + multipathd/main.c | 9 + 23 files changed, 1375 insertions(+), 2903 deletions(-)
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 1/6 libmultipath: rewrite dict.c with function generation macros
dict.c is full of nearly identical functions for setting and printing the configuration. Many options use the exact same function with just the variable name changing. For options that exist in multiple sections of multipath.conf, the functions for setting and printing the option are also nearly identical, except for the config structure that is used.
In order to avoid this massive amount of code duplication, and also to standardize and avoid copy/paste errors, I've written some standard functions with the most common setting and printing code, and some macros that take the setting and printing functions, and add the boilerplate code that is necessary for the different sections. This means that there is at most one unique function to set and print an option, regardless of home many sections is appears in. Options that just set a string or integer don't even need their own function. They can use one of the generic ones.
There's one trade-off that I'm not sure I chose the right way on. In order to keep the number of macros down, I made them transfer the data using void pointers. This means that the macro works regardless of whether the data is a signed or unsigned int or a string or whatever. The downside to this is that there isn't type checking. This means that if, for instance, someone called a function that expected a string, but passed in an integer. The complier wouldn't catch the error.
declare_def_snprint(verbosity, print_str)
as an example, would happily treat &conf->verbosity as a string pointer. I'm not sure how worried people are about this, but it wouldn't be too hard to add a bunch more declare_* macros so that each was typed.
--- libmultipath/config.c | 5 +- libmultipath/defaults.h | 2 - libmultipath/dict.c | 3097 +++++++++++------------------------------------ libmultipath/structs.h | 44 +- 4 files changed, 719 insertions(+), 2429 deletions(-)
libmultipath/config.c +3 -2
@@ -556,7 +556,7 @@ load_config (char * file, struct udev *udev) conf->attribute_flags =0 ; conf->reassign_maps =DEFAULT_REASSIGN_MAPS ; conf->checkint =DEFAULT_CHECKINT ; - conf->max_checkint =MAX_CHECKINT (conf->checkint); + conf->max_checkint =0 ; conf->pgfailback =DEFAULT_FAILBACK ; conf->fast_io_fail =DEFAULT_FAST_IO_FAIL ; conf->retain_hwhandler =DEFAULT_RETAIN_HWHANDLER ;
@@ -599,7 +599,8 @@ load_config (char * file, struct udev *udev) }else {init_keywords (); } - +if (conf->max_checkint ==0 ) + conf->max_checkint =MAX_CHECKINT (conf->checkint);/* * fill the voids left in the config file */
libmultipath/defaults.h +0 -2
@@ -11,8 +11,6 @@#define DEFAULT_FAILBACK -FAILBACK_MANUAL#define DEFAULT_RR_WEIGHT RR_WEIGHT_NONE#define DEFAULT_NO_PATH_RETRY NO_PATH_RETRY_UNDEF -#define DEFAULT_PGTIMEOUT -PGTIMEOUT_NONE -#define DEFAULT_USER_FRIENDLY_NAMES 0#define DEFAULT_VERBOSITY 2#define DEFAULT_REASSIGN_MAPS 1#define DEFAULT_FAST_IO_FAIL 5
libmultipath/dict.c +691 -2406
2,975 lines not on this page · raw message
libmultipath/structs.h +25 -19
44 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.
Benjamin Marzinski
maintainerPATCH 2/6 libmultipath: cleanup propsel.c with macros for common actions
In reply to Benjamin MarzinskiMany of the functions in propsel.c are nearly identical, except for the names of the variables that they are dealing with. Also, some variables that the user configured with a keyword were just printing the variable as an integer, which isn't very helpful without looking at the code to see what the number stands for. They were using the variable names instead of the config file names as well. This patch tries to simplify the file by using macros for the repetitive work of the functions, and standardizes and clarifies the debug messages by using the print functions from dict.c
--- libmultipath/dict.c | 14 +- libmultipath/dict.h | 7 + libmultipath/pgpolicies.c | 2 +- libmultipath/propsel.c | 712 +++++++++++++++++----------------------------- 4 files changed, 282 insertions(+), 453 deletions(-)
libmultipath/dict.c +7 -7
@@ -496,7 +496,7 @@ set_fast_io_fail(vector strvec, void *ptr)return 0 ; } -static int +int print_fast_io_fail (char * buff,int len,void *ptr) {int *int_ptr = (int *)ptr;
@@ -534,7 +534,7 @@ set_dev_loss(vector strvec, void *ptr)return 0 ; } -static int +int print_dev_loss (char * buff,int len,void *ptr) {unsigned int *uint_ptr = (unsigned int *)ptr;
@@ -567,7 +567,7 @@ set_pgpolicy(vector strvec, void *ptr)return 0 ; } -static int +int print_pgpolicy (char * buff,int len,void *ptr) {char str[POLICY_NAME_SIZE ];
@@ -683,7 +683,7 @@ set_rr_weight(vector strvec, void *ptr)return 0 ; } -static int +int print_rr_weight (char * buff,int len,void *ptr) {int *int_ptr = (int *)ptr;
@@ -727,7 +727,7 @@ set_pgfailback(vector strvec, void *ptr)return 0 ; } -static int +int print_pgfailback (char * buff,int len,void *ptr) {int *int_ptr = (int *)ptr;
@@ -774,7 +774,7 @@ set_no_path_retry(vector strvec, void *ptr)return 0 ; } -static int +int print_no_path_retry (char * buff,int len,void *ptr) {int *int_ptr = (int *)ptr;
@@ -873,7 +873,7 @@ set_reservation_key(vector strvec, void *ptr)return 0 ; } -static int +int print_reservation_key (char * buff,int len,void * ptr) {unsigned char **uchar_ptr = (unsigned char **)ptr;
libmultipath/dict.h +7 -0
@@ -7,5 +7,12 @@void init_keywords (void );int get_sys_max_fds (int *); +int print_rr_weight (char * buff,int len,void *ptr); +int print_pgfailback (char * buff,int len,void *ptr); +int print_pgpolicy (char * buff,int len,void *ptr); +int print_no_path_retry (char * buff,int len,void *ptr); +int print_fast_io_fail (char * buff,int len,void *ptr); +int print_dev_loss (char * buff,int len,void *ptr); +int print_reservation_key (char * buff,int len,void * ptr);#endif /* _DICT_H */
libmultipath/pgpolicies.c +1 -1
@@ -27,7 +27,7 @@ get_pgpolicy_id (char * str)if (0 ==strncmp (str,"group_by_node_name" ,18 ))return GROUP_BY_NODE_NAME ; -return -1 ; +return IOPOLICY_UNDEF ; } extern int
libmultipath/propsel.c +267 -445
910 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 3/6 libmultipath: add overrides section to multipath.conf
In reply to Benjamin MarzinskiSometimes users want to be able to set a configuration value for all their devices (for instance, they may want all devices to set no_path_retry to fail). The builtin device configurations make this tricky, since users need to change each device configuration individually. To avoid that, this patch adds a new section to multipath.conf, "overrides". This section has all of the attributes that are in both the devices and defaults section. Attributes set in the overrides section have a higher priority that those in the devices section. With this section added, the multipath configuration order now goes:
multipaths > overrides > devices > defaults
I also made want_user_friendly_names print out where the configuration came from, and I made made select_hwhandler and select_selector always strdup the string, instead of only on the defaults. Since multipathd will update the device strings from the kernel anyway, the old way just added complexity without saving any memory.
To store the overrides configuration, I used a hwentry structure. We may want to make a new overrides structure, so that we set any of the defaults values in overrides. That way, users could skip using defaults and just use overrides if they wanted. However, this would take some additional changes to make sure that all the defaults options can undefined, which they can't currently be.
--- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/dict.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++ libmultipath/print.c | 30 ++++++++++++++ libmultipath/print.h | 1 + libmultipath/propsel.c | 55 +++++++++++++++++++++----- libmultipath/structs.c | 9 +---- multipath.conf.annotated | 18 ++++++++- multipath.conf.defaults | 2 + multipath.conf.synthetic | 3 ++ multipath/main.c | 6 +++ multipath/multipath.conf.5 | 57 +++++++++++++++++++++++++++ multipathd/cli_handlers.c | 10 +++++ 13 files changed, 273 insertions(+), 18 deletions(-)
libmultipath/config.c +1 -0
@@ -523,6 +523,7 @@ free_config (struct config * conf)free_mptable (conf->mptable);free_hwtable (conf->hwtable); +free_hwe (conf->overrides);free_keywords (conf->keywords);FREE (conf); }
libmultipath/config.h +1 -0
@@ -145,6 +145,7 @@ struct config {vector keywords;vector mptable;vector hwtable; +struct hwentry *overrides;vector blist_devnode;vector blist_wwid;
libmultipath/dict.c +98 -0
230 lines not on this page · raw message
libmultipath/print.c +30 -0
@@ -1080,6 +1080,36 @@ snprint_mptable (char * buff, int len, vector mptable) }extern int +snprint_overrides (char * buff,int len,struct hwentry *overrides) +{ +int fwd =0 ; +int i; +struct keyword *rootkw; +struct keyword *kw; + + rootkw =find_keyword (NULL ,"overrides" ); +if (!rootkw) +return 0 ; + + fwd +=snprintf (buff + fwd, len - fwd,"overrides {\n" ); +if (fwd > len) +return len; +if (!overrides) + goto out; + iterate_sub_keywords(rootkw, kw, i) { + fwd +=snprint_keyword (buff + fwd, len - fwd,"\t%k %v\n" , + kw,NULL ); +if (fwd > len) +return len; + } +out: + fwd +=snprintf (buff + fwd, len - fwd,"}\n" ); +if (fwd > len) +return len; +return fwd; +} + +extern int snprint_defaults (char * buff,int len) {int fwd =0 ;
libmultipath/print.h +1 -0
@@ -50,6 +50,7 @@ int snprint_status (char *, int, struct vectors *);int snprint_devices (char *,int ,struct vectors *);int snprint_hwtable (char *,int ,vector );int snprint_mptable (char *,int ,vector ); +int snprint_overrides (char *,int ,struct hwentry *);void print_multipath_topology (struct multipath * mpp,int verbosity);void print_path (struct path * pp,char * style);
libmultipath/propsel.c +45 -10
190 lines not on this page · raw message
libmultipath/structs.c +2 -7
@@ -206,10 +206,7 @@ free_multipath_attributes (struct multipath * mpp)if (!mpp)return ; -if (mpp->selector && - mpp->selector != conf->selector && - (!mpp->mpe || (mpp->mpe && mpp->selector != mpp->mpe->selector)) && - (!mpp->hwe || (mpp->hwe && mpp->selector != mpp->hwe->selector))) { +if (mpp->selector) {FREE (mpp->selector); mpp->selector =NULL ; }
@@ -219,9 +216,7 @@ free_multipath_attributes (struct multipath * mpp) mpp->features =NULL ; } -if (mpp->hwhandler && - mpp->hwhandler != conf->hwhandler && - (!mpp->hwe || (mpp->hwe && mpp->hwhandler != mpp->hwe->hwhandler))) { +if (mpp->hwhandler) {FREE (mpp->hwhandler); mpp->hwhandler =NULL ; }
multipath.conf.annotated +17 -1
@@ -485,7 +485,8 @@ ## scope : multipath & multipathd ## desc : list of per storage controller settings ## overrides default settings (device_maps block) -## overriden by per multipath settings (multipaths block) +## overriden by per multipath settings (multipaths block) +## and the overrides settings (overrides block) ## #devices { # #
@@ -651,3 +652,18 @@ # rr_weight priorities # } #} +# +## +## name : devices +## scope : multipath & multipathd +## desc : list of settings to override all hadware settings for all devices +## overrides default settings (device_maps block) +## and per device type settings (devices block) +## overriden by per multipath settings (multipaths block) +## +# attributes and values are identical to the device block +# +#overrides { +# dev_loss_tmo 60 +# no_path_retry fail +#}
multipath.conf.defaults +2 -0
@@ -912,3 +912,5 @@ #} #multipaths { #} +#overrides { +#}
multipath.conf.synthetic +3 -0
@@ -72,3 +72,6 @@ # path_grouping_policy multibus # } #} +#overrides { +# no_path_retry fail +#}
multipath/main.c +6 -0
@@ -405,6 +405,12 @@ dump_config (void) reply =REALLOC (reply, maxlen *=2 );continue ; } + c +=snprint_overrides (c, reply + maxlen - c, conf->overrides); + again = ((c - reply) == maxlen); +if (again) { + reply =REALLOC (reply, maxlen *=2 ); +continue ; + } c +=snprint_mptable (c, reply + maxlen - c, conf->mptable); again = ((c - reply) == maxlen);if (again)
multipath/multipath.conf.5 +57 -0
69 lines not on this page · raw message
multipathd/cli_handlers.c +10 -0
@@ -190,6 +190,16 @@ show_config (char ** r, int * len) maxlen *=2 ;continue ; } + c +=snprint_overrides (c, reply + maxlen - c, conf->overrides); + again = ((c - reply) == maxlen); +if (again) { + reply =REALLOC (reply, maxlen *2 ); +if (!reply) +return 1 ; +memset (reply + maxlen,0 , maxlen); + maxlen *=2 ; +continue ; + } c +=snprint_mptable (c, reply + maxlen - c, conf->mptable); again = ((c - reply) == maxlen);REALLOC_REPLY (reply, again, maxlen);
Signature · 1 line
1.8.3.1
Re: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
I have no strong opinion on this one : I feel like the complexity of the parameter inheritance system is already quite complicated ... but this addition of a new layer would likely and safely be ignored by users who don't need it. Those who need it are surely ready to pay the price.
Does someone have objection to my applying this patch ?
Best regards,
Christophe
Quoted 829 lines · Benjamin Marzinski
Sometimes users want to be able to set a configuration value for all their devices (for instance, they may want all devices to set
no_path_retryto fail). The builtin device configurations make this tricky, since users need to change each device configuration individually. To avoid that, this patch adds a new section to multipath.conf, "overrides". This section has all of the attributes that are in both the devices and defaults section. Attributes set in the overrides section have a higher priority that those in the devices section. With this section added, the multipath configuration order now goes:multipaths > overrides > devices > defaults
I also made
want_user_friendly_namesprint out where the configuration came from, and I made madeselect_hwhandlerandselect_selectoralways strdup the string, instead of only on the defaults. Since multipathd will update the device strings from the kernel anyway, the old way just added complexity without saving any memory.To store the overrides configuration, I used a hwentry structure. We may want to make a new overrides structure, so that we set any of the defaults values in overrides. That way, users could skip using defaults and just use overrides if they wanted. However, this would take some additional changes to make sure that all the defaults options can undefined, which they can't currently be.
Signed-off-by Benjamin Marzinski <[email protected]>--- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/dict.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++ libmultipath/print.c | 30 ++++++++++++++ libmultipath/print.h | 1 + libmultipath/propsel.c | 55 +++++++++++++++++++++----- libmultipath/structs.c | 9 +---- multipath.conf.annotated | 18 ++++++++- multipath.conf.defaults | 2 + multipath.conf.synthetic | 3 ++ multipath/main.c | 6 +++ multipath/multipath.conf.5 | 57 +++++++++++++++++++++++++++ multipathd/cli_handlers.c | 10 +++++ 13 files changed, 273 insertions(+), 18 deletions(-)libmultipath/config.c +1
-0@@ -523,6 +523,7 @@ free_config (struct config * conf)free_mptable (conf->mptable);free_hwtable (conf->hwtable); +free_hwe (conf->overrides);free_keywords (conf->keywords);FREE (conf); }libmultipath/config.h +1
-0@@ -145,6 +145,7 @@ struct config {vector keywords;vector mptable;vector hwtable; +struct hwentry *overrides;vector blist_devnode;vector blist_wwid;libmultipath/dict.c +16
-0@@ -181,6 +181,22 @@ snprint_hw_ ## option (char * buff, int len, void * data) \return function (buff, len, &hwe->option); \ } +#define declare_ovr_handler (option, function) \ +static int \ +ovr_ ## option ## _handler (vector strvec) \ +{ \ + if (!conf->overrides) \ + return 1; \ + return function (strvec, &conf->overrides->option); \ +} + +#define declare_ovr_snprint (option, function) \ +static int \ +snprint_ovr_ ## option (char * buff, int len, void * data) \ +{ \ + return function (buff, len, &conf->overrides->option); \ +} +#define declare_mp_handler (option, function) \ static int \
mp_## option ##_handler(vector strvec) \libmultipath/dict.c +8
-0@@ -218,21 +234,29 @@ declare_def_handler(selector, set_str) declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR) declare_hw_handler(selector, set_str) declare_hw_snprint(selector, print_str) +declare_ovr_handler(selector, set_str) +declare_ovr_snprint(selector, print_str) declare_mp_handler(selector, set_str) declare_mp_snprint(selector, print_str) declare_def_handler(uid_attribute, set_str)declare_def_snprint_defstr (uid_attribute, print_str, DEFAULT_UID_ATTRIBUTE) +declare_ovr_handler(uid_attribute, set_str) +declare_ovr_snprint(uid_attribute, print_str) declare_hw_handler(uid_attribute, set_str) declare_hw_snprint(uid_attribute, print_str) declare_def_handler(getuid, set_str) declare_def_snprint(getuid, print_str) +declare_ovr_handler(getuid, set_str) +declare_ovr_snprint(getuid, print_str) declare_hw_handler(getuid, set_str) declare_hw_snprint(getuid, print_str) declare_def_handler(prio_name, set_str) declare_def_snprint_defstr(prio_name, print_str, DEFAULT_PRIO) +declare_ovr_handler(prio_name, set_str) +declare_ovr_snprint(prio_name, print_str) declare_hw_handler(prio_name, set_str)declare_hw_snprint (prio_name, print_str)
declare_mp_handler(prio_name, set_str)libmultipath/dict.c +16
-0@@ -240,11 +264,15 @@ declare_mp_snprint(prio_name, print_str) declare_def_handler(alias_prefix, set_str) declare_def_snprint_defstr(alias_prefix, print_str, DEFAULT_ALIAS_PREFIX) +declare_ovr_handler(alias_prefix, set_str) +declare_ovr_snprint(alias_prefix, print_str) declare_hw_handler(alias_prefix, set_str) declare_hw_snprint(alias_prefix, print_str) declare_def_handler(prio_args, set_str) declare_def_snprint_defstr(prio_args, print_str, DEFAULT_PRIO_ARGS) +declare_ovr_handler(prio_args, set_str) +declare_ovr_snprint(prio_args, print_str) declare_hw_handler(prio_args, set_str) declare_hw_snprint(prio_args, print_str)declare_mp_handler (prio_args, set_str)@@ -252,6 +280,8 @@ declare_mp_snprint(prio_args, print_str) declare_def_handler(features, set_str) declare_def_snprint_defstr(features, print_str, DEFAULT_FEATURES) +declare_ovr_handler(features, set_str) +declare_ovr_snprint(features, print_str) declare_hw_handler(features, set_str) declare_hw_snprint(features, print_str)declare_mp_handler (features, set_str)@@ -259,11 +289,15 @@ declare_mp_snprint(features, print_str) declare_def_handler(checker_name, set_str) declare_def_snprint_defstr(checker_name, print_str, DEFAULT_CHECKER) +declare_ovr_handler(checker_name, set_str) +declare_ovr_snprint(checker_name, print_str) declare_hw_handler(checker_name, set_str) declare_hw_snprint(checker_name, print_str) declare_def_handler(minio, set_int) declare_def_snprint_defint(minio, print_int, DEFAULT_MINIO) +declare_ovr_handler(minio, set_int) +declare_ovr_snprint(minio, print_nonzero) declare_hw_handler(minio, set_int) declare_hw_snprint(minio, print_nonzero)declare_mp_handler (minio, set_int)@@ -271,6 +305,8 @@ declare_mp_snprint(minio, print_nonzero) declare_def_handler(minio_rq, set_int) declare_def_snprint_defint(minio_rq, print_int, DEFAULT_MINIO_RQ) +declare_ovr_handler(minio_rq, set_int) +declare_ovr_snprint(minio_rq, print_nonzero) declare_hw_handler(minio_rq, set_int) declare_hw_snprint(minio_rq, print_nonzero)declare_mp_handler (minio_rq, set_int)@@ -296,6 +332,8 @@ declare_def_snprint(checker_timeout, print_nonzero) declare_def_handler(flush_on_last_del, set_yes_no_undef) declare_def_snprint_defint(flush_on_last_del, print_yes_no_undef, YNU_NO) +declare_ovr_handler(flush_on_last_del, set_yes_no_undef) +declare_ovr_snprint(flush_on_last_del, print_yes_no_undef) declare_hw_handler(flush_on_last_del, set_yes_no_undef) declare_hw_snprint(flush_on_last_del, print_yes_no_undef)declare_mp_handler (flush_on_last_del, set_yes_no_undef)@@ -303,6 +341,8 @@ declare_mp_snprint(flush_on_last_del, print_yes_no_undef) declare_def_handler(user_friendly_names, set_yes_no_undef) declare_def_snprint_defint(user_friendly_names, print_yes_no_undef, YNU_NO) +declare_ovr_handler(user_friendly_names, set_yes_no_undef) +declare_ovr_snprint(user_friendly_names, print_yes_no_undef) declare_hw_handler(user_friendly_names, set_yes_no_undef)
declare_hw_snprint(user_friendly_names, print_yes_no_undef)declare_mp_handler(user_friendly_names, set_yes_no_undef)libmultipath/dict.c +39
-0@@ -316,11 +356,15 @@ declare_def_snprint(wwids_file, print_str) declare_def_handler(retain_hwhandler, set_yes_no_undef) declare_def_snprint_defint(retain_hwhandler, print_yes_no_undef, YNU_NO) +declare_ovr_handler(retain_hwhandler, set_yes_no_undef) +declare_ovr_snprint(retain_hwhandler, print_yes_no_undef) declare_hw_handler(retain_hwhandler, set_yes_no_undef) declare_hw_snprint(retain_hwhandler, print_yes_no_undef) declare_def_handler(detect_prio, set_yes_no_undef) declare_def_snprint_defint(detect_prio, print_yes_no_undef, YNU_NO) +declare_ovr_handler(detect_prio, set_yes_no_undef) +declare_ovr_snprint(detect_prio, print_yes_no_undef) declare_hw_handler(detect_prio, set_yes_no_undef)declare_hw_snprint (detect_prio, print_yes_no_undef)@@ -512,6 +556,8 @@ print_fast_io_fail(char * buff, int len, void *ptr) declare_def_handler(fast_io_fail, set_fast_io_fail) declare_def_snprint(fast_io_fail, print_fast_io_fail) +declare_ovr_handler(fast_io_fail, set_fast_io_fail) +declare_ovr_snprint(fast_io_fail, print_fast_io_fail) declare_hw_handler(fast_io_fail, set_fast_io_fail)declare_hw_snprint (fast_io_fail, print_fast_io_fail)@@ -548,6 +594,8 @@ print_dev_loss(char * buff, int len, void *ptr) declare_def_handler(dev_loss, set_dev_loss) declare_def_snprint(dev_loss, print_dev_loss) +declare_ovr_handler(dev_loss, set_dev_loss) +declare_ovr_snprint(dev_loss, print_dev_loss) declare_hw_handler(dev_loss, set_dev_loss)declare_hw_snprint (dev_loss, print_dev_loss)@@ -583,6 +631,8 @@ print_pgpolicy(char * buff, int len, void *ptr) declare_def_handler(pgpolicy, set_pgpolicy) declare_def_snprint_defint(pgpolicy, print_pgpolicy, DEFAULT_PGPOLICY) +declare_ovr_handler(pgpolicy, set_pgpolicy) +declare_ovr_snprint(pgpolicy, print_pgpolicy) declare_hw_handler(pgpolicy, set_pgpolicy) declare_hw_snprint(pgpolicy, print_pgpolicy)declare_mp_handler (pgpolicy, set_pgpolicy)@@ -700,6 +750,8 @@ print_rr_weight (char * buff, int len, void *ptr) declare_def_handler(rr_weight, set_rr_weight) declare_def_snprint_defint(rr_weight, print_rr_weight, RR_WEIGHT_NONE) +declare_ovr_handler(rr_weight, set_rr_weight) +declare_ovr_snprint(rr_weight, print_rr_weight) declare_hw_handler(rr_weight, set_rr_weight) declare_hw_snprint(rr_weight, print_rr_weight)declare_mp_handler (rr_weight, set_rr_weight)@@ -748,6 +800,8 @@ print_pgfailback (char * buff, int len, void *ptr) declare_def_handler(pgfailback, set_pgfailback) declare_def_snprint_defint(pgfailback, print_pgfailback, DEFAULT_FAILBACK) +declare_ovr_handler(pgfailback, set_pgfailback) +declare_ovr_snprint(pgfailback, print_pgfailback) declare_hw_handler(pgfailback, set_pgfailback) declare_hw_snprint(pgfailback, print_pgfailback)declare_mp_handler (pgfailback, set_pgfailback)@@ -793,6 +847,8 @@ print_no_path_retry(char * buff, int len, void *ptr) declare_def_handler(no_path_retry, set_no_path_retry) declare_def_snprint(no_path_retry, print_no_path_retry) +declare_ovr_handler(no_path_retry, set_no_path_retry) +declare_ovr_snprint(no_path_retry, print_no_path_retry) declare_hw_handler(no_path_retry, set_no_path_retry) declare_hw_snprint(no_path_retry, print_no_path_retry)declare_mp_handler (no_path_retry, set_no_path_retry)@@ -1061,6 +1117,25 @@ declare_hw_handler(hwhandler, set_str)declare_hw_snprint (hwhandler, print_str)/* +* overrides handlers + */ +static int +overrides_handler (vector strvec) +{ +struct hwentry * overrides; + + overrides =alloc_hwe (); + +if (!overrides) +return 1 ; + + conf->overrides = overrides; +return 0 ; +} + + + +/* * multipaths block handlers */ static int@@ -1236,6 +1311,29 @@ init_keywords(void)install_keyword ("detect_prio" , &hw_detect_prio_handler, &snprint_hw_detect_prio);install_sublevel_end (); +install_keyword_root ("overrides" , &overrides_handler); +install_keyword ("path_grouping_policy" , &ovr_pgpolicy_handler, &snprint_ovr_pgpolicy); +install_keyword ("uid_attribute" , &ovr_uid_attribute_handler, &snprint_ovr_uid_attribute); + install_keyword("getuid_callout", &ovr_getuid_handler,
&snprint_ovr_getuid);
+ install_keyword("path_selector",&ovr_selector_handler,&snprint_ovr_selector);
+ install_keyword("path_checker",&ovr_checker_name_handler,&snprint_ovr_checker_name);libmultipath/dict.c +2
-0+install_keyword ("checker" , &ovr_checker_name_handler,NULL ); + install_keyword("alias_prefix", &ovr_alias_prefix_handler,
&snprint_ovr_alias_prefix);
+ install_keyword("features",&ovr_features_handler,&snprint_ovr_features);
+ install_keyword("prio",&ovr_prio_name_handler,&snprint_ovr_prio_name);
+ install_keyword("prio_args",&ovr_prio_args_handler,&snprint_ovr_prio_args);
+ install_keyword("failback",&ovr_pgfailback_handler,&snprint_ovr_pgfailback);
+ install_keyword("rr_weight",&ovr_rr_weight_handler,&snprint_ovr_rr_weight);
+ install_keyword("no_path_retry",&ovr_no_path_retry_handler,&snprint_ovr_no_path_retry);
+ install_keyword("rr_min_io",&ovr_minio_handler,&snprint_ovr_minio);
+ install_keyword("rr_min_io_rq",&ovr_minio_rq_handler,&snprint_ovr_minio_rq);
+ install_keyword("flush_on_last_del",&ovr_flush_on_last_del_handler,&snprint_ovr_flush_on_last_del);
+ install_keyword("fast_io_fail_tmo",&ovr_fast_io_fail_handler,&snprint_ovr_fast_io_fail);
+ install_keyword("dev_loss_tmo",&ovr_dev_loss_handler,&snprint_ovr_dev_loss);
+ install_keyword("user_friendly_names",&ovr_user_friendly_names_handler,&snprint_ovr_user_friendly_names);
+ install_keyword("retain_attached_hw_handler",&ovr_retain_hwhandler_handler,&snprint_ovr_retain_hwhandler);
+ install_keyword("detect_prio",&ovr_detect_prio_handler,&snprint_ovr_detect_prio);libmultipath/dict.c +1
-0+install_keyword_root ("multipaths" , &multipaths_handler);install_keyword_multi ("multipath" , &multipath_handler,NULL );install_sublevel ();libmultipath/print.c +30
-0@@ -1080,6 +1080,36 @@ snprint_mptable (char * buff, int len, vector mptable) }extern int +snprint_overrides (char * buff,int len,struct hwentry *overrides) +{ +int fwd =0 ; +int i; +struct keyword *rootkw; +struct keyword *kw; + + rootkw =find_keyword (NULL ,"overrides" ); +if (!rootkw) +return 0 ; + + fwd +=snprintf (buff + fwd, len - fwd,"overrides {\n" ); +if (fwd > len) +return len; +if (!overrides) + goto out; + iterate_sub_keywords(rootkw, kw, i) { + fwd +=snprint_keyword (buff + fwd, len - fwd,"\t%k %v\n" , + kw,NULL ); +if (fwd > len) +return len; + } +out: + fwd +=snprintf (buff + fwd, len - fwd,"}\n" ); +if (fwd > len) +return len; +return fwd; +} + +extern int snprint_defaults (char * buff,int len) {int fwd = 0;libmultipath/print.h +1
-0@@ -50,6 +50,7 @@ int snprint_status (char *, int, struct vectors *);int snprint_devices (char *,int ,struct vectors *);int snprint_hwtable (char *,int ,vector );int snprint_mptable (char *,int ,vector ); +int snprint_overrides (char *,int ,struct hwentry *);void print_multipath_topology (struct multipath * mpp,int verbosity);void print_path (struct path * pp,char * style);libmultipath/propsel.c +2
-0@@ -48,6 +48,8 @@ do { \ do_set(var, mp->mpe, mp->var, "(LUN setting)")#define mp_set_hwe (var) \ do_set(var, mp->hwe, mp->var, "(controller setting)") +#define mp_set_ovr (var) \ +do_set (var, conf->overrides, mp->var,"(overrides setting)" )#define
mp_set_conf(var)\
do_set(var, conf, mp->var, "(config file default)")
#definemp_set_default(var, value)\libmultipath/propsel.c +8
-1@@ -59,6 +61,8 @@ do_set(var, mpe, pp->var, "(LUN setting)") do_set(var, pp->hwe, pp->var, "(controller setting)")#define pp_set_conf (var) \ do_set(var, conf, pp->var, "(config file default)") +#define pp_set_ovr (var) \ +do_set(var, conf->overrides, pp->var, "(overrides setting)")#define pp_set_default (var, value) \ do_default(pp->var, value)@@ -130,6 +134,7 @@ select_rr_weight (struct multipath * mp)char *origin, buff[13 ];mp_set_mpe (rr_weight); +mp_set_ovr (rr_weight);mp_set_hwe (rr_weight);mp_set_conf (rr_weight);mp_set_default (rr_weight,RR_WEIGHT_NONE );@@ -145,6 +150,7 @@ select_pgfailback (struct multipath * mp)char *origin, buff[13 ];mp_set_mpe (pgfailback); +mp_set_ovr (pgfailback);mp_set_hwe (pgfailback);mp_set_conf (pgfailback);mp_set_default (pgfailback,DEFAULT_FAILBACK );@@ -165,6 +171,7 @@ select_pgpolicy (struct multipath * mp) goto out; }mp_set_mpe (pgpolicy); +mp_set_ovr (pgpolicy);mp_set_hwe (pgpolicy);mp_set_conf (pgpolicy);mp_set_default (pgpolicy,DEFAULT_PGPOLICY );@@ -181,10 +188,12 @@ select_selector (struct multipath * mp)char *origin;mp_set_mpe (selector); +mp_set_ovr (selector);mp_set_hwe (selector);mp_set_conf (selector); -mp_set_default (selector,set_default (DEFAULT_SELECTOR )); +mp_set_default (selector,DEFAULT_SELECTOR ); out: + mp->selector =STRDUP (mp->selector);condlog (3 ,"%s: path_selector = \"%s\" %s" , mp->alias, mp->selector, origin);return 0;libmultipath/propsel.c +20
-8@@ -195,6 +204,7 @@ select_alias_prefix (struct multipath * mp) {char *origin; +mp_set_ovr (alias_prefix);mp_set_hwe (alias_prefix);mp_set_conf (alias_prefix);mp_set_default (alias_prefix,DEFAULT_ALIAS_PREFIX );@@ -206,19 +216,30 @@ out:static int want_user_friendly_names (struct multipath * mp) { -if (mp->mpe && - mp->mpe->user_friendly_names !=USER_FRIENDLY_NAMES_UNDEF ) -return (mp->mpe->user_friendly_names == USER_FRIENDLY_NAMES_ON); -if (mp->hwe && - mp->hwe->user_friendly_names !=USER_FRIENDLY_NAMES_UNDEF ) -return (mp->hwe->user_friendly_names == USER_FRIENDLY_NAMES_ON); -return (conf->user_friendly_names ==USER_FRIENDLY_NAMES_ON ); + +char *origin; +int user_friendly_names; + +do_set (user_friendly_names, mp->mpe, user_friendly_names, +"(LUN setting)" ); +do_set (user_friendly_names, conf->overrides, user_friendly_names, +"(overrides setting)" ); +do_set (user_friendly_names, mp->hwe, user_friendly_names, +"(controller setting)" ); +do_set (user_friendly_names, conf, user_friendly_names, +"(config file setting)" ); +do_default (user_friendly_names,USER_FRIENDLY_NAMES_OFF ); +out: +condlog (3 ,"%s: user_friendly_names = %s %s" , mp->wwid, + (user_friendly_names ==USER_FRIENDLY_NAMES_ON )?"yes" :"no" , + origin); +return (user_friendly_names ==USER_FRIENDLY_NAMES_ON ); }extern int select_alias (struct multipath * mp) { -char *origin; +char *origin =NULL ;if (mp->mpe && mp->mpe->alias) { mp->alias = STRDUP(mp->mpe->alias);libmultipath/propsel.c +3
-1@@ -261,6 +282,7 @@ select_features (struct multipath * mp)char *origin;mp_set_mpe (features); +mp_set_ovr (features);mp_set_hwe (features);mp_set_conf (features);mp_set_default (features,DEFAULT_FEATURES );@@ -287,8 +309,9 @@ select_hwhandler (struct multipath * mp)mp_set_hwe (hwhandler);mp_set_conf (hwhandler); -mp_set_default (hwhandler,set_default (DEFAULT_HWHANDLER )); +mp_set_default (hwhandler,DEFAULT_HWHANDLER ); out: + mp->hwhandler =STRDUP (mp->hwhandler);condlog (3 ,"%s: hardware_handler = \"%s\" %s" , mp->alias, mp->hwhandler, origin);return 0;libmultipath/propsel.c +1
-0@@ -300,6 +323,7 @@ select_checker(struct path *pp)char *origin, *checker_name;struct checker * c = &pp->checker; + do_set(checker_name, conf->overrides, checker_name, "(overrides setting)"); do_set(checker_name, pp->hwe, checker_name, "(controller setting)");do_set(checker_name, conf, checker_name, "(config file setting)"); do_default(checker_name, DEFAULT_CHECKER);libmultipath/propsel.c +5
-0@@ -327,6 +351,8 @@ select_getuid (struct path * pp) {char *origin; +pp_set_ovr (uid_attribute); +pp_set_ovr (getuid);pp_set_hwe (uid_attribute);pp_set_hwe (getuid);pp_set_conf (uid_attribute);@@ -383,6 +409,7 @@ select_prio (struct path * pp) } mpe =find_mpe (pp->wwid);set_prio (mpe,"(LUN setting)" ); +set_prio (conf->overrides,"(overrides setting)" );set_prio (pp->hwe,"controller setting)" );set_prio (conf,"(config file default)" );prio_get (p,DEFAULT_PRIO ,DEFAULT_PRIO_ARGS );@@ -405,6 +432,7 @@ select_no_path_retry(struct multipath *mp)return 0 ; }mp_set_mpe (no_path_retry); +mp_set_ovr (no_path_retry);mp_set_hwe (no_path_retry);mp_set_conf (no_path_retry); out:@@ -427,6 +455,7 @@ select_minio_rq (struct multipath * mp)char *origin;do_set (minio_rq, mp->mpe, mp->minio,"(LUN setting)" ); + do_set(minio_rq, conf->overrides, mp->minio, "(overrides setting)"); do_set(minio_rq, mp->hwe, mp->minio,"(controller setting)" );do_set (minio_rq, conf, mp->minio,"(config file setting)" );do_default(mp->minio, DEFAULT_MINIO_RQ);libmultipath/propsel.c +6
-0@@ -441,6 +470,7 @@ select_minio_bio (struct multipath * mp)char *origin;mp_set_mpe (minio); +mp_set_ovr (minio);mp_set_hwe (minio);mp_set_conf (minio);mp_set_default (minio,DEFAULT_MINIO );@@ -465,6 +495,7 @@ select_fast_io_fail(struct multipath *mp) {char *origin, buff[12 ]; +mp_set_ovr (fast_io_fail);mp_set_hwe (fast_io_fail);mp_set_conf (fast_io_fail);mp_set_default (fast_io_fail,DEFAULT_FAST_IO_FAIL );@@ -479,6 +510,7 @@ select_dev_loss(struct multipath *mp) {char *origin, buff[12 ]; +mp_set_ovr (dev_loss);mp_set_hwe (dev_loss);mp_set_conf (dev_loss); mp->dev_loss =0 ;@@ -497,6 +529,7 @@ select_flush_on_last_del(struct multipath *mp)if (mp->flush_on_last_del ==FLUSH_IN_PROGRESS )return 0 ;mp_set_mpe (flush_on_last_del); +mp_set_ovr (flush_on_last_del);mp_set_hwe (flush_on_last_del);mp_set_conf (flush_on_last_del);mp_set_default (flush_on_last_del,FLUSH_DISABLED );@@ -532,6 +565,7 @@ select_retain_hwhandler (struct multipath * mp) origin ="(requires kernel version >= 1.5.0)" ; goto out; } +mp_set_ovr (retain_hwhandler);mp_set_hwe (retain_hwhandler);mp_set_conf (retain_hwhandler);mp_set_default (retain_hwhandler,DEFAULT_RETAIN_HWHANDLER );@@ -547,6 +581,7 @@ select_detect_prio (struct path * pp) {char *origin; +pp_set_ovr (detect_prio);pp_set_hwe (detect_prio);pp_set_conf (detect_prio);pp_set_default (detect_prio,DEFAULT_DETECT_PRIO );libmultipath/structs.c +0
-3@@ -206,10 +206,7 @@ free_multipath_attributes (struct multipath * mpp)if (!mpp)return ; - if (mpp->selector && - mpp->selector != conf->selector && - (!mpp->mpe || (mpp->mpe && mpp->selector !=
mpp->mpe->selector)) &&
- (!mpp->hwe || (mpp->hwe&&mpp->selector!=mpp->hwe->selector))) {libmultipath/structs.c +2
-3+if (mpp->selector) {FREE (mpp->selector); mpp->selector =NULL ; }@@ -219,9 +216,7 @@ free_multipath_attributes (struct multipath * mpp) mpp->features =NULL ; } -if (mpp->hwhandler && - mpp->hwhandler != conf->hwhandler && - (!mpp->hwe || (mpp->hwe && mpp->hwhandler != mpp->hwe->hwhandler))) { +if (mpp->hwhandler) {FREE (mpp->hwhandler); mpp->hwhandler =NULL ;}multipath.conf.annotated +7
-1@@ -485,7 +485,8 @@ ## scope : multipath & multipathd ## desc : list of per storage controller settings ## overrides default settings (device_maps block) -## overriden by per multipath settings (multipaths block) +## overriden by per multipath settings (multipaths block) +## and the overrides settings (overrides block) ## #devices { # #@@ -651,3 +652,18 @@ # rr_weight priorities # } #} +# +## +## name : devices +## scope : multipath & multipathd +## desc : list of settings to override all hadware settings for alldevices
multipath.conf.annotated +10
-0+## overrides default settings (device_maps block) +## and per device type settings (devices block) +## overriden by per multipath settings (multipaths block) +## +# attributes and values are identical to the device block +# +#overrides { +# dev_loss_tmo 60 +# no_path_retry fail +#}multipath.conf.defaults +2
-0@@ -912,3 +912,5 @@ #} #multipaths { #} +#overrides { +#}multipath.conf.synthetic +3
-0@@ -72,3 +72,6 @@ # path_grouping_policy multibus # } #} +#overrides { +# no_path_retry fail +#}multipath/main.c +6
-0@@ -405,6 +405,12 @@ dump_config (void) reply =REALLOC (reply, maxlen *=2 );continue ; } + c +=snprint_overrides (c, reply + maxlen - c, conf->overrides); + again = ((c - reply) == maxlen); +if (again) { + reply =REALLOC (reply, maxlen *=2 ); +continue ; + } c +=snprint_mptable (c, reply + maxlen - c, conf->mptable); again = ((c - reply) == maxlen);if (again)
multipath/multipath.conf.5 +6
-0@@ -61,6 +61,10 @@ the udev attribute given by the .TP .B devices This section defines the device-specific settings. +.TP +.B overrides +This section defines values for attributes that should override the +device-specific settings for all devices. .RE .LP .SH "defaults section"@@ -629,6 +633,59 @@ section: .RE .PD .LP +.SH "overrides section" +The overrides section recognizes the following optional attributes; ifnot set
multipath/multipath.conf.5 +51
-0+the values are taken from the +.I devices +or +.I defaults +sections: +.sp 1 +.PD .1v +.RS +.TP 18 +.B path_grouping_policy +.TP +.B uid_attribute +.TP +.B getuid_callout +.TP +.B path_selector +.TP +.B path_checker +.TP +.B alias_prefix +.TP +.B features +.TP +.B prio +.TP +.B prio_args +.TP +.B failback +.TP +.B rr_weight +.TP +.B no_path_retry +.TP +.B rr_min_io +.TP +.B rr_min_io_rq +.TP +.B flush_on_last_del +.TP +.B fast_io_fail_tmo +.TP +.B dev_loss_tmo +.TP +.B user_friendly_names +.TP +.B retain_attached_hw_handler +.TP +.B detect_prio +.RE +.PD +.LP .SH "KNOWN ISSUES" The usage of .B queue_if_no_pathmultipathd/cli_handlers.c +10
-0@@ -190,6 +190,16 @@ show_config (char ** r, int * len) maxlen *=2 ;continue ; } + c +=snprint_overrides (c, reply + maxlen - c, conf->overrides); + again = ((c - reply) == maxlen); +if (again) { + reply =REALLOC (reply, maxlen *2 ); +if (!reply) +return 1 ; +memset (reply + maxlen,0 , maxlen); + maxlen *=2 ; +continue ; + } c +=snprint_mptable (c, reply + maxlen - c, conf->mptable); again = ((c - reply) == maxlen);REALLOC_REPLY(reply, again, maxlen);--
1.8.3.1
Re: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
Quoted 7 lines · Christophe Varoqui
I have no strong opinion on this one : I feel like the complexity of the parameter inheritance system is already quite complicated ... but this addition of a new layer would likely and safely be ignored by users who don't need it. Those who need it are surely ready to pay the price.
Does someone have objection to my applying this patch ?
Quoted 33 lines
Best regards,
ChristopheQuoted 25 lines · Benjamin Marzinski
Sometimes users want to be able to set a configuration value for all their devices (for instance, they may want all devices to set
no_path_retryto fail). The builtin device configurations make this tricky, since users need to change each device configuration individually. To avoid that, this patch adds a new section to multipath.conf, "overrides". This section has all of the attributes that are in both the devices and defaults section. Attributes set in the overrides section have a higher priority that those in the devices section. With this section added, the multipath configuration order now goes:multipaths > overrides > devices > defaults
I also made
want_user_friendly_namesprint out where the configuration came from, and I made madeselect_hwhandlerandselect_selectoralways strdup the string, instead of only on the defaults. Since multipathd will update the device strings from the kernel anyway, the old way just added complexity without saving any memory.To store the overrides configuration, I used a hwentry structure. We may want to make a new overrides structure, so that we set any of the defaults values in overrides. That way, users could skip using defaults and just use overrides if they wanted. However, this would take some additional changes to make sure that all the defaults options can undefined, which they can't currently be.
What's the current precedence of the configuration sections? I don't think the manual pages document this (sufficiently). I guess the precedence is:
multipaths > devices > defaults
But where do the built-in device configurations fit in? It seems those are somehow merged with the user supplied entries from the configuration file.
Would changing the precedence to
multipaths > devices > defaults > built-in devices
fix the issue at hand?
Sebastian
Re: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
Hi,
the precedence chain is :
multipaths > user-specified per-device > default per-device > default
The issue adressed by Ben's patch would not be solved by your suggestion, as far as I can see. The proposed override section is just a way not repeat a per-device in each multipath (insane) or device (tedious) section.
I personnaly implement the tedious device configuration using a configuration manager (shameless plug: opensvc). But I can see the value of an override section for those not using a such config management tools.
Best regards,
Christophe Varoqui
OpenSVC
Quoted 71 lines · Sebastian Herbszt
Quoted 7 lines · Christophe Varoqui
I have no strong opinion on this one : I feel like the complexity of the parameter inheritance system is already quite complicated ... but this addition of a new layer would likely and safely be ignored by users who don't need it. Those who need it are surely ready to pay the price.
Does someone have objection to my applying this patch ?
Quoted 10 lines
Best regards,
ChristopheOn Wed, Nov 19, 2014 at 7:17 AM, Benjamin Marzinski <[email protected]
Quoted 1 line · wrote:
Sometimes users want to be able to set a configuration value for all
their
Quoted 1 line
Quoted 1 line
devices (for instance, they may want all devices to set
no_path_retryto
Quoted 1 line
Quoted 1 line
fail). The builtin device configurations make this tricky, since users
need
Quoted 1 line
Quoted 1 line
to change each device configuration individually. To avoid that, this
patch
Quoted 1 line
Quoted 1 line
adds a new section to multipath.conf, "overrides". This section has
all of
Quoted 2 lines
Quoted 2 lines
the attributes that are in both the devices and defaults section. Attributes set in the overrides section have a higher priority that
those
Quoted 6 lines
Quoted 6 lines
in the devices section. With this section added, the multipath configuration order now goes:
multipaths > overrides > devices > defaults
I also made
want_user_friendly_namesprint out where the configurationcame
Quoted 1 line
Quoted 1 line
from, and I made made
select_hwhandlerandselect_selectoralwaysstrdup
Quoted 1 line
Quoted 1 line
the string, instead of only on the defaults. Since multipathd will
update
Quoted 4 lines
Quoted 4 lines
the device strings from the kernel anyway, the old way just added complexity without saving any memory.
To store the overrides configuration, I used a hwentry structure. We
may
Quoted 1 line
Quoted 1 line
want to make a new overrides structure, so that we set any of the
defaults
Quoted 1 line
Quoted 1 line
values in overrides. That way, users could skip using defaults and
just
Quoted 4 lines
Quoted 4 lines
use overrides if they wanted. However, this would take some additional changes to make sure that all the defaults options can undefined, which they can't currently be.
What's the current precedence of the configuration sections? I don't think the manual pages document this (sufficiently). I guess the precedence is:
multipaths > devices > defaults
But where do the built-in device configurations fit in? It seems those are somehow merged with the user supplied entries from the configuration file.
Would changing the precedence to
multipaths > devices > defaults > built-in devices
fix the issue at hand?
Sebastian
Re: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
Hello Christophe,
Quoted 9 lines · Christophe Varoqui
Hi,
the precedence chain is :
multipaths > user-specified per-device > default per-device > default
The issue adressed by Ben's patch would not be solved by your suggestion, as far as I can see. The proposed override section is just a way not repeat a per-device in each multipath (insane) or device (tedious) section.
care to explain why setting the precedence to
multipaths > user-specified per-device > default > default per-device
would not fix the issue?
Lets assume the following default device and user configuration:
.vendor = "COMPELNT", .product = "Compellent Vol", .pgpolicy = MULTIBUS, .pgfailback = -FAILBACK_IMMEDIATE
.no_path_retry = NO_PATH_RETRY_QUEUE,
.checker_name = TUR
defaults {
no_path_retry fail
}
devices {
device {
vendor "COMPELNT"
product "Compellent Vol"
path_grouping_policy "group_by_prio"
}
}multipaths {
multipath {
wwid 1234
failback 15
}
}The default section should change no_path_retry from "queue" to "fail". The device section should change path_grouping_policy from "multibus" to "group_by_prio" for "COMPELNT/Compellent Vol".
The multipath section should change failback from "immediate" to 15 for wwid 1234.
The path_checker would still be "tur".
Is this not what the "overrides" patch intended?
Sebastian
Re: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
Quoted 13 lines · Sebastian Herbszt
Hello Christophe,
Quoted 9 lines · Christophe Varoqui
Hi,
the precedence chain is :
multipaths > user-specified per-device > default per-device > default
The issue adressed by Ben's patch would not be solved by your suggestion, as far as I can see. The proposed override section is just a way not repeat a per-device in each multipath (insane) or device (tedious) section.
Quoted 5 lines
care to explain why setting the precedence to
multipaths > user-specified per-device > default > default per-device
would not fix the issue?
It may very well "fix" the issue but having global default overriding drive-specific default seems to me as wrong as breaking compatibility by such change which would likely introduce more issues.
-- Martian
Quoted 45 lines
Lets assume the following default device and user configuration:
.vendor = "COMPELNT", .product = "Compellent Vol", .pgpolicy = MULTIBUS, .pgfailback = -FAILBACK_IMMEDIATE.no_path_retry =
NO_PATH_RETRY_QUEUE,
.checker_name = TURdefaults {
no_path_retryfail
}devices { device { vendor "COMPELNT" product "Compellent Vol" path_grouping_policy "group_by_prio" } }multipaths { multipath { wwid 1234 failback 15 } }The default section should change
no_path_retryfrom "queue" to "fail". The device section should changepath_grouping_policyfrom "multibus" to "group_by_prio" for "COMPELNT/Compellent Vol".
The multipath section should change failback from "immediate" to 15 for wwid 1234.
Thepath_checkerwould still be "tur".Is this not what the "overrides" patch intended?
Sebastian
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Benjamin Marzinski
maintainerRe: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
In reply to Sebastian HerbsztQuoted 13 lines · Sebastian Herbszt
Hello Christophe,
Quoted 9 lines · Christophe Varoqui
Hi,
the precedence chain is :
multipaths > user-specified per-device > default per-device > default
The issue adressed by Ben's patch would not be solved by your suggestion, as far as I can see. The proposed override section is just a way not repeat a per-device in each multipath (insane) or device (tedious) section.
Quoted 5 lines
care to explain why setting the precedence to
multipaths > user-specified per-device > default > default per-device
would not fix the issue?
I don't think the issue is that it wouldn't solve my problem. The issue is that it isn't as simple as it looks, and causes a large impact to existing users.
First off, I assume you mean
multipaths > user per-device > user default > builtin per-device > builtin default
What happens when users modify a builtin device configuration. Does the whole device configuration move up in presidence, or only the user modified parts? If the whole device does, This will cause lots of unexpected effects. If not, there will often be two devices sections controlling a multipath device along with two defaults sections, making the configuration output that much harder to read (I admit that the overrides section is basically a second devices section, but I assume that this feature will be rarely used. My original all_devs patch had the benefit that it adjusted all the device configurations directly, so users sill just needed to look in three sections to understand their configuration, instead of five with your method)
Also, adding a new section doesn't impact existing user configurations or user's existing understanding of how the multipath tools work. Your solution would cause a lot of broken configurations and relearning. This last point is my biggest objection. If we were starting from scratch your method would have probably made configuration enough more inituitive to justify the extra work of dealing with and displaying the two extra configuration sections. As it stands, I don't think it adds enough benefit to be worth the pain.
-Ben
Quoted 39 lines
Lets assume the following default device and user configuration:
.vendor = "COMPELNT", .product = "Compellent Vol", .pgpolicy = MULTIBUS, .pgfailback = -FAILBACK_IMMEDIATE.no_path_retry =
NO_PATH_RETRY_QUEUE,
.checker_name = TURdefaults {
no_path_retryfail
}devices { device { vendor "COMPELNT" product "Compellent Vol" path_grouping_policy "group_by_prio" } }multipaths { multipath { wwid 1234 failback 15 } }The default section should change
no_path_retryfrom "queue" to "fail". The device section should changepath_grouping_policyfrom "multibus" to "group_by_prio" for "COMPELNT/Compellent Vol".
The multipath section should change failback from "immediate" to 15 for wwid 1234.
Thepath_checkerwould still be "tur".Is this not what the "overrides" patch intended?
Sebastian
Benjamin Marzinski
maintainerRe: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
In reply to Christophe VaroquiQuoted 5 lines · Christophe Varoqui
I have no strong opinion on this one : I feel like the complexity of the parameter inheritance system is already quite complicated ... but this addition of a new layer would likely and safely be ignored by users who don't need it. Those who need it are surely ready to pay the price. Does someone have objection to my applying this patch ?
Christophe, I wrote this patch because you thought an "overrides" section would be more intuitive than my previous solution of a specialized "all_devs" devices section option to overwrite options on all the devices.
http://www.redhat.com/archives/dm-devel/2014-September/msg00047.html
Maybe this isn't exactly what you had in mind. At any rate, I'd like to have some method inside of multipath to accomplish this.
-Ben
Quoted 875 lines
Best regards, Christophe On Wed, Nov 19, 2014 at 7:17 AM, Benjamin Marzinski <[email protected]> wrote: Sometimes users want to be able to set a configuration value for all their devices (for instance, they may want all devices to set no_path_retry to fail). The builtin device configurations make this tricky, since users need to change each device configuration individually. To avoid that, this patch adds a new section to multipath.conf, "overrides".A This section has all of the attributes that are in both the devices and defaults section. Attributes set in the overrides section have a higher priority that those in the devices section. With this section added, the multipath configuration order now goes: multipaths > overrides > devices > defaults I also made want_user_friendly_names print out where the configuration came from, and I made made select_hwhandler and select_selector always strdup the string, instead of only on the defaults.A Since multipathd will update the device strings from the kernel anyway, the old way just added complexity without saving any memory. To store the overrides configuration, I used a hwentry structure. We may want to make a new overrides structure, so that we set any of the defaults values in overrides.A That way, users could skip using defaults and just use overrides if they wanted. However, this would take some additional changes to make sure that all the defaults options can undefined, which they can't currently be. Signed-off-by: Benjamin Marzinski <[email protected]> --- A libmultipath/config.cA A A |A 1 + A libmultipath/config.hA A A |A 1 + A libmultipath/dict.cA A A A | 98 ++++++++++++++++++++++++++++++++++++++++++++++ A libmultipath/print.cA A A A | 30 ++++++++++++++ A libmultipath/print.hA A A A |A 1 + A libmultipath/propsel.cA A A | 55 +++++++++++++++++++++----- A libmultipath/structs.cA A A |A 9 +---- A multipath.conf.annotatedA A | 18 ++++++++- A multipath.conf.defaultsA A |A 2 + A multipath.conf.syntheticA A |A 3 ++ A multipath/main.cA A A A A A |A 6 +++ A multipath/multipath.conf.5 | 57 +++++++++++++++++++++++++++ A multipathd/cli_handlers.cA | 10 +++++ A 13 files changed, 273 insertions(+), 18 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index bfd8ee8..7f7bd5a 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -523,6 +523,7 @@ free_config (struct config * conf) A A A A free_mptable(conf->mptable); A A A A free_hwtable(conf->hwtable); +A A A A free_hwe(conf->overrides); A A A A free_keywords(conf->keywords); A A A A FREE(conf); A } diff --git a/libmultipath/config.h b/libmultipath/config.h index c57ab31..ef1d7c3 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -145,6 +145,7 @@ struct config { A A A A vector keywords; A A A A vector mptable; A A A A vector hwtable; +A A A A struct hwentry *overrides; A A A A vector blist_devnode; A A A A vector blist_wwid; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 98cbe48..737c9b0 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -181,6 +181,22 @@ snprint_hw_ ## option (char * buff, int len, void * data)A A A A A \ A A A A return function (buff, len, &hwe->option);A A A A A A A A A A A \ A } +#define declare_ovr_handler(option, function)A A A A A A A A A A A A A \ +static intA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ +ovr_ ## option ## _handler (vector strvec)A A A A A A A A A A A A A A A \ +{A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ +A A A A if (!conf->overrides)A A A A A A A A A A A A A A A A A A A A A A \ +A A A A A A A A return 1;A A A A A A A A A A A A A A A A A A A A A A A A \ +A A A A return function (strvec, &conf->overrides->option);A A A A A A A \ +} + +#define declare_ovr_snprint(option, function)A A A A A A A A A A A A A \ +static intA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ +snprint_ovr_ ## option (char * buff, int len, void * data)A A A A A A A \ +{A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ +A A A A return function (buff, len, &conf->overrides->option);A A A A A \ +} + A #define declare_mp_handler(option, function)A A A A A A A A A A A A A A \ A static intA A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ A mp_ ## option ## _handler (vector strvec)A A A A A A A A A A A A A A A \ @@ -218,21 +234,29 @@ declare_def_handler(selector, set_str) A declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR) A declare_hw_handler(selector, set_str) A declare_hw_snprint(selector, print_str) +declare_ovr_handler(selector, set_str) +declare_ovr_snprint(selector, print_str) A declare_mp_handler(selector, set_str) A declare_mp_snprint(selector, print_str) A declare_def_handler(uid_attribute, set_str) A declare_def_snprint_defstr(uid_attribute, print_str, DEFAULT_UID_ATTRIBUTE) +declare_ovr_handler(uid_attribute, set_str) +declare_ovr_snprint(uid_attribute, print_str) A declare_hw_handler(uid_attribute, set_str) A declare_hw_snprint(uid_attribute, print_str) A declare_def_handler(getuid, set_str) A declare_def_snprint(getuid, print_str) +declare_ovr_handler(getuid, set_str) +declare_ovr_snprint(getuid, print_str) A declare_hw_handler(getuid, set_str) A declare_hw_snprint(getuid, print_str) A declare_def_handler(prio_name, set_str) A declare_def_snprint_defstr(prio_name, print_str, DEFAULT_PRIO) +declare_ovr_handler(prio_name, set_str) +declare_ovr_snprint(prio_name, print_str) A declare_hw_handler(prio_name, set_str) A declare_hw_snprint(prio_name, print_str) A declare_mp_handler(prio_name, set_str) @@ -240,11 +264,15 @@ declare_mp_snprint(prio_name, print_str) A declare_def_handler(alias_prefix, set_str) A declare_def_snprint_defstr(alias_prefix, print_str, DEFAULT_ALIAS_PREFIX) +declare_ovr_handler(alias_prefix, set_str) +declare_ovr_snprint(alias_prefix, print_str) A declare_hw_handler(alias_prefix, set_str) A declare_hw_snprint(alias_prefix, print_str) A declare_def_handler(prio_args, set_str) A declare_def_snprint_defstr(prio_args, print_str, DEFAULT_PRIO_ARGS) +declare_ovr_handler(prio_args, set_str) +declare_ovr_snprint(prio_args, print_str) A declare_hw_handler(prio_args, set_str) A declare_hw_snprint(prio_args, print_str) A declare_mp_handler(prio_args, set_str) @@ -252,6 +280,8 @@ declare_mp_snprint(prio_args, print_str) A declare_def_handler(features, set_str) A declare_def_snprint_defstr(features, print_str, DEFAULT_FEATURES) +declare_ovr_handler(features, set_str) +declare_ovr_snprint(features, print_str) A declare_hw_handler(features, set_str) A declare_hw_snprint(features, print_str) A declare_mp_handler(features, set_str) @@ -259,11 +289,15 @@ declare_mp_snprint(features, print_str) A declare_def_handler(checker_name, set_str) A declare_def_snprint_defstr(checker_name, print_str, DEFAULT_CHECKER) +declare_ovr_handler(checker_name, set_str) +declare_ovr_snprint(checker_name, print_str) A declare_hw_handler(checker_name, set_str) A declare_hw_snprint(checker_name, print_str) A declare_def_handler(minio, set_int) A declare_def_snprint_defint(minio, print_int, DEFAULT_MINIO) +declare_ovr_handler(minio, set_int) +declare_ovr_snprint(minio, print_nonzero) A declare_hw_handler(minio, set_int) A declare_hw_snprint(minio, print_nonzero) A declare_mp_handler(minio, set_int) @@ -271,6 +305,8 @@ declare_mp_snprint(minio, print_nonzero) A declare_def_handler(minio_rq, set_int) A declare_def_snprint_defint(minio_rq, print_int, DEFAULT_MINIO_RQ) +declare_ovr_handler(minio_rq, set_int) +declare_ovr_snprint(minio_rq, print_nonzero) A declare_hw_handler(minio_rq, set_int) A declare_hw_snprint(minio_rq, print_nonzero) A declare_mp_handler(minio_rq, set_int) @@ -296,6 +332,8 @@ declare_def_snprint(checker_timeout, print_nonzero) A declare_def_handler(flush_on_last_del, set_yes_no_undef) A declare_def_snprint_defint(flush_on_last_del, print_yes_no_undef, YNU_NO) +declare_ovr_handler(flush_on_last_del, set_yes_no_undef) +declare_ovr_snprint(flush_on_last_del, print_yes_no_undef) A declare_hw_handler(flush_on_last_del, set_yes_no_undef) A declare_hw_snprint(flush_on_last_del, print_yes_no_undef) A declare_mp_handler(flush_on_last_del, set_yes_no_undef) @@ -303,6 +341,8 @@ declare_mp_snprint(flush_on_last_del, print_yes_no_undef) A declare_def_handler(user_friendly_names, set_yes_no_undef) A declare_def_snprint_defint(user_friendly_names, print_yes_no_undef, YNU_NO) +declare_ovr_handler(user_friendly_names, set_yes_no_undef) +declare_ovr_snprint(user_friendly_names, print_yes_no_undef) A declare_hw_handler(user_friendly_names, set_yes_no_undef) A declare_hw_snprint(user_friendly_names, print_yes_no_undef) A declare_mp_handler(user_friendly_names, set_yes_no_undef) @@ -316,11 +356,15 @@ declare_def_snprint(wwids_file, print_str) A declare_def_handler(retain_hwhandler, set_yes_no_undef) A declare_def_snprint_defint(retain_hwhandler, print_yes_no_undef, YNU_NO) +declare_ovr_handler(retain_hwhandler, set_yes_no_undef) +declare_ovr_snprint(retain_hwhandler, print_yes_no_undef) A declare_hw_handler(retain_hwhandler, set_yes_no_undef) A declare_hw_snprint(retain_hwhandler, print_yes_no_undef) A declare_def_handler(detect_prio, set_yes_no_undef) A declare_def_snprint_defint(detect_prio, print_yes_no_undef, YNU_NO) +declare_ovr_handler(detect_prio, set_yes_no_undef) +declare_ovr_snprint(detect_prio, print_yes_no_undef) A declare_hw_handler(detect_prio, set_yes_no_undef) A declare_hw_snprint(detect_prio, print_yes_no_undef) @@ -512,6 +556,8 @@ print_fast_io_fail(char * buff, int len, void *ptr) A declare_def_handler(fast_io_fail, set_fast_io_fail) A declare_def_snprint(fast_io_fail, print_fast_io_fail) +declare_ovr_handler(fast_io_fail, set_fast_io_fail) +declare_ovr_snprint(fast_io_fail, print_fast_io_fail) A declare_hw_handler(fast_io_fail, set_fast_io_fail) A declare_hw_snprint(fast_io_fail, print_fast_io_fail) @@ -548,6 +594,8 @@ print_dev_loss(char * buff, int len, void *ptr) A declare_def_handler(dev_loss, set_dev_loss) A declare_def_snprint(dev_loss, print_dev_loss) +declare_ovr_handler(dev_loss, set_dev_loss) +declare_ovr_snprint(dev_loss, print_dev_loss) A declare_hw_handler(dev_loss, set_dev_loss) A declare_hw_snprint(dev_loss, print_dev_loss) @@ -583,6 +631,8 @@ print_pgpolicy(char * buff, int len, void *ptr) A declare_def_handler(pgpolicy, set_pgpolicy) A declare_def_snprint_defint(pgpolicy, print_pgpolicy, DEFAULT_PGPOLICY) +declare_ovr_handler(pgpolicy, set_pgpolicy) +declare_ovr_snprint(pgpolicy, print_pgpolicy) A declare_hw_handler(pgpolicy, set_pgpolicy) A declare_hw_snprint(pgpolicy, print_pgpolicy) A declare_mp_handler(pgpolicy, set_pgpolicy) @@ -700,6 +750,8 @@ print_rr_weight (char * buff, int len, void *ptr) A declare_def_handler(rr_weight, set_rr_weight) A declare_def_snprint_defint(rr_weight, print_rr_weight, RR_WEIGHT_NONE) +declare_ovr_handler(rr_weight, set_rr_weight) +declare_ovr_snprint(rr_weight, print_rr_weight) A declare_hw_handler(rr_weight, set_rr_weight) A declare_hw_snprint(rr_weight, print_rr_weight) A declare_mp_handler(rr_weight, set_rr_weight) @@ -748,6 +800,8 @@ print_pgfailback (char * buff, int len, void *ptr) A declare_def_handler(pgfailback, set_pgfailback) A declare_def_snprint_defint(pgfailback, print_pgfailback, DEFAULT_FAILBACK) +declare_ovr_handler(pgfailback, set_pgfailback) +declare_ovr_snprint(pgfailback, print_pgfailback) A declare_hw_handler(pgfailback, set_pgfailback) A declare_hw_snprint(pgfailback, print_pgfailback) A declare_mp_handler(pgfailback, set_pgfailback) @@ -793,6 +847,8 @@ print_no_path_retry(char * buff, int len, void *ptr) A declare_def_handler(no_path_retry, set_no_path_retry) A declare_def_snprint(no_path_retry, print_no_path_retry) +declare_ovr_handler(no_path_retry, set_no_path_retry) +declare_ovr_snprint(no_path_retry, print_no_path_retry) A declare_hw_handler(no_path_retry, set_no_path_retry) A declare_hw_snprint(no_path_retry, print_no_path_retry) A declare_mp_handler(no_path_retry, set_no_path_retry) @@ -1061,6 +1117,25 @@ declare_hw_handler(hwhandler, set_str) A declare_hw_snprint(hwhandler, print_str) A /* + * overrides handlers + */ +static int +overrides_handler(vector strvec) +{ +A A A A struct hwentry * overrides; + +A A A A overrides = alloc_hwe(); + +A A A A if (!overrides) +A A A A A A A A return 1; + +A A A A conf->overrides = overrides; +A A A A return 0; +} + + + +/* A * multipaths block handlers A */ A static int @@ -1236,6 +1311,29 @@ init_keywords(void) A A A A install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio); A A A A install_sublevel_end(); +A A A A install_keyword_root("overrides", &overrides_handler); +A A A A install_keyword("path_grouping_policy", &ovr_pgpolicy_handler, &snprint_ovr_pgpolicy); +A A A A install_keyword("uid_attribute", &ovr_uid_attribute_handler, &snprint_ovr_uid_attribute); +A A A A install_keyword("getuid_callout", &ovr_getuid_handler, &snprint_ovr_getuid); +A A A A install_keyword("path_selector", &ovr_selector_handler, &snprint_ovr_selector); +A A A A install_keyword("path_checker", &ovr_checker_name_handler, &snprint_ovr_checker_name); +A A A A install_keyword("checker", &ovr_checker_name_handler, NULL); +A A A A install_keyword("alias_prefix", &ovr_alias_prefix_handler, &snprint_ovr_alias_prefix); +A A A A install_keyword("features", &ovr_features_handler, &snprint_ovr_features); +A A A A install_keyword("prio", &ovr_prio_name_handler, &snprint_ovr_prio_name); +A A A A install_keyword("prio_args", &ovr_prio_args_handler, &snprint_ovr_prio_args); +A A A A install_keyword("failback", &ovr_pgfailback_handler, &snprint_ovr_pgfailback); +A A A A install_keyword("rr_weight", &ovr_rr_weight_handler, &snprint_ovr_rr_weight); +A A A A install_keyword("no_path_retry", &ovr_no_path_retry_handler, &snprint_ovr_no_path_retry); +A A A A install_keyword("rr_min_io", &ovr_minio_handler, &snprint_ovr_minio); +A A A A install_keyword("rr_min_io_rq", &ovr_minio_rq_handler, &snprint_ovr_minio_rq); +A A A A install_keyword("flush_on_last_del", &ovr_flush_on_last_del_handler, &snprint_ovr_flush_on_last_del); +A A A A install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail); +A A A A install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss); +A A A A install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names); +A A A A install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler); +A A A A install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio); + A A A A install_keyword_root("multipaths", &multipaths_handler); A A A A install_keyword_multi("multipath", &multipath_handler, NULL); A A A A install_sublevel(); diff --git a/libmultipath/print.c b/libmultipath/print.c index 383eae4..ade3841 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -1080,6 +1080,36 @@ snprint_mptable (char * buff, int len, vector mptable) A } A extern int +snprint_overrides (char * buff, int len, struct hwentry *overrides) +{ +A A A A int fwd = 0; +A A A A int i; +A A A A struct keyword *rootkw; +A A A A struct keyword *kw; + +A A A A rootkw = find_keyword(NULL, "overrides"); +A A A A if (!rootkw) +A A A A A A A A return 0; + +A A A A fwd += snprintf(buff + fwd, len - fwd, "overrides {\n"); +A A A A if (fwd > len) +A A A A A A A A return len; +A A A A if (!overrides) +A A A A A A A A goto out; +A A A A iterate_sub_keywords(rootkw, kw, i) { +A A A A A A A A fwd += snprint_keyword(buff + fwd, len - fwd, "\t%k %v\n", +A A A A A A A A A A A A A A A A A A A kw, NULL); +A A A A A A A A if (fwd > len) +A A A A A A A A A A A A return len; +A A A A } +out: +A A A A fwd += snprintf(buff + fwd, len - fwd, "}\n"); +A A A A if (fwd > len) +A A A A A A A A return len; +A A A A return fwd; +} + +extern int A snprint_defaults (char * buff, int len) A { A A A A int fwd = 0; diff --git a/libmultipath/print.h b/libmultipath/print.h index aef182b..a3c3319 100644 --- a/libmultipath/print.h +++ b/libmultipath/print.h @@ -50,6 +50,7 @@ int snprint_status (char *, int, struct vectors *); A int snprint_devices (char *, int, struct vectors *); A int snprint_hwtable (char *, int, vector); A int snprint_mptable (char *, int, vector); +int snprint_overrides (char *, int, struct hwentry *); A void print_multipath_topology (struct multipath * mpp, int verbosity); A void print_path (struct path * pp, char * style); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index f2ab7d2..440802c 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -48,6 +48,8 @@ do {A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ A do_set(var, mp->mpe, mp->var, "(LUN setting)") A #define mp_set_hwe(var)A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ A do_set(var, mp->hwe, mp->var, "(controller setting)") +#define mp_set_ovr(var)A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ +do_set(var, conf->overrides, mp->var, "(overrides setting)") A #define mp_set_conf(var)A A A A A A A A A A A A A A A A A A A A A A A A \ A do_set(var, conf, mp->var, "(config file default)") A #define mp_set_default(var, value)A A A A A A A A A A A A A A A A A A A \ @@ -59,6 +61,8 @@ do_set(var, mpe, pp->var, "(LUN setting)") A do_set(var, pp->hwe, pp->var, "(controller setting)") A #define pp_set_conf(var)A A A A A A A A A A A A A A A A A A A A A A A A \ A do_set(var, conf, pp->var, "(config file default)") +#define pp_set_ovr(var)A A A A A A A A A A A A A A A A A A A A A A A A A A A A \ +do_set(var, conf->overrides, pp->var, "(overrides setting)") A #define pp_set_default(var, value)A A A A A A A A A A A A A A A A A A A \ A do_default(pp->var, value) @@ -130,6 +134,7 @@ select_rr_weight (struct multipath * mp) A A A A char *origin, buff[13]; A A A A mp_set_mpe(rr_weight); +A A A A mp_set_ovr(rr_weight); A A A A mp_set_hwe(rr_weight); A A A A mp_set_conf(rr_weight); A A A A mp_set_default(rr_weight, RR_WEIGHT_NONE); @@ -145,6 +150,7 @@ select_pgfailback (struct multipath * mp) A A A A char *origin, buff[13]; A A A A mp_set_mpe(pgfailback); +A A A A mp_set_ovr(pgfailback); A A A A mp_set_hwe(pgfailback); A A A A mp_set_conf(pgfailback); A A A A mp_set_default(pgfailback, DEFAULT_FAILBACK); @@ -165,6 +171,7 @@ select_pgpolicy (struct multipath * mp) A A A A A A A A goto out; A A A A } A A A A mp_set_mpe(pgpolicy); +A A A A mp_set_ovr(pgpolicy); A A A A mp_set_hwe(pgpolicy); A A A A mp_set_conf(pgpolicy); A A A A mp_set_default(pgpolicy, DEFAULT_PGPOLICY); @@ -181,10 +188,12 @@ select_selector (struct multipath * mp) A A A A char *origin; A A A A mp_set_mpe(selector); +A A A A mp_set_ovr(selector); A A A A mp_set_hwe(selector); A A A A mp_set_conf(selector); -A A A A mp_set_default(selector, set_default(DEFAULT_SELECTOR)); +A A A A mp_set_default(selector, DEFAULT_SELECTOR); A out: +A A A A mp->selector = STRDUP(mp->selector); A A A A condlog(3, "%s: path_selector = \"%s\" %s", mp->alias, mp->selector, A A A A A A A A origin); A A A A return 0; @@ -195,6 +204,7 @@ select_alias_prefix (struct multipath * mp) A { A A A A char *origin; +A A A A mp_set_ovr(alias_prefix); A A A A mp_set_hwe(alias_prefix); A A A A mp_set_conf(alias_prefix); A A A A mp_set_default(alias_prefix, DEFAULT_ALIAS_PREFIX); @@ -206,19 +216,30 @@ out: A static int A want_user_friendly_names(struct multipath * mp) A { -A A A A if (mp->mpe && -A A A A A A mp->mpe->user_friendly_names != USER_FRIENDLY_NAMES_UNDEF) -A A A A A A A A return (mp->mpe->user_friendly_names == USER_FRIENDLY_NAMES_ON); -A A A A if (mp->hwe && -A A A A A A mp->hwe->user_friendly_names != USER_FRIENDLY_NAMES_UNDEF) -A A A A A A A A return (mp->hwe->user_friendly_names == USER_FRIENDLY_NAMES_ON); -A A A A return (conf->user_friendly_namesA == USER_FRIENDLY_NAMES_ON); + +A A A A char *origin; +A A A A int user_friendly_names; + +A A A A do_set(user_friendly_names, mp->mpe, user_friendly_names, +A A A A A A A "(LUN setting)"); +A A A A do_set(user_friendly_names, conf->overrides, user_friendly_names, +A A A A A A A "(overrides setting)"); +A A A A do_set(user_friendly_names, mp->hwe, user_friendly_names, +A A A A A A A "(controller setting)"); +A A A A do_set(user_friendly_names, conf, user_friendly_names, +A A A A A A A "(config file setting)"); +A A A A do_default(user_friendly_names, USER_FRIENDLY_NAMES_OFF); +out: +A A A A condlog(3, "%s: user_friendly_names = %s %s", mp->wwid, +A A A A A A A A (user_friendly_names == USER_FRIENDLY_NAMES_ON)? "yes" : "no", +A A A A A A A A origin); +A A A A return (user_friendly_names == USER_FRIENDLY_NAMES_ON); A } A extern int A select_alias (struct multipath * mp) A { -A A A A char *origin; +A A A A char *origin = NULL; A A A A if (mp->mpe && mp->mpe->alias) { A A A A A A A A mp->alias = STRDUP(mp->mpe->alias); @@ -261,6 +282,7 @@ select_features (struct multipath * mp) A A A A char *origin; A A A A mp_set_mpe(features); +A A A A mp_set_ovr(features); A A A A mp_set_hwe(features); A A A A mp_set_conf(features); A A A A mp_set_default(features, DEFAULT_FEATURES); @@ -287,8 +309,9 @@ select_hwhandler (struct multipath * mp) A A A A mp_set_hwe(hwhandler); A A A A mp_set_conf(hwhandler); -A A A A mp_set_default(hwhandler, set_default(DEFAULT_HWHANDLER)); +A A A A mp_set_default(hwhandler, DEFAULT_HWHANDLER); A out: +A A A A mp->hwhandler = STRDUP(mp->hwhandler); A A A A condlog(3, "%s: hardware_handler = \"%s\" %s", mp->alias, mp->hwhandler, A A A A A A A A origin); A A A A return 0; @@ -300,6 +323,7 @@ select_checker(struct path *pp) A A A A char *origin, *checker_name; A A A A struct checker * c = &pp->checker; +A A A A do_set(checker_name, conf->overrides, checker_name, "(overrides setting)"); A A A A do_set(checker_name, pp->hwe, checker_name, "(controller setting)"); A A A A do_set(checker_name, conf, checker_name, "(config file setting)"); A A A A do_default(checker_name, DEFAULT_CHECKER); @@ -327,6 +351,8 @@ select_getuid (struct path * pp) A { A A A A char *origin; +A A A A pp_set_ovr(uid_attribute); +A A A A pp_set_ovr(getuid); A A A A pp_set_hwe(uid_attribute); A A A A pp_set_hwe(getuid); A A A A pp_set_conf(uid_attribute); @@ -383,6 +409,7 @@ select_prio (struct path * pp) A A A A } A A A A mpe = find_mpe(pp->wwid); A A A A set_prio(mpe, "(LUN setting)"); +A A A A set_prio(conf->overrides, "(overrides setting)"); A A A A set_prio(pp->hwe, "controller setting)"); A A A A set_prio(conf, "(config file default)"); A A A A prio_get(p, DEFAULT_PRIO, DEFAULT_PRIO_ARGS); @@ -405,6 +432,7 @@ select_no_path_retry(struct multipath *mp) A A A A A A A A return 0; A A A A } A A A A mp_set_mpe(no_path_retry); +A A A A mp_set_ovr(no_path_retry); A A A A mp_set_hwe(no_path_retry); A A A A mp_set_conf(no_path_retry); A out: @@ -427,6 +455,7 @@ select_minio_rq (struct multipath * mp) A A A A char *origin; A A A A do_set(minio_rq, mp->mpe, mp->minio, "(LUN setting)"); +A A A A do_set(minio_rq, conf->overrides, mp->minio, "(overrides setting)"); A A A A do_set(minio_rq, mp->hwe, mp->minio, "(controller setting)"); A A A A do_set(minio_rq, conf, mp->minio, "(config file setting)"); A A A A do_default(mp->minio, DEFAULT_MINIO_RQ); @@ -441,6 +470,7 @@ select_minio_bio (struct multipath * mp) A A A A char *origin; A A A A mp_set_mpe(minio); +A A A A mp_set_ovr(minio); A A A A mp_set_hwe(minio); A A A A mp_set_conf(minio); A A A A mp_set_default(minio, DEFAULT_MINIO); @@ -465,6 +495,7 @@ select_fast_io_fail(struct multipath *mp) A { A A A A char *origin, buff[12]; +A A A A mp_set_ovr(fast_io_fail); A A A A mp_set_hwe(fast_io_fail); A A A A mp_set_conf(fast_io_fail); A A A A mp_set_default(fast_io_fail, DEFAULT_FAST_IO_FAIL); @@ -479,6 +510,7 @@ select_dev_loss(struct multipath *mp) A { A A A A char *origin, buff[12]; +A A A A mp_set_ovr(dev_loss); A A A A mp_set_hwe(dev_loss); A A A A mp_set_conf(dev_loss); A A A A mp->dev_loss = 0; @@ -497,6 +529,7 @@ select_flush_on_last_del(struct multipath *mp) A A A A if (mp->flush_on_last_del == FLUSH_IN_PROGRESS) A A A A A A A A return 0; A A A A mp_set_mpe(flush_on_last_del); +A A A A mp_set_ovr(flush_on_last_del); A A A A mp_set_hwe(flush_on_last_del); A A A A mp_set_conf(flush_on_last_del); A A A A mp_set_default(flush_on_last_del, FLUSH_DISABLED); @@ -532,6 +565,7 @@ select_retain_hwhandler (struct multipath * mp) A A A A A A A A origin = "(requires kernel version >= 1.5.0)"; A A A A A A A A goto out; A A A A } +A A A A mp_set_ovr(retain_hwhandler); A A A A mp_set_hwe(retain_hwhandler); A A A A mp_set_conf(retain_hwhandler); A A A A mp_set_default(retain_hwhandler, DEFAULT_RETAIN_HWHANDLER); @@ -547,6 +581,7 @@ select_detect_prio (struct path * pp) A { A A A A char *origin; +A A A A pp_set_ovr(detect_prio); A A A A pp_set_hwe(detect_prio); A A A A pp_set_conf(detect_prio); A A A A pp_set_default(detect_prio, DEFAULT_DETECT_PRIO); diff --git a/libmultipath/structs.c b/libmultipath/structs.c index 30d247d..0538327 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -206,10 +206,7 @@ free_multipath_attributes (struct multipath * mpp) A A A A if (!mpp) A A A A A A A A return; -A A A A if (mpp->selector && -A A A A A A mpp->selector != conf->selector && -A A A A A A (!mpp->mpe || (mpp->mpe && mpp->selector != mpp->mpe->selector)) && -A A A A A A (!mpp->hwe || (mpp->hwe && mpp->selector != mpp->hwe->selector))) { +A A A A if (mpp->selector) { A A A A A A A A FREE(mpp->selector); A A A A A A A A mpp->selector = NULL; A A A A } @@ -219,9 +216,7 @@ free_multipath_attributes (struct multipath * mpp) A A A A A A A A mpp->features = NULL; A A A A } -A A A A if (mpp->hwhandler && -A A A A A A mpp->hwhandler != conf->hwhandler && -A A A A A A (!mpp->hwe || (mpp->hwe && mpp->hwhandler != mpp->hwe->hwhandler))) { +A A A A if (mpp->hwhandler) { A A A A A A A A FREE(mpp->hwhandler); A A A A A A A A mpp->hwhandler = NULL; A A A A } diff --git a/multipath.conf.annotated b/multipath.conf.annotated index 0af1d4c..71afc0a 100644 --- a/multipath.conf.annotated +++ b/multipath.conf.annotated @@ -485,7 +485,8 @@ A ## scope : multipath & multipathd A ## descA : list of per storage controller settings A ##A A A A overrides default settings (device_maps block) -##A A A A A overriden by per multipath settings (multipaths block) +##A A A A overriden by per multipath settings (multipaths block) +##A A A A and the overrides settings (overrides block) A ## A #devices { A #A A A # @@ -651,3 +652,18 @@ A #A A A A A A A rr_weightA A A A A A A A priorities A #A A A } A #} +# +## +## nameA : devices +## scope : multipath & multipathd +## descA : list of settings to override all hadware settings for all devices +##A A A A overrides default settings (device_maps block) +##A A A A and per device type settings (devices block) +##A A A A overriden by per multipath settings (multipaths block) +## +#A A A attributes and values are identical to the device block +# +#overrides { +#A A A dev_loss_tmoA A A A A A 60 +#A A A no_path_retryA A A A A A fail +#} diff --git a/multipath.conf.defaults b/multipath.conf.defaults index 654be97..1c65e02 100644 --- a/multipath.conf.defaults +++ b/multipath.conf.defaults @@ -912,3 +912,5 @@ A #} A #multipaths { A #} +#overrides { +#} diff --git a/multipath.conf.synthetic b/multipath.conf.synthetic index bda1b75..f7b9b8a 100644 --- a/multipath.conf.synthetic +++ b/multipath.conf.synthetic @@ -72,3 +72,6 @@ A #A A A A A A A path_grouping_policyA A multibus A #A A A } A #} +#overrides { +#A A A no_path_retryA A A A A A A A A A fail +#} diff --git a/multipath/main.c b/multipath/main.c index fd6262f..ea453b4 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -405,6 +405,12 @@ dump_config (void) A A A A A A A A A A A A reply = REALLOC(reply, maxlen *= 2); A A A A A A A A A A A A continue; A A A A A A A A } +A A A A A A A A c += snprint_overrides(c, reply + maxlen - c, conf->overrides); +A A A A A A A A again = ((c - reply) == maxlen); +A A A A A A A A if (again) { +A A A A A A A A A A A A reply = REALLOC(reply, maxlen *= 2); +A A A A A A A A A A A A continue; +A A A A A A A A } A A A A A A A A c += snprint_mptable(c, reply + maxlen - c, conf->mptable); A A A A A A A A again = ((c - reply) == maxlen); A A A A A A A A if (again) diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index cadb34d..b823990 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -61,6 +61,10 @@ the udev attribute given by the A .TP A .B devices A This section defines the device-specific settings. +.TP +.B overrides +This section defines values for attributes that should override the +device-specific settings for all devices. A .RE A .LP A .SH "defaults section" @@ -629,6 +633,59 @@ section: A .RE A .PD A .LP +.SH "overrides section" +The overrides section recognizes the following optional attributes; if not set +the values are taken from the +.I devices +or +.I defaults +sections: +.sp 1 +.PD .1v +.RS +.TP 18 +.B path_grouping_policy +.TP +.B uid_attribute +.TP +.B getuid_callout +.TP +.B path_selector +.TP +.B path_checker +.TP +.B alias_prefix +.TP +.B features +.TP +.B prio +.TP +.B prio_args +.TP +.B failback +.TP +.B rr_weight +.TP +.B no_path_retry +.TP +.B rr_min_io +.TP +.B rr_min_io_rq +.TP +.B flush_on_last_del +.TP +.B fast_io_fail_tmo +.TP +.B dev_loss_tmo +.TP +.B user_friendly_names +.TP +.B retain_attached_hw_handler +.TP +.B detect_prio +.RE +.PD +.LP A .SH "KNOWN ISSUES" A The usage of A .B queue_if_no_path diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index b086340..0ce1408 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -190,6 +190,16 @@ show_config (char ** r, int * len) A A A A A A A A A A A A maxlen *= 2; A A A A A A A A A A A A continue; A A A A A A A A } +A A A A A A A A c += snprint_overrides(c, reply + maxlen - c, conf->overrides); +A A A A A A A A again = ((c - reply) == maxlen); +A A A A A A A A if (again) { +A A A A A A A A A A A A reply = REALLOC(reply, maxlen * 2); +A A A A A A A A A A A A if (!reply) +A A A A A A A A A A A A A A A A return 1; +A A A A A A A A A A A A memset(reply + maxlen, 0, maxlen); +A A A A A A A A A A A A maxlen *= 2; +A A A A A A A A A A A A continue; +A A A A A A A A } A A A A A A A A c += snprint_mptable(c, reply + maxlen - c, conf->mptable); A A A A A A A A again = ((c - reply) == maxlen); A A A A A A A A REALLOC_REPLY(reply, again, maxlen); -- 1.8.3.1
Re: [PATCH 3/6] libmultipath: add overrides section to multipath.conf
Ben,
I have no complaints about this patch iteration, and acknowledged the need for some users. As nobody voiced against it, I will apply the patch.
Thanks,
Christophe Varoqui
OpenSVC
Quoted 973 lines · Benjamin Marzinski
Quoted 1 line · Christophe Varoqui
I have no strong opinion on this one : I feel like the complexity of
the
Quoted 2 lines
parameter inheritance system is already quite complicated ... but this addition of a new layer would likely and safely be ignored by users
who
Quoted 2 lines
don't need it. Those who need it are surely ready to pay the price. Does someone have objection to my applying this patch ?
Christophe, I wrote this patch because you thought an "overrides" section would be more intuitive than my previous solution of a specialized "
all_devs" devices section option to overwrite options on all the devices.http://www.redhat.com/archives/dm-devel/2014-September/msg00047.html
Maybe this isn't exactly what you had in mind. At any rate, I'd like to have some method inside of multipath to accomplish this.
-Ben
Quoted 3 lines
Best regards,
Christophe
On Wed, Nov 19, 2014 at 7:17 AM, Benjamin Marzinski <Quoted 5 lines
wrote:
Sometimes users want to be able to set a configuration value for all their
devices (for instance, they may want all devices to set
no_path_retrytoQuoted 1 line
fail). The builtin device configurations make this tricky, since
users
Quoted 2 lines
need
to change each device configuration individually. To avoid that,this
Quoted 2 lines
patch
adds a new section to multipath.conf, "overrides".A This sectionhas
Quoted 10 lines
all of
the attributes that are in both the devices and defaults section. Attributes set in the overrides section have a higher priority that those
in the devices section. With this section added, the multipath configuration order now goes:multipaths > overrides > devices > defaults
I also made
want_user_friendly_namesprint out where theconfiguration
Quoted 2 lines
came
from, and I made madeselect_hwhandlerandselect_selectoralwaysstrdup
Quoted 6 lines
the string, instead of only on the defaults.A Since multipathd will update
the device strings from the kernel anyway, the old way just added complexity without saving any memory.To store the overrides configuration, I used a hwentry structure.
We may
Quoted 5 lines
want to make a new overrides structure, so that we set any of the defaults
values in overrides.A That way, users could skip using defaults and just
use overrides if they wanted. However, this would take someadditional
Quoted 1 line
changes to make sure that all the defaults options can undefined,
which
Quoted 42 lines
they can't currently be. Signed-off-by: Benjamin Marzinski <[email protected]> --- A libmultipath/config.cA A A |A 1 + A libmultipath/config.hA A A |A 1 + A libmultipath/dict.cA A A A | 98 ++++++++++++++++++++++++++++++++++++++++++++++ A libmultipath/print.cA A A A | 30 ++++++++++++++ A libmultipath/print.hA A A A |A 1 + A libmultipath/propsel.cA A A | 55 +++++++++++++++++++++----- A libmultipath/structs.cA A A |A 9 +---- A multipath.conf.annotatedA A | 18 ++++++++- A multipath.conf.defaultsA A |A 2 + A multipath.conf.syntheticA A |A 3 ++ A multipath/main.cA A A A A A |A 6 +++ A multipath/multipath.conf.5 | 57 +++++++++++++++++++++++++++ A multipathd/cli_handlers.cA | 10 +++++ A 13 files changed, 273 insertions(+), 18 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index bfd8ee8..7f7bd5a 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -523,6 +523,7 @@ free_config (struct config * conf) A A A A free_mptable(conf->mptable); A A A A free_hwtable(conf->hwtable); +A A A A free_hwe(conf->overrides); A A A A free_keywords(conf->keywords); A A A A FREE(conf); A } diff --git a/libmultipath/config.h b/libmultipath/config.h index c57ab31..ef1d7c3 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -145,6 +145,7 @@ struct config { A A A A vector keywords; A A A A vector mptable; A A A A vector hwtable; +A A A A struct hwentry *overrides;Quoted 7 lines
A A A A vector blist_devnode; A A A A vector blist_wwid; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 98cbe48..737c9b0 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -181,6 +181,22 @@ snprint_hw_ ## option (char * buff, int len,void *
Quoted 2 lines
data)A A A A A \ A A A A return function (buff, len, &hwe->option);A A A AA A
Quoted 4 lines
A A A A A \ A } +#define declare_ovr_handler(option, function)A A A A A A AA A
Quoted 2 lines
A A A A \
+static intA A A A A A A A A A A A A A A A A A AA
Quoted 2 lines
A A A A A A A A A A A \
+ovr_ ## option ##_handler(vector strvec)A A A A A A A AA A
Quoted 2 lines
A A A A A \
+{A A A A A A A A A A A A A A A A A A A A A AA
Quoted 2 lines
A A A A A A A A A A A A \ +A A A A if (!conf->overrides)A A A A A A A A A A AA A
Quoted 2 lines
A A A A A A A A A \
+A A A A A A A A return 1;A A A A A A A A A A AA A
Quoted 2 lines
A A A A A A A A A A A \ +A A A A return function (strvec, &conf->overrides->option);AA A
Quoted 4 lines
A A A A \ +} + +#define declare_ovr_snprint(option, function)A A A A A A AA A
Quoted 2 lines
A A A A \
+static intA A A A A A A A A A A A A A A A A A AA
Quoted 2 lines
A A A A A A A A A A A \
+snprint_ovr_ ## option (char * buff, int len, void * data)A A AA
Quoted 2 lines
A A A \
+{A A A A A A A A A A A A A A A A A A A A A AA
Quoted 2 lines
A A A A A A A A A A A A \
+A A A A return function (buff, len,&conf->overrides->option);A A
Quoted 4 lines
A A A \ +} + A #define declare_mp_handler(option, function)A A A A A A AA A
Quoted 2 lines
A A A A A \
A static intA A A A A A A A A A A A A A A A A AA A
Quoted 2 lines
A A A A A A A A A A A \
Amp_## option ##_handler(vector strvec)A A A A A A A AA A
Quoted 42 lines
A A A A A \
@@ -218,21 +234,29 @@declare_def_handler(selector, set_str)Adeclare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)Adeclare_hw_handler(selector, set_str)
Adeclare_hw_snprint(selector, print_str)+declare_ovr_handler(selector,set_str) +declare_ovr_snprint(selector,print_str)
Adeclare_mp_handler(selector, set_str)
Adeclare_mp_snprint(selector, print_str)A
declare_def_handler(uid_attribute, set_str)Adeclare_def_snprint_defstr(uid_attribute, print_str, DEFAULT_UID_ATTRIBUTE)+declare_ovr_handler(uid_attribute,set_str) +declare_ovr_snprint(uid_attribute,print_str) Adeclare_hw_handler(uid_attribute, set_str)Adeclare_hw_snprint(uid_attribute, print_str)A
declare_def_handler(getuid, set_str)
Adeclare_def_snprint(getuid, print_str)
+declare_ovr_handler(getuid,set_str)
+declare_ovr_snprint(getuid,print_str)
Adeclare_hw_handler(getuid, set_str)
Adeclare_hw_snprint(getuid, print_str)A
declare_def_handler(prio_name, set_str)
Adeclare_def_snprint_defstr(prio_name, print_str, DEFAULT_PRIO)+declare_ovr_handler(prio_name,set_str) +declare_ovr_snprint(prio_name,print_str)
Adeclare_hw_handler(prio_name, set_str)
Adeclare_hw_snprint(prio_name, print_str)
Adeclare_mp_handler(prio_name, set_str)
@@ -240,11 +264,15 @@declare_mp_snprint(prio_name, print_str)A
declare_def_handler(alias_prefix, set_str)Adeclare_def_snprint_defstr(alias_prefix, print_str, DEFAULT_ALIAS_PREFIX)+declare_ovr_handler(alias_prefix,set_str) +declare_ovr_snprint(alias_prefix,print_str) Adeclare_hw_handler(alias_prefix, set_str)Adeclare_hw_snprint(alias_prefix, print_str)Quoted 2 lines
A
declare_def_handler(prio_args, set_str)A declare_def_snprint_defstr(prio_args,print_str,
DEFAULT_PRIO_ARGS)Quoted 16 lines
+declare_ovr_handler(prio_args,
set_str) +declare_ovr_snprint(prio_args,print_str)
Adeclare_hw_handler(prio_args, set_str)
Adeclare_hw_snprint(prio_args, print_str)
Adeclare_mp_handler(prio_args, set_str)
@@ -252,6 +280,8 @@declare_mp_snprint(prio_args, print_str)A
declare_def_handler(features, set_str)
Adeclare_def_snprint_defstr(features, print_str, DEFAULT_FEATURES)+declare_ovr_handler(features,set_str) +declare_ovr_snprint(features,print_str)
Adeclare_hw_handler(features, set_str)
Adeclare_hw_snprint(features, print_str)
Adeclare_mp_handler(features, set_str)
@@ -259,11 +289,15 @@declare_mp_snprint(features, print_str)Quoted 2 lines
A
declare_def_handler(checker_name, set_str)A declare_def_snprint_defstr(checker_name,print_str,
DEFAULT_CHECKER)Quoted 14 lines
+declare_ovr_handler(checker_name,
set_str) +declare_ovr_snprint(checker_name,print_str) Adeclare_hw_handler(checker_name, set_str)Adeclare_hw_snprint(checker_name, print_str)A
declare_def_handler(minio, set_int)
Adeclare_def_snprint_defint(minio, print_int, DEFAULT_MINIO)+declare_ovr_handler(minio,set_int) +declare_ovr_snprint(minio,print_nonzero)
Adeclare_hw_handler(minio, set_int)
Adeclare_hw_snprint(minio, print_nonzero)
Adeclare_mp_handler(minio, set_int)
@@ -271,6 +305,8 @@declare_mp_snprint(minio, print_nonzero)Quoted 8 lines
A
declare_def_handler(minio_rq, set_int)
Adeclare_def_snprint_defint(minio_rq, print_int, DEFAULT_MINIO_RQ)+declare_ovr_handler(minio_rq,set_int) +declare_ovr_snprint(minio_rq,print_nonzero)
Adeclare_hw_handler(minio_rq, set_int)
Adeclare_hw_snprint(minio_rq, print_nonzero)
Adeclare_mp_handler(minio_rq, set_int)
@@ -296,6 +332,8 @@ declare_def_snprint(checker_timeout,
print_nonzero)Quoted 12 lines
A
declare_def_handler(flush_on_last_del, set_yes_no_undef)Adeclare_def_snprint_defint(flush_on_last_del, print_yes_no_undef, YNU_NO)
+declare_ovr_handler(flush_on_last_del,set_yes_no_undef) +declare_ovr_snprint(flush_on_last_del,print_yes_no_undef) Adeclare_hw_handler(flush_on_last_del, set_yes_no_undef)Adeclare_hw_snprint(flush_on_last_del, print_yes_no_undef)Adeclare_mp_handler(flush_on_last_del, set_yes_no_undef)@@ -303,6 +341,8 @@declare_mp_snprint(flush_on_last_del, print_yes_no_undef)Quoted 2 lines
A
declare_def_handler(user_friendly_names, set_yes_no_undef)A declare_def_snprint_defint(user_friendly_names,
print_yes_no_undef,Quoted 16 lines
YNU_NO)
+declare_ovr_handler(user_friendly_names,set_yes_no_undef) +declare_ovr_snprint(user_friendly_names,print_yes_no_undef) Adeclare_hw_handler(user_friendly_names, set_yes_no_undef)Adeclare_hw_snprint(user_friendly_names, print_yes_no_undef)Adeclare_mp_handler(user_friendly_names, set_yes_no_undef)@@ -316,11 +356,15 @@declare_def_snprint(wwids_file, print_str)A
declare_def_handler(retain_hwhandler, set_yes_no_undef)Adeclare_def_snprint_defint(retain_hwhandler, print_yes_no_undef, YNU_NO)
+declare_ovr_handler(retain_hwhandler,set_yes_no_undef) +declare_ovr_snprint(retain_hwhandler,print_yes_no_undef) Adeclare_hw_handler(retain_hwhandler, set_yes_no_undef)Adeclare_hw_snprint(retain_hwhandler, print_yes_no_undef)Quoted 2 lines
A
declare_def_handler(detect_prio, set_yes_no_undef)A declare_def_snprint_defint(detect_prio,print_yes_no_undef,
YNU_NO)Quoted 6 lines
+declare_ovr_handler(detect_prio,
set_yes_no_undef) +declare_ovr_snprint(detect_prio,print_yes_no_undef) Adeclare_hw_handler(detect_prio, set_yes_no_undef)Adeclare_hw_snprint(detect_prio, print_yes_no_undef)@@ -512,6 +556,8 @@ print_fast_io_fail(char * buff, int len, void
*ptr)
Quoted 17 lines
A
declare_def_handler(fast_io_fail, set_fast_io_fail)Adeclare_def_snprint(fast_io_fail, print_fast_io_fail)+declare_ovr_handler(fast_io_fail,set_fast_io_fail) +declare_ovr_snprint(fast_io_fail,print_fast_io_fail) Adeclare_hw_handler(fast_io_fail, set_fast_io_fail)Adeclare_hw_snprint(fast_io_fail, print_fast_io_fail)@@ -548,6 +594,8 @@
print_dev_loss(char * buff, int len, void *ptr)A
declare_def_handler(dev_loss, set_dev_loss)Adeclare_def_snprint(dev_loss, print_dev_loss)+declare_ovr_handler(dev_loss,set_dev_loss) +declare_ovr_snprint(dev_loss,print_dev_loss) Adeclare_hw_handler(dev_loss, set_dev_loss)Adeclare_hw_snprint(dev_loss, print_dev_loss)Quoted 4 lines
@@ -583,6 +631,8 @@
print_pgpolicy(char * buff, int len, void *ptr)A
declare_def_handler(pgpolicy, set_pgpolicy)A declare_def_snprint_defint(pgpolicy,print_pgpolicy,
DEFAULT_PGPOLICY)Quoted 6 lines
+declare_ovr_handler(pgpolicy,
set_pgpolicy) +declare_ovr_snprint(pgpolicy,print_pgpolicy)
Adeclare_hw_handler(pgpolicy, set_pgpolicy)
Adeclare_hw_snprint(pgpolicy, print_pgpolicy)
Adeclare_mp_handler(pgpolicy, set_pgpolicy)
@@ -700,6 +750,8 @@print_rr_weight(char * buff, int len, void*ptr)
Quoted 3 lines
A
declare_def_handler(rr_weight, set_rr_weight)A declare_def_snprint_defint(rr_weight,print_rr_weight,
RR_WEIGHT_NONE)Quoted 6 lines
+declare_ovr_handler(rr_weight,
set_rr_weight) +declare_ovr_snprint(rr_weight,print_rr_weight)
Adeclare_hw_handler(rr_weight, set_rr_weight)
Adeclare_hw_snprint(rr_weight, print_rr_weight)
Adeclare_mp_handler(rr_weight, set_rr_weight)
@@ -748,6 +800,8 @@print_pgfailback(char * buff, int len, void*ptr)
Quoted 10 lines
A
declare_def_handler(pgfailback, set_pgfailback)
Adeclare_def_snprint_defint(pgfailback, print_pgfailback, DEFAULT_FAILBACK)
+declare_ovr_handler(pgfailback,set_pgfailback) +declare_ovr_snprint(pgfailback,print_pgfailback)
Adeclare_hw_handler(pgfailback, set_pgfailback)
Adeclare_hw_snprint(pgfailback, print_pgfailback)
Adeclare_mp_handler(pgfailback, set_pgfailback)
@@ -793,6 +847,8 @@ print_no_path_retry(char * buff, int len, void*ptr)
Quoted 35 lines
A declare_def_handler(no_path_retry, set_no_path_retry) A declare_def_snprint(no_path_retry, print_no_path_retry) +declare_ovr_handler(no_path_retry, set_no_path_retry) +declare_ovr_snprint(no_path_retry, print_no_path_retry) A declare_hw_handler(no_path_retry, set_no_path_retry) A declare_hw_snprint(no_path_retry, print_no_path_retry) A declare_mp_handler(no_path_retry, set_no_path_retry) @@ -1061,6 +1117,25 @@ declare_hw_handler(hwhandler, set_str) A declare_hw_snprint(hwhandler, print_str) A /* + * overrides handlers + */ +static int +overrides_handler(vector strvec) +{ +A A A A struct hwentry * overrides; + +A A A A overrides = alloc_hwe(); + +A A A A if (!overrides) +A A A A A A A A return 1; + +A A A A conf->overrides = overrides; +A A A A return 0; +} + + + +/* A * multipaths block handlers A */ A static int @@ -1236,6 +1311,29 @@ init_keywords(void)Quoted 8 lines
A A A A install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio); A A A A install_sublevel_end(); +A A A A install_keyword_root("overrides", &overrides_handler); +A A A A install_keyword("path_grouping_policy", &ovr_pgpolicy_handler, &snprint_ovr_pgpolicy); +A A A A install_keyword("uid_attribute",
&ovr_uid_attribute_handler,Quoted 6 lines
&snprint_ovr_uid_attribute);
+A A A Ainstall_keyword("getuid_callout", &ovr_getuid_handler, &snprint_ovr_getuid);
+A A A Ainstall_keyword("path_selector", &ovr_selector_handler, &snprint_ovr_selector);
+A A A A install_keyword("path_checker",
&ovr_checker_name_handler,Quoted 2 lines
&snprint_ovr_checker_name);
+A A A A install_keyword("checker",&ovr_checker_name_handler,NULL);
Quoted 1 line
+A A A A install_keyword("alias_prefix",
&ovr_alias_prefix_handler,Quoted 4 lines
&snprint_ovr_alias_prefix);
+A A A Ainstall_keyword("features", &ovr_features_handler, &snprint_ovr_features);
+A A A A install_keyword("prio",&ovr_prio_name_handler,Quoted 8 lines
&snprint_ovr_prio_name);
+A A A Ainstall_keyword("prio_args", &ovr_prio_args_handler, &snprint_ovr_prio_args);
+A A A Ainstall_keyword("failback", &ovr_pgfailback_handler, &snprint_ovr_pgfailback);
+A A A Ainstall_keyword("rr_weight", &ovr_rr_weight_handler, &snprint_ovr_rr_weight);
+A A A A install_keyword("no_path_retry",
&ovr_no_path_retry_handler,Quoted 41 lines
&snprint_ovr_no_path_retry); +A A A A install_keyword("rr_min_io", &ovr_minio_handler, &snprint_ovr_minio); +A A A A install_keyword("rr_min_io_rq", &ovr_minio_rq_handler, &snprint_ovr_minio_rq); +A A A A install_keyword("flush_on_last_del", &ovr_flush_on_last_del_handler, &snprint_ovr_flush_on_last_del); +A A A A install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail); +A A A A install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss); +A A A A install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names); +A A A A install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler); +A A A A install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio); + A A A A install_keyword_root("multipaths", &multipaths_handler); A A A A install_keyword_multi("multipath", &multipath_handler, NULL); A A A A install_sublevel(); diff --git a/libmultipath/print.c b/libmultipath/print.c index 383eae4..ade3841 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -1080,6 +1080,36 @@ snprint_mptable (char * buff, int len, vector mptable) A } A extern int +snprint_overrides (char * buff, int len, struct hwentry *overrides) +{ +A A A A int fwd = 0; +A A A A int i; +A A A A struct keyword *rootkw; +A A A A struct keyword *kw; + +A A A A rootkw = find_keyword(NULL, "overrides"); +A A A A if (!rootkw) +A A A A A A A A return 0;Quoted 8 lines
+ +A A A A fwd += snprintf(buff + fwd, len - fwd, "overrides {\n"); +A A A A if (fwd > len) +A A A A A A A A return len; +A A A A if (!overrides) +A A A A A A A A goto out; +A A A A iterate_sub_keywords(rootkw, kw, i) { +A A A A A A A A fwd += snprint_keyword(buff + fwd, len -fwd,
Quoted 13 lines
"\t%k %v\n", +A A A A A A A A A A A A A A A A A A A kw, NULL); +A A A A A A A A if (fwd > len) +A A A A A A A A A A A A return len; +A A A A } +out: +A A A A fwd += snprintf(buff + fwd, len - fwd, "}\n"); +A A A A if (fwd > len) +A A A A A A A A return len; +A A A A return fwd; +} + +extern intQuoted 8 lines
A snprint_defaults (char * buff, int len) A { A A A A int fwd = 0; diff --git a/libmultipath/print.h b/libmultipath/print.h index aef182b..a3c3319 100644 --- a/libmultipath/print.h +++ b/libmultipath/print.h @@ -50,6 +50,7 @@ int snprint_status (char *, int, struct vectors*);
Quoted 6 lines
A int snprint_devices (char *, int, struct vectors *); A int snprint_hwtable (char *, int, vector); A int snprint_mptable (char *, int, vector); +int snprint_overrides (char *, int, struct hwentry *); A void print_multipath_topology (struct multipath * mpp, intverbosity);
Quoted 6 lines
A void print_path (struct path * pp, char * style); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index f2ab7d2..440802c 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -48,6 +48,8 @@ do {A A A A A A A A A A A A A A AA A
Quoted 3 lines
A A A A A A A A A A A A A A A A \ A do_set(var, mp->mpe, mp->var, "(LUN setting)") A #define mp_set_hwe(var)A A A A A A A A A A A A A AA A
Quoted 3 lines
A A A A A A A A A A A A \ A do_set(var, mp->hwe, mp->var, "(controller setting)") +#define mp_set_ovr(var)A A A A A A A A A A A A A AA A
Quoted 3 lines
A A A A A A A A A A A A \ +do_set(var, conf->overrides, mp->var, "(overrides setting)") A #define mp_set_conf(var)A A A A A A A A A A A A A AA
Quoted 3 lines
A A A A A A A A A \ A do_set(var, conf, mp->var, "(config file default)") A #define mp_set_default(var, value)A A A A A A A A A AA A
Quoted 4 lines
A A A A A A A \ @@ -59,6 +61,8 @@ do_set(var, mpe, pp->var, "(LUN setting)") A do_set(var, pp->hwe, pp->var, "(controller setting)") A #define pp_set_conf(var)A A A A A A A A A A A A A AA
Quoted 3 lines
A A A A A A A A A \ A do_set(var, conf, pp->var, "(config file default)") +#define pp_set_ovr(var)A A A A A A A A A A A A A AA A
Quoted 3 lines
A A A A A A A A A A A A \ +do_set(var, conf->overrides, pp->var, "(overrides setting)") A #define pp_set_default(var, value)A A A A A A A A A AA A
Quoted 63 lines
A A A A A A A \ A do_default(pp->var, value) @@ -130,6 +134,7 @@ select_rr_weight (struct multipath * mp) A A A A char *origin, buff[13]; A A A A mp_set_mpe(rr_weight); +A A A A mp_set_ovr(rr_weight); A A A A mp_set_hwe(rr_weight); A A A A mp_set_conf(rr_weight); A A A A mp_set_default(rr_weight, RR_WEIGHT_NONE); @@ -145,6 +150,7 @@ select_pgfailback (struct multipath * mp) A A A A char *origin, buff[13]; A A A A mp_set_mpe(pgfailback); +A A A A mp_set_ovr(pgfailback); A A A A mp_set_hwe(pgfailback); A A A A mp_set_conf(pgfailback); A A A A mp_set_default(pgfailback, DEFAULT_FAILBACK); @@ -165,6 +171,7 @@ select_pgpolicy (struct multipath * mp) A A A A A A A A goto out; A A A A } A A A A mp_set_mpe(pgpolicy); +A A A A mp_set_ovr(pgpolicy); A A A A mp_set_hwe(pgpolicy); A A A A mp_set_conf(pgpolicy); A A A A mp_set_default(pgpolicy, DEFAULT_PGPOLICY); @@ -181,10 +188,12 @@ select_selector (struct multipath * mp) A A A A char *origin; A A A A mp_set_mpe(selector); +A A A A mp_set_ovr(selector); A A A A mp_set_hwe(selector); A A A A mp_set_conf(selector); -A A A A mp_set_default(selector, set_default(DEFAULT_SELECTOR)); +A A A A mp_set_default(selector, DEFAULT_SELECTOR); A out: +A A A A mp->selector = STRDUP(mp->selector); A A A A condlog(3, "%s: path_selector = \"%s\" %s", mp->alias, mp->selector, A A A A A A A A origin); A A A A return 0; @@ -195,6 +204,7 @@ select_alias_prefix (struct multipath * mp) A { A A A A char *origin; +A A A A mp_set_ovr(alias_prefix); A A A A mp_set_hwe(alias_prefix); A A A A mp_set_conf(alias_prefix); A A A A mp_set_default(alias_prefix, DEFAULT_ALIAS_PREFIX); @@ -206,19 +216,30 @@ out: A static int A want_user_friendly_names(struct multipath * mp) A { -A A A A if (mp->mpe && -A A A A A A mp->mpe->user_friendly_names != USER_FRIENDLY_NAMES_UNDEF) -A A A A A A A A return (mp->mpe->user_friendly_names == USER_FRIENDLY_NAMES_ON); -A A A A if (mp->hwe && -A A A A A A mp->hwe->user_friendly_names != USER_FRIENDLY_NAMES_UNDEF) -A A A A A A A A return (mp->hwe->user_friendly_names ==Quoted 8 lines
USER_FRIENDLY_NAMES_ON); -A A A A return (conf->user_friendly_namesA == USER_FRIENDLY_NAMES_ON); + +A A A A char *origin; +A A A A int user_friendly_names; + +A A A A do_set(user_friendly_names, mp->mpe,
user_friendly_names,Quoted 5 lines
+A A A A A A A "(LUN setting)"); +A A A A do_set(user_friendly_names, conf->overrides, user_friendly_names, +A A A A A A A "(overrides setting)"); +A A A A do_set(user_friendly_names, mp->hwe,
user_friendly_names,Quoted 4 lines
+A A A A A A A "(controller setting)"); +A A A A do_set(user_friendly_names, conf, user_friendly_names, +A A A A A A A "(config file setting)"); +A A A A do_default(user_friendly_names,
USER_FRIENDLY_NAMES_OFF);Quoted 3 lines
+out: +A A A A condlog(3, "%s: user_friendly_names = %s %s", mp->wwid, +A A A A A A A A (user_friendly_names ==
USER_FRIENDLY_NAMES_ON)?Quoted 18 lines
"yes" : "no", +A A A A A A A A origin); +A A A A return (user_friendly_names == USER_FRIENDLY_NAMES_ON); A } A extern int A select_alias (struct multipath * mp) A { -A A A A char *origin; +A A A A char *origin = NULL; A A A A if (mp->mpe && mp->mpe->alias) { A A A A A A A A mp->alias = STRDUP(mp->mpe->alias); @@ -261,6 +282,7 @@ select_features (struct multipath * mp) A A A A char *origin; A A A A mp_set_mpe(features); +A A A A mp_set_ovr(features);Quoted 8 lines
A A A A mp_set_hwe(features); A A A A mp_set_conf(features); A A A A mp_set_default(features, DEFAULT_FEATURES); @@ -287,8 +309,9 @@ select_hwhandler (struct multipath * mp) A A A A mp_set_hwe(hwhandler); A A A A mp_set_conf(hwhandler); -A A A A mp_set_default(hwhandler,
set_default(DEFAULT_HWHANDLER));Quoted 4 lines
+A A A A mp_set_default(hwhandler, DEFAULT_HWHANDLER); A out: +A A A A mp->hwhandler = STRDUP(mp->hwhandler); A A A A condlog(3, "%s: hardware_handler = \"%s\" %s",
mp->alias,Quoted 40 lines
mp->hwhandler, A A A A A A A A origin); A A A A return 0; @@ -300,6 +323,7 @@ select_checker(struct path *pp) A A A A char *origin, *checker_name; A A A A struct checker * c = &pp->checker; +A A A A do_set(checker_name, conf->overrides, checker_name, "(overrides setting)"); A A A A do_set(checker_name, pp->hwe, checker_name, "(controller setting)"); A A A A do_set(checker_name, conf, checker_name, "(config file setting)"); A A A A do_default(checker_name, DEFAULT_CHECKER); @@ -327,6 +351,8 @@ select_getuid (struct path * pp) A { A A A A char *origin; +A A A A pp_set_ovr(uid_attribute); +A A A A pp_set_ovr(getuid); A A A A pp_set_hwe(uid_attribute); A A A A pp_set_hwe(getuid); A A A A pp_set_conf(uid_attribute); @@ -383,6 +409,7 @@ select_prio (struct path * pp) A A A A } A A A A mpe = find_mpe(pp->wwid); A A A A set_prio(mpe, "(LUN setting)"); +A A A A set_prio(conf->overrides, "(overrides setting)"); A A A A set_prio(pp->hwe, "controller setting)"); A A A A set_prio(conf, "(config file default)"); A A A A prio_get(p, DEFAULT_PRIO, DEFAULT_PRIO_ARGS); @@ -405,6 +432,7 @@ select_no_path_retry(struct multipath *mp) A A A A A A A A return 0; A A A A } A A A A mp_set_mpe(no_path_retry); +A A A A mp_set_ovr(no_path_retry); A A A A mp_set_hwe(no_path_retry); A A A A mp_set_conf(no_path_retry); A out: @@ -427,6 +455,7 @@ select_minio_rq (struct multipath * mp)Quoted 8 lines
A A A A char *origin; A A A A do_set(minio_rq, mp->mpe, mp->minio, "(LUN setting)"); +A A A A do_set(minio_rq, conf->overrides, mp->minio, "(overrides setting)"); A A A A do_set(minio_rq, mp->hwe, mp->minio, "(controller setting)"); A A A A do_set(minio_rq, conf, mp->minio, "(config filesetting)");
Quoted 27 lines
A A A A do_default(mp->minio, DEFAULT_MINIO_RQ); @@ -441,6 +470,7 @@ select_minio_bio (struct multipath * mp) A A A A char *origin; A A A A mp_set_mpe(minio); +A A A A mp_set_ovr(minio); A A A A mp_set_hwe(minio); A A A A mp_set_conf(minio); A A A A mp_set_default(minio, DEFAULT_MINIO); @@ -465,6 +495,7 @@ select_fast_io_fail(struct multipath *mp) A { A A A A char *origin, buff[12]; +A A A A mp_set_ovr(fast_io_fail); A A A A mp_set_hwe(fast_io_fail); A A A A mp_set_conf(fast_io_fail); A A A A mp_set_default(fast_io_fail, DEFAULT_FAST_IO_FAIL); @@ -479,6 +510,7 @@ select_dev_loss(struct multipath *mp) A { A A A A char *origin, buff[12]; +A A A A mp_set_ovr(dev_loss); A A A A mp_set_hwe(dev_loss); A A A A mp_set_conf(dev_loss); A A A A mp->dev_loss = 0; @@ -497,6 +529,7 @@ select_flush_on_last_del(struct multipath *mp) A A A A if (mp->flush_on_last_del == FLUSH_IN_PROGRESS)Quoted 8 lines
A A A A A A A A return 0; A A A A mp_set_mpe(flush_on_last_del); +A A A A mp_set_ovr(flush_on_last_del); A A A A mp_set_hwe(flush_on_last_del); A A A A mp_set_conf(flush_on_last_del); A A A A mp_set_default(flush_on_last_del, FLUSH_DISABLED); @@ -532,6 +565,7 @@ select_retain_hwhandler (struct multipath * mp) A A A A A A A A origin = "(requires kernel version >=1.5.0)";
Quoted 6 lines
A A A A A A A A goto out; A A A A } +A A A A mp_set_ovr(retain_hwhandler); A A A A mp_set_hwe(retain_hwhandler); A A A A mp_set_conf(retain_hwhandler); A A A A mp_set_default(retain_hwhandler,
DEFAULT_RETAIN_HWHANDLER);Quoted 5 lines
@@ -547,6 +581,7 @@ select_detect_prio (struct path * pp) A { A A A A char *origin; +A A A A pp_set_ovr(detect_prio);Quoted 8 lines
A A A A pp_set_hwe(detect_prio); A A A A pp_set_conf(detect_prio); A A A A pp_set_default(detect_prio, DEFAULT_DETECT_PRIO); diff --git a/libmultipath/structs.c b/libmultipath/structs.c index 30d247d..0538327 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -206,10 +206,7 @@ free_multipath_attributes (struct multipath *mpp)
Quoted 14 lines
A A A A if (!mpp) A A A A A A A A return;-A A A A if (mpp->selector && -A A A A A A mpp->selector != conf->selector && -A A A A A A (!mpp->mpe || (mpp->mpe && mpp->selector != mpp->mpe->selector)) && -A A A A A A (!mpp->hwe || (mpp->hwe && mpp->selector != mpp->hwe->selector))) { +A A A A if (mpp->selector) { A A A A A A A A FREE(mpp->selector); A A A A A A A A mpp->selector = NULL; A A A A } @@ -219,9 +216,7 @@ free_multipath_attributes (struct multipath *mpp)
Quoted 12 lines
A A A A A A A A mpp->features = NULL; A A A A }-A A A A if (mpp->hwhandler && -A A A A A A mpp->hwhandler != conf->hwhandler && -A A A A A A (!mpp->hwe || (mpp->hwe && mpp->hwhandler != mpp->hwe->hwhandler))) { +A A A A if (mpp->hwhandler) { A A A A A A A A FREE(mpp->hwhandler); A A A A A A A A mpp->hwhandler = NULL; A A A A } diff --git a/multipath.conf.annotated b/multipath.conf.annotatedQuoted 8 lines
index 0af1d4c..71afc0a 100644 --- a/multipath.conf.annotated +++ b/multipath.conf.annotated @@ -485,7 +485,8 @@ A ## scope : multipath & multipathd A ## descA : list of per storage controller settings A ##A A A A overrides default settings (device_maps block) -##A A A A A overriden by per multipath settings (multipathsblock)
Quoted 1 line
+##A A A A overriden by per multipath settings (multipaths
block)
Quoted 5 lines
+##A A A A and the overrides settings (overrides block) A ## A #devices { A #A A A # @@ -651,3 +652,18 @@Quoted 8 lines
A #A A A A A A A rr_weightA A A A A A A A priorities A #A A A } A #} +# +## +## nameA : devices +## scope : multipath & multipathd +## descA : list of settings to override all hadware settings forall
Quoted 4 lines
devices
+##A A A A overrides default settings (device_mapsblock) +##A A A A and per device type settings (devices block) +##A A A A overriden by per multipath settings (multipathsblock)
Quoted 26 lines
+## +#A A A attributes and values are identical to the device block +# +#overrides { +#A A A dev_loss_tmoA A A A A A 60 +#A A A no_path_retryA A A A A A fail +#} diff --git a/multipath.conf.defaults b/multipath.conf.defaults index 654be97..1c65e02 100644 --- a/multipath.conf.defaults +++ b/multipath.conf.defaults @@ -912,3 +912,5 @@ A #} A #multipaths { A #} +#overrides { +#} diff --git a/multipath.conf.synthetic b/multipath.conf.synthetic index bda1b75..f7b9b8a 100644 --- a/multipath.conf.synthetic +++ b/multipath.conf.synthetic @@ -72,3 +72,6 @@ A #A A A A A A A path_grouping_policyA A multibus A #A A A } A #} +#overrides {Quoted 8 lines
+#A A A no_path_retryA A A A A A A A A A fail +#} diff --git a/multipath/main.c b/multipath/main.c index fd6262f..ea453b4 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -405,6 +405,12 @@ dump_config (void) A A A A A A A A A A A A reply = REALLOC(reply, maxlen*= 2);
Quoted 3 lines
A A A A A A A A A A A A continue; A A A A A A A A } +A A A A A A A A c += snprint_overrides(c, reply + maxlen -c,
Quoted 4 lines
conf->overrides); +A A A A A A A A again = ((c - reply) == maxlen); +A A A A A A A A if (again) { +A A A A A A A A A A A A reply = REALLOC(reply, maxlen*= 2);
Quoted 19 lines
+A A A A A A A A A A A A continue; +A A A A A A A A }A A A A A A A A c +=
snprint_mptable(c, reply + maxlen - c, conf->mptable);
A A A A A A A A again = ((c - reply) == maxlen); A A A A A A A A if (again)
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index cadb34d..b823990 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -61,6 +61,10 @@ the udev attribute given by the
A .TP
A .B devices
A This section defines the device-specific settings. +.TP
+.B overrides
+This section defines values for attributes that should override the +device-specific settings for all devices.
A .REQuoted 8 lines
A .LP
A .SH "defaults section"
@@ -629,6 +633,59 @@ section:
A .RE
A .PD
A .LP
+.SH "overrides section"
+The overrides section recognizes the following optionalattributes; if
Quoted 56 lines
not set +the values are taken from the +.I devices +or +.I defaults +sections: +.sp 1 +.PD .1v +.RS +.TP 18 +.B path_grouping_policy +.TP +.B uid_attribute +.TP +.B getuid_callout +.TP +.B path_selector +.TP +.B path_checker +.TP +.B alias_prefix +.TP +.B features +.TP +.B prio +.TP +.B prio_args +.TP +.B failback +.TP +.B rr_weight +.TP +.B no_path_retry +.TP +.B rr_min_io +.TP +.B rr_min_io_rq +.TP +.B flush_on_last_del +.TP +.B fast_io_fail_tmo +.TP +.B dev_loss_tmo +.TP +.B user_friendly_names +.TP +.B retain_attached_hw_handler +.TP +.B detect_prio +.RE +.PD +.LP A .SH "KNOWN ISSUES" A The usage of A .B queue_if_no_path diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.cQuoted 8 lines
index b086340..0ce1408 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -190,6 +190,16 @@ show_config (char ** r, int * len) A A A A A A A A A A A A maxlen *= 2; A A A A A A A A A A A A continue; A A A A A A A A } +A A A A A A A A c += snprint_overrides(c, reply + maxlen -c,
Quoted 4 lines
conf->overrides); +A A A A A A A A again = ((c - reply) == maxlen); +A A A A A A A A if (again) { +A A A A A A A A A A A A reply = REALLOC(reply, maxlen *2);
Quoted 3 lines
+A A A A A A A A A A A A if (!reply) +A A A A A A A A A A A A A A A A return 1; +A A A A A A A A A A A A memset(reply + maxlen, 0,maxlen);
Quoted 9 lines
+A A A A A A A A A A A A maxlen *= 2; +A A A A A A A A A A A A continue; +A A A A A A A A } A A A A A A A A c += snprint_mptable(c, reply + maxlen - c, conf->mptable); A A A A A A A A again = ((c - reply) == maxlen); A A A A A A A A REALLOC_REPLY(reply, again, maxlen); -- 1.8.3.1
Benjamin Marzinski
maintainerPATCH 4/6 add find_multipaths option
In reply to Benjamin MarzinskiThis patch adds a new option (find_multipaths) to the defaults section of multipath.conf. This is used to keep multipath from simply creating multipath devices on top of any non-blacklisted device. When this is set to "yes", multipath will only create multipath devices when there are actually multiple paths to the storage. This means that in most setups where find_multipaths is set, users don't need to bother with the editting the blacklist, because multipath will do the work for them. The only case where blacklisting is still necessary is if user want to disable multipathing on LUNs that actually have multiple paths.
One of the issues with only grabbing devices with multiple paths is that multipath can't know when it first sees a path device whether a second path device will appear. This could be a problem, because if multipath doesn't claim the device, something else might. For instance, a filesystem could be automounted on a path device before the second path device appeared.
Multipath deals with this by using the /etc/multipaths/wwids file. If the device wwid is listed in this file, multipath knows that it is a path device, and can create a multipath device on it as soon as it appears. This means that after multipath has created a multipath device once, it will automatically create it in the future as soon as the first path is discovered.
In general, there are three conditions for find_multipaths to allow the creation of a device. After passing all the checks that multipath currently does to allow device creation, one of these three conditions must also be true for device creation, if find_multipaths is enabled.
1. There are at least two non-blacklisted paths with the same wwid
2. The creation was manually forced, by specifying the device with the multipath command
3. The path's wwid is in the wwids file, which means that multipath has previously created a multipath device with that wwid.
--- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/configure.c | 11 +++++++++++ libmultipath/defaults.h | 1 + libmultipath/dict.c | 4 ++++ libmultipath/wwids.c | 26 ++++++++++++++++++++++++++ libmultipath/wwids.h | 1 + multipath/main.c | 27 +++++++++++++++++++++++++-- multipathd/main.c | 6 ++++++ 9 files changed, 76 insertions(+), 2 deletions(-)
libmultipath/config.c +1 -0
@@ -563,6 +563,7 @@ load_config (char * file, struct udev *udev) conf->retain_hwhandler =DEFAULT_RETAIN_HWHANDLER ; conf->detect_prio =DEFAULT_DETECT_PRIO ; conf->force_sync =0 ; + conf->find_multipaths =DEFAULT_FIND_MULTIPATHS ;/* * preload default hwtable
libmultipath/config.h +1 -0
@@ -116,6 +116,7 @@ struct config {unsigned int dev_loss;int log_checker_err;int allow_queueing; +int find_multipaths;uid_t uid;gid_t gid;mode_t mode;
libmultipath/configure.c +11 -0
@@ -740,6 +740,10 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rmemset (empty_buff,0 ,WWID_SIZE ); +/* ignore refwwid if it's empty */ +if (refwwid && !strlen (refwwid)) + refwwid =NULL ; +if (force_reload) { vector_foreach_slot (pathvec, pp1, k) { pp1->mpp =NULL ;
@@ -769,6 +773,13 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_rif (refwwid &&strncmp (pp1->wwid, refwwid,WWID_SIZE ))continue ; +/* If find_multipaths was selected check if the path is valid */ +if (conf->find_multipaths && !refwwid && + !should_multipath (pp1, pathvec)) { +orphan_path (pp1,"only one path" ); +continue ; + } +/* * at this point, we know we really got a new mp */
libmultipath/defaults.h +1 -0
@@ -13,6 +13,7 @@#define DEFAULT_NO_PATH_RETRY NO_PATH_RETRY_UNDEF#define DEFAULT_VERBOSITY 2#define DEFAULT_REASSIGN_MAPS 1 +#define DEFAULT_FIND_MULTIPATHS 0#define DEFAULT_FAST_IO_FAIL 5#define DEFAULT_RETAIN_HWHANDLER RETAIN_HWHANDLER_OFF#define DEFAULT_DETECT_PRIO DETECT_PRIO_OFF
libmultipath/dict.c +4 -0
@@ -230,6 +230,9 @@ declare_def_snprint(reassign_maps, print_yes_no) declare_def_handler(multipath_dir, set_str) declare_def_snprint(multipath_dir, print_str) +declare_def_handler(find_multipaths, set_yes_no) +declare_def_snprint(find_multipaths, print_yes_no) + declare_def_handler(selector, set_str) declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)declare_hw_handler (selector, set_str)
@@ -1242,6 +1245,7 @@ init_keywords(void)install_keyword ("retain_attached_hw_handler" , &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler);install_keyword ("detect_prio" , &def_detect_prio_handler, &snprint_def_detect_prio);install_keyword ("force_sync" , &def_force_sync_handler, &snprint_def_force_sync); +install_keyword ("find_multipaths" , &def_find_multipaths_handler, &snprint_def_find_multipaths);__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 );
libmultipath/wwids.c +26 -0
@@ -261,6 +261,32 @@ out: }int +should_multipath (struct path *pp1,vector pathvec) +{ +int i; +struct path *pp2; + +condlog (4 ,"checking if %s should be multipathed" , pp1->dev); + vector_foreach_slot(pathvec, pp2, i) { +if (pp1->dev == pp2->dev) +continue ; +if (strncmp (pp1->wwid, pp2->wwid,WWID_SIZE ) ==0 ) { +condlog (3 ,"found multiple paths with wwid %s, " +"multipathing %s" , pp1->wwid, pp1->dev); +return 1 ; + } + } +if (check_wwids_file (pp1->wwid,0 ) <0 ) { +condlog (3 ,"wwid %s not in wwids file, skipping %s" , + pp1->wwid, pp1->dev); +return 0 ; + } +condlog (3 ,"found wwid %s in wwids file, multipathing %s" , pp1->wwid, + pp1->dev); +return 1 ; +} + +int remember_wwid (char *wwid) {int ret =check_wwids_file (wwid,1 );
libmultipath/wwids.h +1 -0
@@ -12,6 +12,7 @@"#\n" \"# Valid WWIDs:\n" +int should_multipath(struct path *pp, vector pathvec);int remember_wwid (char *wwid);int check_wwids_file (char *wwid,int write_wwid);int remove_wwid (char *wwid);
multipath/main.c +25 -2
@@ -197,6 +197,9 @@ get_dm_mpvec (vector curmp, vector pathvec, char * refwwid)continue ; } +if (conf->cmd ==CMD_VALID_PATH ) +continue ; +dm_get_map (mpp->alias, &mpp->size, params);condlog (3 ,"params = %s" , params);dm_get_status (mpp->alias, status);
@@ -307,7 +310,13 @@ configure (void) goto out; }condlog (3 ,"scope limited to %s" , refwwid); -if (conf->cmd ==CMD_VALID_PATH ) { +/* If you are ignoring the wwids file and find_multipaths is +* set, you need to actually check if there are two available +* paths to determine if this path should be multipathed. To +* do this, we put off the check until after discovering all +* the paths */ +if (conf->cmd ==CMD_VALID_PATH && + (!conf->find_multipaths || !conf->ignore_wwids)) {if (conf->ignore_wwids ||check_wwids_file (refwwid,0 ) ==0 ) r =0 ;
@@ -347,6 +356,20 @@ configure (void)filter_pathvec (pathvec, refwwid); + +if (conf->cmd ==CMD_VALID_PATH ) { +/* This only happens if find_multipaths is and +* ignore_wwids is set. +* If there is currently a multipath device matching +* the refwwid, or there is more than one path matching +* the refwwid, then the path is valid */ +if (VECTOR_SIZE (curmp) !=0 ||VECTOR_SIZE (pathvec) >1 ) + r =0 ; +printf ("%s %s a valid multipath device path\n" , + conf->dev, r ==0 ?"is" :"is not" ); + goto out; + } +if (conf->cmd !=CMD_CREATE && conf->cmd !=CMD_DRY_RUN ) { r =0 ; goto out;
@@ -355,7 +378,7 @@ configure (void)/* * core logic entry point */ - r =coalesce_paths (&vecs,NULL ,NULL , conf->force_reload); + r =coalesce_paths (&vecs,NULL , refwwid, conf->force_reload); out:if (refwwid)
multipathd/main.c +6 -0
@@ -54,6 +54,7 @@#include <print.h> #include <configure.h> #include <prio.h> +#include <wwids.h> #include <pgpolicies.h> #include <uevent.h> #include <log.h>
@@ -496,6 +497,11 @@ rescan:return 1 ; } +if (conf->find_multipaths && + !should_multipath (pp, vecs->pathvec)) { +orphan_path (pp,"only one path" ); +return 0 ; + }condlog (4 ,"%s: creating new map" , pp->dev);if ((mpp =add_map_with_path (vecs, pp,1 ))) { mpp->action =ACT_CREATE ;
Signature · 1 line
1.8.3.1
Benjamin Marzinski
maintainerPATCH 5/6 correctly set partition delimiter on rename
In reply to Benjamin MarzinskiWhen multipath renames a device and the name switches from ending in a number to ending in a letter or vice versa, it currently just keeps any existing delimiter between the device name and partition number. However the default behaviour in kpartx is to only use the 'p' delimiter when the name ends in a number. Unfortunately, without adding a kpartx.conf that kpartx uses to set the delimiter behavior, there's no way for multipath to know how kpartx was run for certain device names (ones ending in a number with a 'p' delimiter).
The patch adds a new multipath.conf defaults parameter, "partition_delimiter". If this value is not set, when multipath renames a device, it will act just like the kpartx default does, only adding a 'p' to names ending in a number. If this parameter is set, multipath will act like kpartx does with the -p option is used, and always add delimiter.
--- libmultipath/config.c | 3 +++ libmultipath/config.h | 1 + libmultipath/devmapper.c | 14 ++++++++++++-- libmultipath/dict.c | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-)
libmultipath/config.c +3 -0
@@ -502,6 +502,8 @@ free_config (struct config * conf)if (conf->alias_prefix)FREE (conf->alias_prefix); +if (conf->partition_delim) +FREE (conf->partition_delim);if (conf->prio_args)FREE (conf->prio_args);
@@ -564,6 +566,7 @@ load_config (char * file, struct udev *udev) conf->detect_prio =DEFAULT_DETECT_PRIO ; conf->force_sync =0 ; conf->find_multipaths =DEFAULT_FIND_MULTIPATHS ; + conf->partition_delim =NULL ;/* * preload default hwtable
libmultipath/config.h +1 -0
@@ -141,6 +141,7 @@ struct config {char * prio_args;char * checker_name;char * alias_prefix; +char * partition_delim;unsigned char * reservation_key;vector keywords;
libmultipath/devmapper.c +12 -2
@@ -1142,6 +1142,8 @@ dm_rename_partmaps (char * old, char * new)unsigned long long size;char dev_t[32 ];int r =1 ; +int offset; +char *delim;if (!(dmt =dm_task_create (DM_DEVICE_LIST )))return 1 ;
@@ -1162,6 +1164,13 @@ dm_rename_partmaps (char * old, char * new)if (dm_dev_t (old, &dev_t[0 ],32 )) goto out; +if (conf->partition_delim) + delim = conf->partition_delim; +if (isdigit (new[strlen (new)-1 ])) + delim ="p" ; +else + delim ="" ; + do { if ( /*
@@ -1189,8 +1198,9 @@ dm_rename_partmaps (char * old, char * new)* then it's a kpartx generated partition. * Rename it. */ -snprintf (buff,PARAMS_SIZE ,"%s%s" , - new, names->name +strlen (old)); +for (offset =strlen (old); names->name[offset] && !(isdigit (names->name[offset])); offset++);/* do nothing */ +snprintf (buff,PARAMS_SIZE ,"%s%s%s" , + new, delim, names->name + offset);dm_rename (names->name, buff);condlog (4 ,"partition map %s renamed" , names->name);
libmultipath/dict.c +4 -0
@@ -233,6 +233,9 @@ declare_def_snprint(multipath_dir, print_str) declare_def_handler(find_multipaths, set_yes_no) declare_def_snprint(find_multipaths, print_yes_no) +declare_def_handler(partition_delim, set_str) +declare_def_snprint(partition_delim, print_str) + declare_def_handler(selector, set_str) declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)declare_hw_handler (selector, set_str)
@@ -1246,6 +1249,7 @@ init_keywords(void)install_keyword ("detect_prio" , &def_detect_prio_handler, &snprint_def_detect_prio);install_keyword ("force_sync" , &def_force_sync_handler, &snprint_def_force_sync);install_keyword ("find_multipaths" , &def_find_multipaths_handler, &snprint_def_find_multipaths); +install_keyword ("partition_delimiter" , &def_partition_delim_handler, &snprint_def_partition_delim);__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 );
Signature · 1 line
1.8.3.1
Re: [PATCH 5/6] correctly set partition delimiter on rename
Ben,
I'm willing to apply this one.
Care to rebase it.
Best regards,
Christophe
Quoted 131 lines · Benjamin Marzinski
When multipath renames a device and the name switches from ending in a number to ending in a letter or vice versa, it currently just keeps any existing delimiter between the device name and partition number. However the default behaviour in kpartx is to only use the 'p' delimiter when the name ends in a number. Unfortunately, without adding a kpartx.conf that kpartx uses to set the delimiter behavior, there's no way for multipath to know how kpartx was run for certain device names (ones ending in a number with a 'p' delimiter).
The patch adds a new multipath.conf defaults parameter, "
partition_delimiter". If this value is not set, when multipath renames a device, it will act just like the kpartx default does, only adding a 'p' to names ending in a number. If this parameter is set, multipath will act like kpartx does with the -p option is used, and always add delimiter.Signed-off-by Benjamin Marzinski <[email protected]>--- libmultipath/config.c | 3 +++ libmultipath/config.h | 1 + libmultipath/devmapper.c | 14 ++++++++++++-- libmultipath/dict.c | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-)libmultipath/config.c +3
-0@@ -502,6 +502,8 @@ free_config (struct config * conf)if (conf->alias_prefix)FREE (conf->alias_prefix); +if (conf->partition_delim) +FREE (conf->partition_delim);if (conf->prio_args)FREE (conf->prio_args);@@ -564,6 +566,7 @@ load_config (char * file, struct udev *udev) conf->detect_prio =DEFAULT_DETECT_PRIO ; conf->force_sync =0 ; conf->find_multipaths =DEFAULT_FIND_MULTIPATHS ; + conf->partition_delim =NULL ;/* * preload default hwtable libmultipath/config.h +1
-0@@ -141,6 +141,7 @@ struct config {char * prio_args;char * checker_name;char * alias_prefix; +char * partition_delim;unsigned char * reservation_key;vector keywords;libmultipath/devmapper.c +10
-2@@ -1142,6 +1142,8 @@ dm_rename_partmaps (char * old, char * new)unsigned long long size;char dev_t[32 ];int r =1 ; +int offset; +char *delim;if (!(dmt =dm_task_create (DM_DEVICE_LIST )))return 1 ;@@ -1162,6 +1164,13 @@ dm_rename_partmaps (char * old, char * new)if (dm_dev_t (old, &dev_t[0 ],32 )) goto out; +if (conf->partition_delim) + delim = conf->partition_delim; +if (isdigit (new[strlen (new)-1 ])) + delim ="p" ; +else + delim ="" ; + do { if ( /*@@ -1189,8 +1198,9 @@ dm_rename_partmaps (char * old, char * new)* then it's a kpartx generated partition. * Rename it. */ -snprintf (buff,PARAMS_SIZE ,"%s%s" , - new, names->name +strlen (old)); + for (offset = strlen(old);names->name[offset] && !(isdigit(names->name[offset])); offset++); /* do nothing */
libmultipath/devmapper.c +2
-0+snprintf (buff,PARAMS_SIZE ,"%s%s%s" , + new, delim, names->name + offset);dm_rename (names->name, buff);condlog (4 ,"partition map %s renamed" , names->name);libmultipath/dict.c +4
-0@@ -233,6 +233,9 @@ declare_def_snprint(multipath_dir, print_str) declare_def_handler(find_multipaths, set_yes_no) declare_def_snprint(find_multipaths, print_yes_no) +declare_def_handler(partition_delim, set_str) +declare_def_snprint(partition_delim, print_str) + declare_def_handler(selector, set_str) declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)declare_hw_handler (selector, set_str)@@ -1246,6 +1249,7 @@ init_keywords(void)install_keyword ("detect_prio" , &def_detect_prio_handler, &snprint_def_detect_prio);install_keyword ("force_sync" , &def_force_sync_handler, &snprint_def_force_sync);install_keyword ("find_multipaths" , &def_find_multipaths_handler, &snprint_def_find_multipaths); + install_keyword("partition_delimiter",
&def_partition_delim_handler,&snprint_def_partition_delim);
__deprecatedinstall_keyword("default_selector",&def_selector_handler, NULL);
__deprecatedinstall_keyword("default_path_grouping_policy",&def_pgpolicy_handler, NULL);
__deprecatedinstall_keyword("default_uid_attribute",&def_uid_attribute_handler, NULL);
--
1.8.3.1
Benjamin Marzinski
maintainerPATCH 6/6 libmultipath: only add uninitialized paths in check_path
In reply to Benjamin MarzinskiWith find_multipaths enabled, there can be non-blacklisted paths that are not supposed to be part of any multipath device. To make sure that check_path doesn't keep checking them, this patch marks paths which are fully initialized. Only uninitialized paths are checked, if they don't belong to a multipath device.
--- libmultipath/discovery.c | 2 ++ libmultipath/structs.h | 1 + multipathd/main.c | 3 +++ 3 files changed, 6 insertions(+)
libmultipath/discovery.c +2 -0
@@ -1250,6 +1250,7 @@ pathinfo (struct path *pp, vector hwtable, int mask) } } + pp->initialized =1 ;return 0 ; blank:
@@ -1258,6 +1259,7 @@ blank:*/ memset (pp->wwid,0 ,WWID_SIZE ); pp->chkrstate = pp->state =PATH_DOWN ; + pp->initialized =0 ;return 0 ; }
libmultipath/structs.h +1 -0
@@ -186,6 +186,7 @@ struct path {struct checker checker;struct multipath * mpp;int fd; +int initialized;/* configlet pointers */ struct hwentry * hwe;
multipathd/main.c +3 -0
@@ -1124,6 +1124,9 @@ check_path (struct vectors * vecs, struct path * pp)int chkr_new_path_up =0 ;int oldchkrstate = pp->chkrstate; +if (pp->initialized && !pp->mpp) +return 0 ; +if (pp->tick && --pp->tick)return 0 ;/* don't check this path yet */
Signature · 1 line
1.8.3.1