Specify prioritizer in the multipath section, too
authorHannes Reinecke <hare@suse.de>
Wed, 4 May 2011 09:56:40 +0000 (11:56 +0200)
committerHannes Reinecke <hare@suse.de>
Thu, 5 May 2011 07:09:12 +0000 (09:09 +0200)
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>
libmultipath/config.c
libmultipath/config.h
libmultipath/dict.c
libmultipath/discovery.c
libmultipath/propsel.c

index f8ba4aa..e74a130 100644 (file)
@@ -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);
 }
 
index af8adb9..8e08129 100644 (file)
@@ -47,6 +47,8 @@ struct mpentry {
        char * selector;
        char * features;
 
+       char * prio_name;
+       char * prio_args;
        int pgpolicy;
        int pgfailback;
        int rr_weight;
index 07aa9d0..fb3032a 100644 (file)
@@ -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);
index 0456b6d..843630b 100644 (file)
@@ -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);
index 83f1006..4efdf14 100644 (file)
@@ -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)",