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