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