diff options
author | Hannes Reinecke <hare@suse.de> | 2011-05-04 11:56:40 +0200 |
---|---|---|
committer | Hannes Reinecke <hare@suse.de> | 2011-05-05 09:09:12 +0200 |
commit | 4197ffbad3014fa3c836a2b0afd3df807add0e35 (patch) | |
tree | a826031aca006a725dbca299da599f93f960dd0a | |
parent | c70575799b2878d11235ce09a36a5221be23f69e (diff) | |
download | multipath-tools-4197ffbad3014fa3c836a2b0afd3df807add0e35.tar.gz |
Specify prioritizer in the multipath section, too
We should allow to set the prioritizer in the multipath section,
too, as some arrays might be configured to run in different
modes.
Signed-off-by: Hannes Reinecke <hare@suse.de>
-rw-r--r-- | libmultipath/config.c | 6 | ||||
-rw-r--r-- | libmultipath/config.h | 2 | ||||
-rw-r--r-- | libmultipath/dict.c | 59 | ||||
-rw-r--r-- | libmultipath/discovery.c | 5 | ||||
-rw-r--r-- | libmultipath/propsel.c | 14 |
5 files changed, 82 insertions, 4 deletions
diff --git a/libmultipath/config.c b/libmultipath/config.c index f8ba4aa..e74a130 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -201,6 +201,12 @@ free_mpe (struct mpentry * mpe) if (mpe->alias) FREE(mpe->alias); + if (mpe->prio_name) + FREE(mpe->prio_name); + + if (mpe->prio_args) + FREE(mpe->prio_args); + FREE(mpe); } diff --git a/libmultipath/config.h b/libmultipath/config.h index af8adb9..8e08129 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -47,6 +47,8 @@ struct mpentry { char * selector; char * features; + char * prio_name; + char * prio_args; int pgpolicy; int pgfailback; int rr_weight; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 07aa9d0..fb3032a 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -1477,6 +1477,37 @@ mp_flush_on_last_del_handler(vector strvec) return 0; } +static int +mp_prio_handler(vector strvec) +{ + struct mpentry * mpe = VECTOR_LAST_SLOT(conf->hwtable); + + if (!mpe) + return 1; + + mpe->prio_name = set_value(strvec); + + if (!mpe->prio_name) + return 1; + + return 0; +} + +static int +mp_prio_args_handler (vector strvec) +{ + struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable); + + if (!mpe) + return 1; + + mpe->prio_args = set_value(strvec); + if (!mpe->prio_args) + return 1; + + return 0; +} + /* * config file keywords printing */ @@ -1678,6 +1709,28 @@ snprint_mp_flush_on_last_del (char * buff, int len, void * data) } static int +snprint_mp_prio(char * buff, int len, void * data) +{ + struct mpentry * mpe = (struct mpentry *)data; + + if (!mpe->prio_name) + return 0; + + return snprintf(buff, len, "%s", mpe->prio_name); +} + +static int +snprint_mp_prio_args(char * buff, int len, void * data) +{ + struct mpentry * mpe = (struct mpentry *)data; + + if (!mpe->prio_args) + return 0; + + return snprintf(buff, len, "%s", mpe->prio_args); +} + +static int snprint_hw_fast_io_fail(char * buff, int len, void * data) { struct hwentry * hwe = (struct hwentry *)data; @@ -1779,8 +1832,8 @@ snprint_hw_prio_args (char * buff, int len, void * data) { struct hwentry * hwe = (struct hwentry *)data; - if (!hwe->prio_args) - return 0; + if (!hwe->prio_args) + return 0; return snprintf(buff, len, "\"%s\"", hwe->prio_args); } @@ -2375,6 +2428,8 @@ init_keywords(void) install_keyword("alias", &alias_handler, &snprint_mp_alias); install_keyword("path_grouping_policy", &mp_pgpolicy_handler, &snprint_mp_path_grouping_policy); install_keyword("path_selector", &mp_selector_handler, &snprint_mp_selector); + install_keyword("prio", &mp_prio_handler, &snprint_mp_prio); + install_keyword("prio_args", &mp_prio_args_handler, &snprint_mp_prio_args); install_keyword("failback", &mp_failback_handler, &snprint_mp_failback); install_keyword("rr_weight", &mp_weight_handler, &snprint_mp_rr_weight); install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 0456b6d..843630b 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -906,8 +906,11 @@ pathinfo (struct path *pp, vector hwtable, int mask) * been successfully obtained before. */ if (mask & DI_PRIO && - (pp->state != PATH_DOWN || pp->priority == PRIO_UNDEF)) + (pp->state != PATH_DOWN || pp->priority == PRIO_UNDEF)) { + if (!strlen(pp->wwid)) + get_uid(pp); get_prio(pp); + } if (mask & DI_WWID && !strlen(pp->wwid)) get_uid(pp); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 83f1006..4efdf14 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -369,6 +369,18 @@ select_getuid (struct path * pp) extern int select_prio (struct path * pp) { + struct mpentry * mpe; + + if ((mpe = find_mpe(pp->wwid))) { + if (mpe->prio_name) { + pp->prio = prio_lookup(mpe->prio_name); + prio_set_args(pp->prio, mpe->prio_args); + condlog(3, "%s: prio = %s (LUN setting)", + pp->dev, pp->prio->name); + return 0; + } + } + if (pp->hwe && pp->hwe->prio_name) { pp->prio = prio_lookup(pp->hwe->prio_name); prio_set_args(pp->prio, pp->hwe->prio_args); @@ -388,7 +400,7 @@ select_prio (struct path * pp) return 0; } pp->prio = prio_lookup(DEFAULT_PRIO); - prio_set_args(pp->prio, DEFAULT_PRIO_ARGS); + prio_set_args(pp->prio, DEFAULT_PRIO_ARGS); condlog(3, "%s: prio = %s (internal default)", pp->dev, DEFAULT_PRIO); condlog(3, "%s: prio = %s (internal default)", |