Blame SOURCES/0151-RHBZ-1297456-weighted-fix.patch

4ae388
---
4ae388
 libmultipath/print.c                     |    8 +++---
4ae388
 libmultipath/print.h                     |    4 +++
4ae388
 libmultipath/prioritizers/weightedpath.c |   37 +++++++++++++++++++++++++++++++
4ae388
 libmultipath/prioritizers/weightedpath.h |    1 
4ae388
 multipath/multipath.conf.5               |    8 +++++-
4ae388
 5 files changed, 53 insertions(+), 5 deletions(-)
4ae388
4ae388
Index: multipath-tools-130222/libmultipath/print.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/print.c
4ae388
+++ multipath-tools-130222/libmultipath/print.c
4ae388
@@ -468,19 +468,19 @@ out:
4ae388
 	return ret;
4ae388
 }
4ae388
 
4ae388
-static int
4ae388
+int
4ae388
 snprint_host_wwnn (char * buff, size_t len, struct path * pp)
4ae388
 {
4ae388
 	return snprint_host_attr(buff, len, pp, "node_name");
4ae388
 }
4ae388
 
4ae388
-static int
4ae388
+int
4ae388
 snprint_host_wwpn (char * buff, size_t len, struct path * pp)
4ae388
 {
4ae388
 	return snprint_host_attr(buff, len, pp, "port_name");
4ae388
 }
4ae388
 
4ae388
-static int
4ae388
+int
4ae388
 snprint_tgt_wwpn (char * buff, size_t len, struct path * pp)
4ae388
 {
4ae388
 	struct udev_device *rport_dev = NULL;
4ae388
@@ -510,7 +510,7 @@ out:
4ae388
 }
4ae388
 
4ae388
 
4ae388
-static int
4ae388
+int
4ae388
 snprint_tgt_wwnn (char * buff, size_t len, struct path * pp)
4ae388
 {
4ae388
 	if (pp->tgt_node_name[0] == '\0')
4ae388
Index: multipath-tools-130222/libmultipath/print.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/print.h
4ae388
+++ multipath-tools-130222/libmultipath/print.h
4ae388
@@ -50,6 +50,10 @@ int snprint_status (char *, int, struct
4ae388
 int snprint_devices (char *, int, struct vectors *);
4ae388
 int snprint_hwtable (char *, int, vector);
4ae388
 int snprint_mptable (char *, int, vector);
4ae388
+int snprint_host_wwnn (char *, size_t, struct path *);
4ae388
+int snprint_host_wwpn (char *, size_t, struct path *);
4ae388
+int snprint_tgt_wwnn (char *, size_t, struct path *);
4ae388
+int snprint_tgt_wwpn (char *, size_t, struct path *);
4ae388
 
4ae388
 void print_multipath_topology (struct multipath * mpp, int verbosity);
4ae388
 void print_path (struct path * pp, char * style);
4ae388
Index: multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/prioritizers/weightedpath.c
4ae388
+++ multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
4ae388
@@ -32,6 +32,8 @@
4ae388
 #include <memory.h>
4ae388
 #include <debug.h>
4ae388
 #include <regex.h>
4ae388
+#include <structs_vec.h>
4ae388
+#include <print.h>
4ae388
 #include "def_func.h"
4ae388
 
4ae388
 char *get_next_string(char **temp, char *split_char)
4ae388
@@ -43,6 +45,36 @@ char *get_next_string(char **temp, char
4ae388
 	return token;
4ae388
 }
4ae388
 
4ae388
+#define CHECK_LEN \
4ae388
+do { \
4ae388
+	if ((p - str) >= (len - 1)) { \
4ae388
+		condlog(0, "%s: %s - buffer size too small", pp->dev, pp->prio.name); \
4ae388
+		return -1; \
4ae388
+	} \
4ae388
+} while(0)
4ae388
+
4ae388
+static int
4ae388
+build_wwn_path(struct path *pp, char *str, int len)
4ae388
+{
4ae388
+	char *p = str;
4ae388
+
4ae388
+	p += snprint_host_wwnn(p, str + len - p, pp);
4ae388
+	CHECK_LEN;
4ae388
+	p += snprintf(p, str + len - p, ":");
4ae388
+	CHECK_LEN;
4ae388
+	p += snprint_host_wwpn(p, str + len - p, pp);
4ae388
+	CHECK_LEN;
4ae388
+	p += snprintf(p, str + len - p, ":");
4ae388
+	CHECK_LEN;
4ae388
+	p += snprint_tgt_wwnn(p, str + len - p, pp);
4ae388
+	CHECK_LEN;
4ae388
+	p += snprintf(p, str + len - p, ":");
4ae388
+	CHECK_LEN;
4ae388
+	p += snprint_tgt_wwpn(p, str + len - p, pp);
4ae388
+	CHECK_LEN;
4ae388
+	return 0;
4ae388
+}
4ae388
+
4ae388
 /* main priority routine */
4ae388
 int prio_path_weight(struct path *pp, char *prio_args)
4ae388
 {
4ae388
@@ -72,6 +104,11 @@ int prio_path_weight(struct path *pp, ch
4ae388
 			pp->sg_id.channel, pp->sg_id.scsi_id, pp->sg_id.lun);
4ae388
 	} else if (!strcmp(regex, DEV_NAME)) {
4ae388
 		strcpy(path, pp->dev);
4ae388
+	} else if (!strcmp(regex, WWN)) {
4ae388
+		if (build_wwn_path(pp, path, FILE_NAME_SIZE) != 0) {
4ae388
+			FREE(arg);
4ae388
+			return priority;
4ae388
+		}
4ae388
 	} else {
4ae388
 		condlog(0, "%s: %s - Invalid arguments", pp->dev,
4ae388
 			pp->prio.name);
4ae388
Index: multipath-tools-130222/libmultipath/prioritizers/weightedpath.h
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/libmultipath/prioritizers/weightedpath.h
4ae388
+++ multipath-tools-130222/libmultipath/prioritizers/weightedpath.h
4ae388
@@ -4,6 +4,7 @@
4ae388
 #define PRIO_WEIGHTED_PATH "weightedpath"
4ae388
 #define HBTL "hbtl"
4ae388
 #define DEV_NAME "devname"
4ae388
+#define WWN "wwn"
4ae388
 #define DEFAULT_PRIORITY 0
4ae388
 
4ae388
 int prio_path_weight(struct path *pp, char *prio_args);
4ae388
Index: multipath-tools-130222/multipath/multipath.conf.5
4ae388
===================================================================
4ae388
--- multipath-tools-130222.orig/multipath/multipath.conf.5
4ae388
+++ multipath-tools-130222/multipath/multipath.conf.5
4ae388
@@ -216,11 +216,17 @@ prioritizers
4ae388
 .TP 12
4ae388
 .B weighted
4ae388
 Needs a value of the form
4ae388
-.I "<hbtl|devname> <regex1> <prio1> <regex2> <prio2> ..."
4ae388
+.I "<hbtl|devname|wwn> <regex1> <prio1> <regex2> <prio2> ..."
4ae388
 .I hbtl
4ae388
 regex can be of SCSI H:B:T:L format  Ex: 1:0:.:. , *:0:0:.
4ae388
 .I devname
4ae388
 regex can be of device name format  Ex: sda , sd.e
4ae388
+.I wwn
4ae388
+regex can be of the form
4ae388
+.I "host_wwnn:host_wwpn:target_wwnn:target_wwpn"
4ae388
+these values can be looked up through sysfs or by running
4ae388
+.I mulitpathd show paths format "%N:%R:%n:%r"
4ae388
+Ex: 0x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* , .*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.*
4ae388
 .TP
4ae388
 .B alua
4ae388
 If