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

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