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

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