[all] User friendly names patch
authorChristophe Varoqui <root@xa-s05.(none)>
Tue, 25 Oct 2005 13:22:12 +0000 (15:22 +0200)
committerChristophe Varoqui <root@xa-s05.(none)>
Tue, 25 Oct 2005 13:22:12 +0000 (15:22 +0200)
This is a patch to add the option of more user friendly names for the
multipath maps, in the form of mpath<n>.  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

libmultipath/Makefile
libmultipath/config.h
libmultipath/devmapper.h
libmultipath/dict.c
libmultipath/propsel.c
libmultipath/uxsock.h
multipath.conf.annotated
multipath.conf.synthetic
multipath/main.c
multipathd/main.c

index c1664a4..0bba4fb 100644 (file)
@@ -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
 
index cc6ec90..0149f68 100644 (file)
@@ -59,6 +59,7 @@ struct config {
        int remove;
        int rr_weight;
        int no_path_retry;
+       int user_friendly_names;
 
        char * dev;
        char * udev_dir;
index e3a64c6..e8d5065 100644 (file)
@@ -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);
index dde885e..06333f0 100644 (file)
@@ -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
index 3e6873a..0253c4b 100644 (file)
@@ -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;
 }
index 29d2de0..fd82552 100644 (file)
@@ -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);
index 0844798..2ca13ba 100644 (file)
 #      # 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<n>.
+#      #           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
+#
 #}
 #      
 ##
index db7721e..190b175 100644 (file)
@@ -14,6 +14,7 @@
 #      rr_weight               priorities
 #      failback                immediate
 #      no_path_retry           fail
+#      user_friendly_name      no
 #}
 #devnode_blacklist {
 #       wwid 26353900f02796769
index e5b8101..e2c8a04 100644 (file)
@@ -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();
 
index 7835721..71a71f1 100644 (file)
@@ -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