Search
j0ke.net Open Build Service
>
Projects
>
GFS
>
multipath-tools
> multipath-tools-add-pp-pref-path
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File multipath-tools-add-pp-pref-path of Package multipath-tools
commit 2a415bb904d4019e2686b2512447fcdbdc8e2519 Author: Hannes Reinecke <hare@suse.de> Date: Mon Mar 3 13:13:59 2008 +0100 Add static path_priority callout Implement a preferred path callout for a static setup. References: #359829 Signed-off-by: Hannes Reinecke <hare@suse.de> diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 2e0e916..10f6f10 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -986,9 +986,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) { @@ -1121,6 +1143,17 @@ snprint_mp_pg_timeout (char * buff, int len, void * data) } 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; @@ -1682,6 +1715,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 --git a/libmultipath/discovery.c b/libmultipath/discovery.c index e6ef2c6..3d5d2cd 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -723,8 +723,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 7bc7083..9062f29 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -260,6 +260,16 @@ select_getuid (struct path * pp) extern int select_prio (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->prio) { pp->prio = pp->hwe->prio; condlog(3, "%s: prio = %s (controller setting)", diff --git a/path_priority/pp_pref_path/Makefile b/path_priority/pp_pref_path/Makefile new file mode 100644 index 0000000..eafc45f --- /dev/null +++ b/path_priority/pp_pref_path/Makefile @@ -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 --git a/path_priority/pp_pref_path/mpath_prio_pp.c b/path_priority/pp_pref_path/mpath_prio_pp.c new file mode 100644 index 0000000..3be81f1 --- /dev/null +++ b/path_priority/pp_pref_path/mpath_prio_pp.c @@ -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; +}