From: Christophe Varoqui Date: Tue, 25 Oct 2005 13:22:12 +0000 (+0200) Subject: [all] User friendly names patch X-Git-Tag: 0.4.6~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b0040b431f102e05f817468f5f5c775a6ece4db;p=platform%2Fupstream%2Fmultipath-tools.git [all] User friendly names patch This is a patch to add the option of more user friendly names for the multipath maps, in the form of mpath. It adds a configuration option "user_friendly_names". If set, it will cause multipath to check a bindings file for the names. The bindings file (/var/lib/multipath/bindings) has alias to wwid mappings. If multipath finds its wwid in the file, it uses the associated alias. If not, it creates a new alias, and adds the binding to the bindings file. If the config option is not set, multipath defaults to it's regular behavior. Specific aliases in /etc/multipath.conf override this behavior. Benjamin Marzinski, Redhat --- diff --git a/libmultipath/Makefile b/libmultipath/Makefile index c1664a4..0bba4fb 100644 --- a/libmultipath/Makefile +++ b/libmultipath/Makefile @@ -10,7 +10,7 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \ hwtable.o blacklist.o util.o dmparser.o config.o \ structs.o cache.o discovery.o propsel.o dict.o \ pgpolicies.o debug.o regex.o defaults.o uevent.o \ - switchgroup.o uxsock.o print.o + switchgroup.o uxsock.o print.o alias.o CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes diff --git a/libmultipath/config.h b/libmultipath/config.h index cc6ec90..0149f68 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -59,6 +59,7 @@ struct config { int remove; int rr_weight; int no_path_retry; + int user_friendly_names; char * dev; char * udev_dir; diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index e3a64c6..e8d5065 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -21,6 +21,7 @@ int dm_geteventnr (char *name); int dm_get_minor (char *name); char * dm_mapname(int major, int minor); int dm_remove_partmaps (char * mapname); +int dm_get_uuid(char *name, char *uuid); #if 0 int dm_rename (char * old, char * new); diff --git a/libmultipath/dict.c b/libmultipath/dict.c index dde885e..06333f0 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -191,6 +191,25 @@ def_no_path_retry_handler(vector strvec) return 0; } +static int +names_handler(vector strvec) +{ + char * buff; + + buff = set_value(strvec); + + if (!buff) + return 1; + + if (!strncmp(buff, "no", 2) || !strncmp(buff, "0", 1)) + conf->user_friendly_names = 0; + else if (!strncmp(buff, "yes", 2) || !strncmp(buff, "1", 1)) + conf->user_friendly_names = 1; + + FREE(buff); + return 0; +} + /* * blacklist block handlers */ @@ -665,6 +684,7 @@ init_keywords(void) install_keyword("rr_min_io", &def_minio_handler); install_keyword("rr_weight", &def_weight_handler); install_keyword("no_path_retry", &def_no_path_retry_handler); + install_keyword("user_friendly_names", &names_handler); /* * deprecated synonyms diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index 3e6873a..0253c4b 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -5,6 +5,7 @@ #include "config.h" #include "debug.h" #include "pgpolicies.h" +#include "alias.h" #include "../libcheckers/checkers.h" @@ -126,8 +127,13 @@ select_alias (struct multipath * mp) { if (mp->mpe && mp->mpe->alias) mp->alias = mp->mpe->alias; - else - mp->alias = mp->wwid; + else { + mp->alias = NULL; + if (conf->user_friendly_names) + mp->alias = get_user_friendly_alias(mp->wwid); + if (mp->alias == NULL) + mp->alias = mp->wwid; + } return 0; } diff --git a/libmultipath/uxsock.h b/libmultipath/uxsock.h index 29d2de0..fd82552 100644 --- a/libmultipath/uxsock.h +++ b/libmultipath/uxsock.h @@ -3,4 +3,5 @@ int ux_socket_connect(const char *name); int ux_socket_listen(const char *name); int send_packet(int fd, const char *buf, size_t len); int recv_packet(int fd, char **buf, size_t *len); - +size_t write_all(int fd, const void *buf, size_t len); +size_t read_all(int fd, void *buf, size_t len); diff --git a/multipath.conf.annotated b/multipath.conf.annotated index 0844798..2ca13ba 100644 --- a/multipath.conf.annotated +++ b/multipath.conf.annotated @@ -110,6 +110,20 @@ # # default : (null) # # # #no_path_retry queue +# +# # +# # name : user_friendly_names +# # scope : multipath +# # desc : If set to "yes", using the bindings file +# # /var/lib/multipath/bindings to assign a persistent and +# # unique alias to the multipath, in the form of mpath. +# # If set to "no" use the WWID as the alias. In either case +# # this be will be overriden by any specific aliases in this +# # file. +# # values : yes|no +# # default : no +# user_friendly_names no +# #} # ## diff --git a/multipath.conf.synthetic b/multipath.conf.synthetic index db7721e..190b175 100644 --- a/multipath.conf.synthetic +++ b/multipath.conf.synthetic @@ -14,6 +14,7 @@ # rr_weight priorities # failback immediate # no_path_retry fail +# user_friendly_name no #} #devnode_blacklist { # wwid 26353900f02796769 diff --git a/multipath/main.c b/multipath/main.c index e5b8101..e2c8a04 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -751,10 +751,10 @@ coalesce_paths (vector curmp, vector pathvec) mpp->mpe = find_mpe(pp1->wwid); mpp->hwe = pp1->hwe; + strcpy(mpp->wwid, pp1->wwid); select_alias(mpp); pp1->mpp = mpp; - strcpy(mpp->wwid, pp1->wwid); mpp->size = pp1->size; mpp->paths = vector_alloc(); diff --git a/multipathd/main.c b/multipathd/main.c index 7835721..71a71f1 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -213,15 +213,10 @@ update_multipath_strings (struct multipath *mpp, vector pathvec) static void set_multipath_wwid (struct multipath * mpp) { - char * wwid; - - wwid = get_mpe_wwid(mpp->alias); + if (mpp->wwid) + return; - if (wwid) { - strncpy(mpp->wwid, wwid, WWID_SIZE); - wwid = NULL; - } else - strncpy(mpp->wwid, mpp->alias, WWID_SIZE); + dm_get_uuid(mpp->alias, mpp->wwid); } static int