[patch] mpath_prio_pp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Title: [patch] mpath_prio_pp

Hi,

Below is the patch for the implementation of preferred path feature in the device mapper.
Preferred path feature allows the selection of a particular path for a LUN, by making proper priority assignments.
mpath_prio_pp is a callout routine for the same.Let me know your comments.

Thanks,
Veena



diff -pNaur multipath-tools-0.4.8/libmultipath/config.h multipath-tools-0.4.8.new/libmultipath/config.h
--- multipath-tools-0.4.8/libmultipath/config.h 2007-08-03 02:35:37.000000000 +0530
+++ multipath-tools-0.4.8.new/libmultipath/config.h     2007-11-30 12:40:33.000000000 +0530
@@ -37,6 +37,7 @@ struct mpentry {
        char * alias;
        char * getuid;
        char * selector;
+       char * getprio;
 
        int pgpolicy;
        int pgfailback;
diff -pNaur multipath-tools-0.4.8/libmultipath/dict.c multipath-tools-0.4.8.new/libmultipath/dict.c
--- multipath-tools-0.4.8/libmultipath/dict.c   2007-08-03 02:35:37.000000000 +0530
+++ multipath-tools-0.4.8.new/libmultipath/dict.c       2007-11-30 12:13:46.000000000 +0530
@@ -933,9 +933,31 @@ mp_pg_timeout_handler(vector strvec)
        return 0;
 }
 
+static int
+mp_prio_callout_handler(vector strvec)
+{
+         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
+
+         if(!mpe)
+                return 1;
+
+         mpe->getprio = set_value(strvec);
+
+         if(!mpe->getprio)
+                return 1;
+
+         if (strlen(mpe->getprio) == 4 && !strcmp(mpe->getprio, "none")) {
+                FREE(mpe->getprio);
+                mpe->getprio = NULL;
+         }
+
+         return 0;
+}
+
 /*
  * config file keywords printing
  */
+
 static int
 snprint_mp_wwid (char * buff, int len, void * data)
 {
@@ -1068,6 +1090,17 @@ snprint_mp_pg_timeout (char * buff, int
 }
 
 static int
+snprint_mp_prio_callout(char * buff, int len, void * data)
+{
+        struct mpentry * mpe = (struct mpentry *)data;
+
+        if (!mpe->getprio)
+                return 0;
+
+        return snprintf(buff, len, "%s", mpe->getprio);
+}
+
+static int
 snprint_hw_vendor (char * buff, int len, void * data)
 {
        struct hwentry * hwe = (struct hwentry *)data;
@@ -1594,6 +1627,7 @@ 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_callout", &mp_prio_callout_handler, &snprint_mp_prio_callout);
        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 -pNaur multipath-tools-0.4.8/libmultipath/discovery.c multipath-tools-0.4.8.new/libmultipath/discovery.c
--- multipath-tools-0.4.8/libmultipath/discovery.c      2007-08-03 02:35:37.000000000 +0530
+++ multipath-tools-0.4.8.new/libmultipath/discovery.c  2007-11-30 12:18:21.000000000 +0530
@@ -709,8 +709,11 @@ pathinfo (struct path *pp, vector hwtabl
          * 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 -pNaur multipath-tools-0.4.8/libmultipath/propsel.c multipath-tools-0.4.8.new/libmultipath/propsel.c
--- multipath-tools-0.4.8/libmultipath/propsel.c        2007-08-03 02:35:37.000000000 +0530
+++ multipath-tools-0.4.8.new/libmultipath/propsel.c    2007-11-30 12:45:21.000000000 +0530
@@ -258,7 +258,16 @@ select_getuid (struct path * pp)
 
 extern int
 select_getprio (struct path * pp)
-{
+{     
+       struct mpentry * mpe;
+        if (mpe = find_mpe(pp->wwid)) {
+                if (mpe->getprio) {
+                        pp->getprio = mpe->getprio;
+                        condlog(3, "%s: getprio = %s (LUN setting)", pp->dev, pp->getprio);
+                        return 0;
+                }
+        }
+
        if (pp->hwe && pp->hwe->getprio) {
                pp->getprio = pp->hwe->getprio;
                condlog(3, "%s: getprio = %s (controller setting)",
diff -pNaur multipath-tools-0.4.8/path_priority/pp_pref_path/Makefile multipath-tools-0.4.8.new/path_priority/pp_pref_path/Makefile

--- multipath-tools-0.4.8/path_priority/pp_pref_path/Makefile   1970-01-01 05:30:00.000000000 +0530
+++ multipath-tools-0.4.8.new/path_priority/pp_pref_path/Makefile       2007-11-30 11:47:21.000000000 +0530
@@ -0,0 +1,25 @@
+EXEC           = mpath_prio_pp
+BUILD          = glibc
+OBJS           = mpath_prio_pp.o
+
+TOPDIR         = ../..
+include $(TOPDIR)/Makefile.inc
+
+all: $(BUILD)
+
+glibc: $(OBJS)
+       $(CC) -o $(EXEC) $(OBJS) $(LDFLAGS)
+
+klibc: $(OBJS)
+       $(CC) -static -o $(EXEC) $(OBJS)
+
+install: $(EXEC)
+       install -m 755 $(EXEC) $(DESTDIR)$(bindir)/$(EXEC)
+
+uninstall:
+       rm $(DESTDIR)$(bindir)/$(EXEC)
+clean:
+       rm -f *.o $(EXEC)
+
+%.o:   %.c
+       $(CC) $(CFLAGS) -c -o $@ $<
diff -pNaur multipath-tools-0.4.8/path_priority/pp_pref_path/mpath_prio_pp.c multipath-tools-0.4.8.new/path_priority/pp_pref_path/mpath_prio_pp.c

--- multipath-tools-0.4.8/path_priority/pp_pref_path/mpath_prio_pp.c    1970-01-01 05:30:00.000000000 +0530
+++ multipath-tools-0.4.8.new/path_priority/pp_pref_path/mpath_prio_pp.c        2007-12-04 16:54:21.000000000 +0530
@@ -0,0 +1,67 @@
+ /*
+ *****************************************************************************
+ *                                                                           *
+ *     (C)  Copyright 2007 Hewlett-Packard Development Company, L.P          *
+ *                                                                           *
+ * This program is free software; you can redistribute it and/or modify it   *
+ * under the terms of the GNU General Public License as published by the Free*
+ * Software  Foundation; either version 2 of the License, or (at your option)*
+ * any later version.                                                        *
+ *                                                                           *
+ * This program is distributed in the hope that it will be useful, but       *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY*
+ * or FITNESS FOR  A PARTICULAR PURPOSE. See the GNU General Public License  *
+ * for more details.                                                         *
+ *                                                                           *
+ * You should have received a copy of the GNU General Public License along   *
+ * with this program; if not, write to the Free Software Foundation, Inc.,   *
+ * 675 Mass Ave, Cambridge, MA 02139, USA.                                   *
+ *                                                                           *
+ * The copy of the GNU General Public License is available at                *
+ * /opt/hp/HPDMmultipath-tool directoy                                       *
+ *                                                                           *
+ *****************************************************************************
+ */
+
+/*
+ * Prioritizer for device mapper,when a path instance is provided as the
+ * preferred path.
+
+ * This prioritizer assigns a priority value based on the comparison made
+ * between the preferred path and the path instance for which this is called.
+ * A priority value of 1 is assigned to the preferred path and 0 to the other
+ * non-preferred paths.
+
+ * Returns zero on successful assignment of priority and -1 on failure.
+ * Failure to assign priority can be caused due to invalid pathname or a missing * argument.
+ */
+
+#include<stdio.h>
+#include<string.h>
+#define HIGH 1
+#define LOW 0
+#define FILE_NAME_SIZE 256
+
+int main(int argc, char * argv[])
+{
+
+       char path[FILE_NAME_SIZE];
+      
+       if(argv[1] && argv[2])
+       {
+               if(!strncmp(argv[2],"/dev/",5))
+                       strcpy(path,argv[2]+5);
+
+               if(!strcmp(path,argv[1]) || !strcmp(argv[1],argv[2]))
+               {
+                       printf("%u\n", HIGH);
+                       return 0;
+               }
+               else
+               {
+                       printf("%u\n", LOW);
+                       return 0;
+               }
+       }
+       return -1;
+}

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux