packages: multipath-tools/multipath-tools.spec, multipath-tools/multipath-t...
arekm
arekm at pld-linux.org
Wed Nov 17 15:07:26 CET 2010
Author: arekm Date: Wed Nov 17 14:07:26 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- readd git patch
---- Files affected:
packages/multipath-tools:
multipath-tools.spec (1.70 -> 1.71) , multipath-tools-git.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/multipath-tools/multipath-tools.spec
diff -u packages/multipath-tools/multipath-tools.spec:1.70 packages/multipath-tools/multipath-tools.spec:1.71
--- packages/multipath-tools/multipath-tools.spec:1.70 Wed Nov 17 08:08:45 2010
+++ packages/multipath-tools/multipath-tools.spec Wed Nov 17 15:07:20 2010
@@ -19,6 +19,7 @@
Source4: %{name}-initramfs-hooks
Source5: %{name}-initramfs-local-top
URL: http://christophe.varoqui.free.fr/
+Patch100: %{name}-git.patch
Patch0: %{name}-llh.patch
Patch1: %{name}-kpartx-udev.patch
Patch2: config.patch
@@ -110,6 +111,7 @@
%prep
%setup -qc
+%patch100 -p1
%patch0 -p1
%patch1 -p1
%patch2 -p1
@@ -197,6 +199,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.71 2010/11/17 14:07:20 arekm
+- readd git patch
+
Revision 1.70 2010/11/17 07:08:45 arekm
- rel 2; no ldconfig needed
================================================================
Index: packages/multipath-tools/multipath-tools-git.patch
diff -u /dev/null packages/multipath-tools/multipath-tools-git.patch:1.1
--- /dev/null Wed Nov 17 15:07:26 2010
+++ packages/multipath-tools/multipath-tools-git.patch Wed Nov 17 15:07:20 2010
@@ -0,0 +1,1200 @@
+diff --git a/libmultipath/alias.c b/libmultipath/alias.c
+index 95506b4..4159ec6 100644
+--- a/libmultipath/alias.c
++++ b/libmultipath/alias.c
+@@ -180,34 +180,35 @@ fail:
+ }
+
+ static int
+-format_devname(char *name, int id, int len)
++format_devname(char *name, int id, int len, char *prefix)
+ {
+ int pos;
++ int prefix_len = strlen(prefix);
+
+ memset(name,0, len);
+- strcpy(name,"mpath");
+- for (pos = len - 1; pos >= 5; pos--) {
++ strcpy(name, prefix);
++ for (pos = len - 1; pos >= prefix_len; pos--) {
+ name[pos] = 'a' + id % 26;
+ if (id < 26)
+ break;
+ id /= 26;
+ id--;
+ }
+- memmove(name + 5, name + pos, len - pos);
+- name[5 + len - pos] = '\0';
+- return (5 + len - pos);
++ memmove(name + prefix_len, name + pos, len - pos);
++ name[prefix_len + len - pos] = '\0';
++ return (prefix_len + len - pos);
+ }
+
+ static int
+-scan_devname(char *alias)
++scan_devname(char *alias, char *prefix)
+ {
+ char *c;
+ int i, n = 0;
+
+- if (strncmp(alias, "mpath", 5))
++ if (!prefix || strncmp(alias, prefix, strlen(prefix)))
+ return -1;
+
+- c = alias + 5;
++ c = alias + strlen(prefix);
+ while (*c != '\0' && *c != ' ' && *c != '\t') {
+ i = *c - 'a';
+ n = ( n * 26 ) + i;
+@@ -221,7 +222,7 @@ scan_devname(char *alias)
+ }
+
+ static int
+-lookup_binding(FILE *f, char *map_wwid, char **map_alias)
++lookup_binding(FILE *f, char *map_wwid, char **map_alias, char *prefix)
+ {
+ char buf[LINE_MAX];
+ unsigned int line_nr = 0;
+@@ -240,7 +241,7 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias)
+ alias = strtok(buf, " \t");
+ if (!alias) /* blank line */
+ continue;
+- curr_id = scan_devname(alias);
++ curr_id = scan_devname(alias, prefix);
+ if (curr_id >= id)
+ id = curr_id + 1;
+ wwid = strtok(NULL, "");
+@@ -284,7 +285,7 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
+ alias = strtok(buf, " \t");
+ if (!alias) /* blank line */
+ continue;
+- curr_id = scan_devname(alias);
++ curr_id = scan_devname(alias, NULL); /* TBD: Why this call? */
+ if (curr_id >= id)
+ id = curr_id + 1;
+ wwid = strtok(NULL, " \t");
+@@ -309,7 +310,7 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
+ }
+
+ static char *
+-allocate_binding(int fd, char *wwid, int id)
++allocate_binding(int fd, char *wwid, int id, char *prefix)
+ {
+ char buf[LINE_MAX];
+ off_t offset;
+@@ -321,7 +322,7 @@ allocate_binding(int fd, char *wwid, int id)
+ return NULL;
+ }
+
+- i = format_devname(buf, id, LINE_MAX);
++ i = format_devname(buf, id, LINE_MAX, prefix);
+ c = buf + i;
+ snprintf(c,LINE_MAX - i, " %s\n", wwid);
+ buf[LINE_MAX - 1] = '\0';
+@@ -352,7 +353,8 @@ allocate_binding(int fd, char *wwid, int id)
+ }
+
+ char *
+-get_user_friendly_alias(char *wwid, char *file)
++get_user_friendly_alias(char *wwid, char *file, char *prefix,
++ int bindings_read_only)
+ {
+ char *alias;
+ int fd, scan_fd, id;
+@@ -385,7 +387,7 @@ get_user_friendly_alias(char *wwid, char *file)
+ return NULL;
+ }
+
+- id = lookup_binding(f, wwid, &alias);
++ id = lookup_binding(f, wwid, &alias, prefix);
+ if (id < 0) {
+ fclose(f);
+ close(scan_fd);
+@@ -393,8 +395,8 @@ get_user_friendly_alias(char *wwid, char *file)
+ return NULL;
+ }
+
+- if (!alias && can_write)
+- alias = allocate_binding(fd, wwid, id);
++ if (!alias && can_write && !bindings_read_only)
++ alias = allocate_binding(fd, wwid, id, prefix);
+
+ fclose(f);
+ close(scan_fd);
+diff --git a/libmultipath/alias.h b/libmultipath/alias.h
+index fe1191b..c489a86 100644
+--- a/libmultipath/alias.h
++++ b/libmultipath/alias.h
+@@ -8,5 +8,6 @@
+ "# alias wwid\n" \
+ "#\n"
+
+-char *get_user_friendly_alias(char *wwid, char *file);
++char *get_user_friendly_alias(char *wwid, char *file, char *prefix,
++ int bindings_readonly);
+ char *get_user_friendly_wwid(char *alias, char *file);
+diff --git a/libmultipath/config.c b/libmultipath/config.c
+index a4178be..00acf96 100644
+--- a/libmultipath/config.c
++++ b/libmultipath/config.c
+@@ -158,6 +158,9 @@ free_hwe (struct hwentry * hwe)
+ if (hwe->prio_args)
+ FREE(hwe->prio_args);
+
++ if (hwe->alias_prefix)
++ FREE(hwe->alias_prefix);
++
+ if (hwe->bl_product)
+ FREE(hwe->bl_product);
+
+@@ -282,6 +285,7 @@ merge_hwe (struct hwentry * hwe1, struct hwentry * hwe2)
+ merge_str(checker_name);
+ merge_str(prio_name);
+ merge_str(prio_args);
++ merge_str(alias_prefix);
+ merge_str(bl_product);
+ merge_num(pgpolicy);
+ merge_num(pgfailback);
+@@ -333,6 +337,9 @@ store_hwe (vector hwtable, struct hwentry * dhwe)
+ if (dhwe->prio_args && !(hwe->prio_args = set_param_str(dhwe->prio_args)))
+ goto out;
+
++ if (dhwe->alias_prefix && !(hwe->alias_prefix = set_param_str(dhwe->alias_prefix)))
++ goto out;
++
+ hwe->pgpolicy = dhwe->pgpolicy;
+ hwe->pgfailback = dhwe->pgfailback;
+ hwe->rr_weight = dhwe->rr_weight;
+@@ -409,6 +416,9 @@ free_config (struct config * conf)
+ if (conf->prio_name)
+ FREE(conf->prio_name);
+
++ if (conf->alias_prefix)
++ FREE(conf->alias_prefix);
++
+ if (conf->prio_args)
+ FREE(conf->prio_args);
+
+@@ -448,6 +458,7 @@ load_config (char * file)
+ conf->minio = 1000;
+ conf->max_fds = 0;
+ conf->bindings_file = DEFAULT_BINDINGS_FILE;
++ conf->bindings_read_only = 0;
+ conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
+ conf->flush_on_last_del = 0;
+ conf->attribute_flags = 0;
+diff --git a/libmultipath/config.h b/libmultipath/config.h
+index 471eed0..5a5f81b 100644
+--- a/libmultipath/config.h
++++ b/libmultipath/config.h
+@@ -25,6 +25,7 @@ struct hwentry {
+ char * checker_name;
+ char * prio_name;
+ char * prio_args;
++ char * alias_prefix;
+
+ int pgpolicy;
+ int pgfailback;
+@@ -73,6 +74,7 @@ struct config {
+ int rr_weight;
+ int no_path_retry;
+ int user_friendly_names;
++ int bindings_read_only;
+ int pg_timeout;
+ int max_fds;
+ int force_reload;
+@@ -99,6 +101,7 @@ struct config {
+ char * prio_name;
+ char * prio_args;
+ char * checker_name;
++ char * alias_prefix;
+
+ vector keywords;
+ vector mptable;
+diff --git a/libmultipath/configure.c b/libmultipath/configure.c
+index c6ca4b6..a40bef3 100644
+--- a/libmultipath/configure.c
++++ b/libmultipath/configure.c
+@@ -284,6 +284,7 @@ lock_multipath (struct multipath * mpp, int lock)
+ struct pathgroup * pgp;
+ struct path * pp;
+ int i, j;
++ int x, y;
+
+ if (!mpp || !mpp->pg)
+ return 0;
+@@ -294,12 +295,25 @@ lock_multipath (struct multipath * mpp, int lock)
+ vector_foreach_slot(pgp->paths, pp, j) {
+ if (lock && flock(pp->fd, LOCK_EX | LOCK_NB) &&
+ errno == EWOULDBLOCK)
+- return 1;
++ goto fail;
+ else if (!lock)
+ flock(pp->fd, LOCK_UN);
+ }
+ }
+ return 0;
++fail:
++ vector_foreach_slot (mpp->pg, pgp, x) {
++ if (x > i)
++ return 1;
++ if (!pgp->paths)
++ continue;
++ vector_foreach_slot(pgp->paths, pp, y) {
++ if (x == i && y >= j)
++ return 1;
++ flock(pp->fd, LOCK_UN);
++ }
++ }
++ return 1;
+ }
+
+ /*
+@@ -577,11 +591,11 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
+
+ remove_map(mpp, vecs, 0);
+
+- if (dm_flush_map(mpp->alias))
++ if (dm_flush_map(alias))
+ condlog(2, "%s: remove failed (dead)",
+- mpp->alias);
++ alias);
+ else
+- condlog(2, "%s: remove (dead)", mpp->alias);
++ condlog(2, "%s: remove (dead)", alias);
+ }
+ }
+ return 0;
+diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h
+index 5a38d25..77526dd 100644
+--- a/libmultipath/defaults.h
++++ b/libmultipath/defaults.h
+@@ -2,6 +2,7 @@
+ #define DEFAULT_UDEVDIR "/dev"
+ #define DEFAULT_MULTIPATHDIR "/" LIB_STRING "/multipath"
+ #define DEFAULT_SELECTOR "round-robin 0"
++#define DEFAULT_ALIAS_PREFIX "mpath"
+ #define DEFAULT_FEATURES "0"
+ #define DEFAULT_HWHANDLER "0"
+ #define DEFAULT_MINIO 1000
+diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
+index 333659b..fb69ee8 100644
+--- a/libmultipath/devmapper.c
++++ b/libmultipath/devmapper.c
+@@ -777,35 +777,49 @@ out:
+ return r;
+ }
+
+-extern int
+-dm_get_name(char *uuid, char *name)
++extern char *
++dm_get_name(char *uuid)
+ {
+- vector vec;
+- struct multipath *mpp;
+- int i, rc = 0;
+-
+- vec = vector_alloc();
++ struct dm_task *dmt;
++ struct dm_info info;
++ char *prefixed_uuid, *name = NULL;
++ const char *nametmp;
+
+- if (!vec)
+- return 0;
++ dmt = dm_task_create(DM_DEVICE_INFO);
++ if (!dmt)
++ return NULL;
+
+- if (dm_get_maps(vec)) {
+- goto out;
++ prefixed_uuid = MALLOC(UUID_PREFIX_LEN + strlen(uuid) + 1);
++ if (!prefixed_uuid) {
++ condlog(0, "cannot create prefixed uuid : %s\n",
++ strerror(errno));
++ goto freeout;
+ }
++ sprintf(prefixed_uuid, UUID_PREFIX "%s", uuid);
++ if (!dm_task_set_uuid(dmt, prefixed_uuid))
++ goto freeout;
+
+- vector_foreach_slot(vec, mpp, i) {
+- if (!strcmp(uuid, mpp->wwid)) {
+- strcpy(name, mpp->alias);
+- rc=1;
+- break;
+- }
+- }
+-out:
+- vector_foreach_slot(vec, mpp, i) {
+- free_multipath(mpp, KEEP_PATHS);
++ if (!dm_task_run(dmt))
++ goto freeout;
++
++ if (!dm_task_get_info(dmt, &info) || !info.exists)
++ goto freeout;
++
++ nametmp = dm_task_get_name(dmt);
++ if (nametmp && strlen(nametmp)) {
++ name = MALLOC(strlen(nametmp) + 1);
++ if (name)
++ strcpy(name, nametmp);
++ } else {
++ condlog(2, "%s: no device-mapper name found", uuid);
+ }
+- vector_free(vec);
+- return rc;
++
++freeout:
++ if (prefixed_uuid)
++ FREE(prefixed_uuid);
++ dm_task_destroy(dmt);
++
++ return name;
+ }
+
+ int
+diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
+index f3ffeaa..6c22bf3 100644
+--- a/libmultipath/devmapper.h
++++ b/libmultipath/devmapper.h
+@@ -37,6 +37,6 @@ int dm_remove_partmaps (const char * mapname, int need_sync);
+ int dm_get_uuid(char *name, char *uuid);
+ int dm_get_info (char * mapname, struct dm_info ** dmi);
+ int dm_rename (char * old, char * new);
+-int dm_get_name(char * uuid, char * name);
++char * dm_get_name(char * uuid);
+
+ #endif /* _DEVMAPPER_H */
+diff --git a/libmultipath/dict.c b/libmultipath/dict.c
+index 02aa238..964df9e 100644
+--- a/libmultipath/dict.c
++++ b/libmultipath/dict.c
+@@ -148,6 +148,17 @@ def_prio_handler(vector strvec)
+ }
+
+ static int
++def_alias_prefix_handler(vector strvec)
++{
++ conf->alias_prefix = set_value(strvec);
++
++ if (!conf->alias_prefix)
++ return 1;
++
++ return 0;
++}
++
++static int
+ def_prio_args_handler(vector strvec)
+ {
+ conf->prio_args = set_value(strvec);
+@@ -831,6 +842,22 @@ hw_prio_handler(vector strvec)
+ }
+
+ static int
++hw_alias_prefix_handler(vector strvec)
++{
++ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
++
++ if (!hwe)
++ return 1;
++
++ hwe->alias_prefix = set_value(strvec);
++
++ if (!hwe->alias_prefix)
++ return 1;
++
++ return 0;
++}
++
++static int
+ hw_prio_args_handler(vector strvec)
+ {
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+@@ -1580,6 +1607,19 @@ snprint_hw_prio (char * buff, int len, void * data)
+ }
+
+ static int
++snprint_hw_alias_prefix (char * buff, int len, void * data)
++{
++ struct hwentry * hwe = (struct hwentry *)data;
++
++ if (!hwe->alias_prefix || (strlen(hwe->alias_prefix) == 0))
++ return 0;
++ if (conf->alias_prefix && !strcmp(hwe->alias_prefix, conf->alias_prefix))
++ return 0;
++
++ return snprintf(buff, len, "%s", hwe->alias_prefix);
++}
++
++static int
+ snprint_hw_prio_args (char * buff, int len, void * data)
+ {
+ struct hwentry * hwe = (struct hwentry *)data;
+@@ -2076,6 +2116,16 @@ snprint_def_user_friendly_names (char * buff, int len, void * data)
+ }
+
+ static int
++snprint_def_alias_prefix (char * buff, int len, void * data)
++{
++ if (!conf->alias_prefix)
++ return 0;
++ if (!strcmp(conf->alias_prefix, DEFAULT_ALIAS_PREFIX))
++ return 0;
++ return snprintf(buff, len, conf->alias_prefix);
++}
++
++static int
+ snprint_ble_simple (char * buff, int len, void * data)
+ {
+ struct blentry * ble = (struct blentry *)data;
+@@ -2117,6 +2167,7 @@ init_keywords(void)
+ install_keyword("features", &def_features_handler, &snprint_def_features);
+ install_keyword("path_checker", &def_path_checker_handler, &snprint_def_path_checker);
+ install_keyword("checker", &def_path_checker_handler, &snprint_def_path_checker);
++ install_keyword("alias_prefix", &def_alias_prefix_handler, &snprint_def_alias_prefix);
+ install_keyword("failback", &default_failback_handler, &snprint_def_failback);
+ install_keyword("rr_min_io", &def_minio_handler, &snprint_def_rr_min_io);
+ install_keyword("max_fds", &max_fds_handler, &snprint_max_fds);
+@@ -2138,17 +2189,17 @@ init_keywords(void)
+ __deprecated install_keyword("default_path_checker", &def_path_checker_handler, NULL);
+
+ install_keyword_root("blacklist", &blacklist_handler);
+- install_keyword("devnode", &ble_devnode_handler, &snprint_ble_simple);
+- install_keyword("wwid", &ble_wwid_handler, &snprint_ble_simple);
+- install_keyword("device", &ble_device_handler, NULL);
++ install_keyword_multi("devnode", &ble_devnode_handler, &snprint_ble_simple);
++ install_keyword_multi("wwid", &ble_wwid_handler, &snprint_ble_simple);
++ install_keyword_multi("device", &ble_device_handler, NULL);
+ install_sublevel();
+ install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
+ install_keyword("product", &ble_product_handler, &snprint_bled_product);
+ install_sublevel_end();
+ install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
+- install_keyword("devnode", &ble_except_devnode_handler, &snprint_ble_simple);
+- install_keyword("wwid", &ble_except_wwid_handler, &snprint_ble_simple);
+- install_keyword("device", &ble_except_device_handler, NULL);
++ install_keyword_multi("devnode", &ble_except_devnode_handler, &snprint_ble_simple);
++ install_keyword_multi("wwid", &ble_except_wwid_handler, &snprint_ble_simple);
++ install_keyword_multi("device", &ble_except_device_handler, NULL);
+ install_sublevel();
+ install_keyword("vendor", &ble_except_vendor_handler, &snprint_bled_vendor);
+ install_keyword("product", &ble_except_product_handler, &snprint_bled_product);
+@@ -2166,7 +2217,7 @@ init_keywords(void)
+ #endif
+
+ install_keyword_root("devices", &devices_handler);
+- install_keyword("device", &device_handler, NULL);
++ install_keyword_multi("device", &device_handler, NULL);
+ install_sublevel();
+ install_keyword("vendor", &vendor_handler, &snprint_hw_vendor);
+ install_keyword("product", &product_handler, &snprint_hw_product);
+@@ -2176,6 +2227,7 @@ init_keywords(void)
+ install_keyword("path_selector", &hw_selector_handler, &snprint_hw_selector);
+ install_keyword("path_checker", &hw_path_checker_handler, &snprint_hw_path_checker);
+ install_keyword("checker", &hw_path_checker_handler, &snprint_hw_path_checker);
++ install_keyword("alias_prefix", &hw_alias_prefix_handler, &snprint_hw_alias_prefix);
+ install_keyword("features", &hw_features_handler, &snprint_hw_features);
+ install_keyword("hardware_handler", &hw_handler_handler, &snprint_hw_hardware_handler);
+ install_keyword("prio", &hw_prio_handler, &snprint_hw_prio);
+@@ -2191,7 +2243,7 @@ init_keywords(void)
+ install_sublevel_end();
+
+ install_keyword_root("multipaths", &multipaths_handler);
+- install_keyword("multipath", &multipath_handler, NULL);
++ install_keyword_multi("multipath", &multipath_handler, NULL);
+ install_sublevel();
+ install_keyword("wwid", &wwid_handler, &snprint_mp_wwid);
+ install_keyword("alias", &alias_handler, &snprint_mp_alias);
+diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
+index 122eb8f..c371b47 100644
+--- a/libmultipath/discovery.c
++++ b/libmultipath/discovery.c
+@@ -10,6 +10,7 @@
+ #include <sys/stat.h>
+ #include <dirent.h>
+ #include <errno.h>
++#include <libgen.h>
+
+ #include "checkers.h"
+ #include "vector.h"
+@@ -204,6 +205,41 @@ sysfs_get_fc_nodename (struct sysfs_device * dev, char * node,
+ return 1;
+ }
+
++static int
++find_rport_id(struct path *pp)
++{
++ char attr_path[SYSFS_PATH_SIZE];
++ char *dir, *base;
++ int host, channel, rport_id = -1;
++
++ if (safe_sprintf(attr_path,
++ "/class/fc_transport/target%i:%i:%i",
++ pp->sg_id.host_no, pp->sg_id.channel,
++ pp->sg_id.scsi_id)) {
++ condlog(0, "attr_path too small for target");
++ return 1;
++ }
++
++ if (sysfs_resolve_link(attr_path, SYSFS_PATH_SIZE))
++ return -1;
++
++ condlog(4, "target%d:%d:%d -> path %s", pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.scsi_id, attr_path);
++ dir = attr_path;
++ do {
++ base = basename(dir);
++ dir = dirname(dir);
++
++ if (sscanf((const char *)base, "rport-%d:%d-%d", &host, &channel, &rport_id) == 3)
++ break;
++ } while (strcmp((const char *)dir, "/"));
++
++ if (rport_id < 0)
++ return -1;
++
++ condlog(4, "target%d:%d:%d -> rport_id %d", pp->sg_id.host_no, pp->sg_id.channel, pp->sg_id.scsi_id, rport_id);
++ return rport_id;
++}
++
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/multipath-tools/multipath-tools.spec?r1=1.70&r2=1.71&f=u
More information about the pld-cvs-commit
mailing list