Blame SOURCES/0119-RHBZ-1081397-save-alua-info.patch

ecd2a9
---
ecd2a9
 libmultipath/prio.c                      |   34 ++++++++++++++++-
ecd2a9
 libmultipath/prio.h                      |    7 +++
ecd2a9
 libmultipath/prioritizers/alua.c         |   62 +++++++++++++++++++++++--------
ecd2a9
 libmultipath/prioritizers/alua_rtpg.c    |   22 +++++++++--
ecd2a9
 libmultipath/prioritizers/alua_rtpg.h    |    4 +-
ecd2a9
 libmultipath/prioritizers/const.c        |    4 ++
ecd2a9
 libmultipath/prioritizers/datacore.c     |    3 +
ecd2a9
 libmultipath/prioritizers/def_func.h     |   11 +++++
ecd2a9
 libmultipath/prioritizers/emc.c          |    4 ++
ecd2a9
 libmultipath/prioritizers/hds.c          |    4 ++
ecd2a9
 libmultipath/prioritizers/hp_sw.c        |    4 ++
ecd2a9
 libmultipath/prioritizers/iet.c          |    4 ++
ecd2a9
 libmultipath/prioritizers/ontap.c        |    4 ++
ecd2a9
 libmultipath/prioritizers/random.c       |    4 ++
ecd2a9
 libmultipath/prioritizers/rdac.c         |    4 ++
ecd2a9
 libmultipath/prioritizers/weightedpath.c |    3 +
ecd2a9
 libmultipath/propsel.c                   |    4 +-
ecd2a9
 multipathd/main.c                        |   24 ++++++++----
ecd2a9
 18 files changed, 174 insertions(+), 32 deletions(-)
ecd2a9
ecd2a9
Index: multipath-tools-130222/libmultipath/prio.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prio.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prio.c
ecd2a9
@@ -112,9 +112,24 @@ struct prio * add_prio (char * name)
ecd2a9
 	p->getprio = (int (*)(struct path *, char *)) dlsym(p->handle, "getprio");
ecd2a9
 	errstr = dlerror();
ecd2a9
 	if (errstr != NULL)
ecd2a9
-		condlog(0, "A dynamic linking error occurred: (%s)", errstr);
ecd2a9
+		condlog(0, "A dynamic linking error occurred with getprio: (%s)", errstr);
ecd2a9
 	if (!p->getprio)
ecd2a9
 		goto out;
ecd2a9
+
ecd2a9
+	p->initprio = (int (*)(struct prio *)) dlsym(p->handle, "initprio");
ecd2a9
+	errstr = dlerror();
ecd2a9
+	if (errstr != NULL)
ecd2a9
+		condlog(0, "A dynamic linking error occurred with initprio: (%s)", errstr);
ecd2a9
+	if (!p->initprio)
ecd2a9
+		goto out;
ecd2a9
+
ecd2a9
+	p->freeprio = (int (*)(struct prio *)) dlsym(p->handle, "freeprio");
ecd2a9
+	errstr = dlerror();
ecd2a9
+	if (errstr != NULL)
ecd2a9
+		condlog(0, "A dynamic linking error occurred with freeprio: (%s)", errstr);
ecd2a9
+	if (!p->freeprio)
ecd2a9
+		goto out;
ecd2a9
+
ecd2a9
 	list_add(&p->node, &prioritizers);
ecd2a9
 	return p;
ecd2a9
 out:
ecd2a9
@@ -122,6 +137,13 @@ out:
ecd2a9
 	return NULL;
ecd2a9
 }
ecd2a9
 
ecd2a9
+int prio_init (struct prio * p)
ecd2a9
+{
ecd2a9
+	if (!p || !p->initprio)
ecd2a9
+		return 1;
ecd2a9
+	return p->initprio(p);
ecd2a9
+}
ecd2a9
+
ecd2a9
 int prio_getprio (struct prio * p, struct path * pp)
ecd2a9
 {
ecd2a9
 	return p->getprio(pp, p->args);
ecd2a9
@@ -156,8 +178,16 @@ void prio_get (struct prio * dst, char *
ecd2a9
 	strncpy(dst->name, src->name, PRIO_NAME_LEN);
ecd2a9
 	if (args)
ecd2a9
 		strncpy(dst->args, args, PRIO_ARGS_LEN);
ecd2a9
+	dst->initprio = src->initprio;
ecd2a9
 	dst->getprio = src->getprio;
ecd2a9
+	dst->freeprio = src->freeprio;
ecd2a9
 	dst->handle = NULL;
ecd2a9
+	dst->context = NULL;
ecd2a9
+
ecd2a9
+	if (dst->initprio(dst) != 0){
ecd2a9
+		memset(dst, 0x0, sizeof(struct prio));
ecd2a9
+		return;
ecd2a9
+	}
ecd2a9
 
ecd2a9
 	src->refcount++;
ecd2a9
 }
ecd2a9
@@ -173,6 +203,8 @@ void prio_put (struct prio * dst)
ecd2a9
 		src = NULL;
ecd2a9
 	else
ecd2a9
 		src = prio_lookup(dst->name);
ecd2a9
+	if (dst->freeprio)
ecd2a9
+		dst->freeprio(dst);
ecd2a9
 	memset(dst, 0x0, sizeof(struct prio));
ecd2a9
 	free_prio(src);
ecd2a9
 }
ecd2a9
Index: multipath-tools-130222/libmultipath/prio.h
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prio.h
ecd2a9
+++ multipath-tools-130222/libmultipath/prio.h
ecd2a9
@@ -46,9 +46,15 @@ struct prio {
ecd2a9
 	void *handle;
ecd2a9
 	int refcount;
ecd2a9
 	struct list_head node;
ecd2a9
+	void * context;
ecd2a9
 	char name[PRIO_NAME_LEN];
ecd2a9
 	char args[PRIO_ARGS_LEN];
ecd2a9
+	int (*initprio)(struct prio * p);
ecd2a9
+	/* You are allowed to call initprio multiple times without calling
ecd2a9
+	 * freeprio. Doing so will reinitialize it (possibly skipping
ecd2a9
+	 * allocations) */
ecd2a9
 	int (*getprio)(struct path *, char *);
ecd2a9
+	int (*freeprio)(struct prio * p);
ecd2a9
 };
ecd2a9
 
ecd2a9
 unsigned int get_prio_timeout(unsigned int default_timeout);
ecd2a9
@@ -57,6 +63,7 @@ void cleanup_prio (void);
ecd2a9
 struct prio * add_prio (char *);
ecd2a9
 struct prio * prio_lookup (char *);
ecd2a9
 int prio_getprio (struct prio *, struct path *);
ecd2a9
+int prio_init (struct prio *);
ecd2a9
 void prio_get (struct prio *, char *, char *);
ecd2a9
 void prio_put (struct prio *);
ecd2a9
 int prio_selected (struct prio *);
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/alua.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/alua.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/alua.c
ecd2a9
@@ -37,6 +37,12 @@ static const char * aas_string[] = {
ecd2a9
 	[AAS_TRANSITIONING]	= "transitioning between states",
ecd2a9
 };
ecd2a9
 
ecd2a9
+struct alua_context {
ecd2a9
+	int tpg_support;
ecd2a9
+	int tpg;
ecd2a9
+	int buflen;
ecd2a9
+};
ecd2a9
+
ecd2a9
 static const char *aas_print_string(int rc)
ecd2a9
 {
ecd2a9
 	rc &= 0x7f;
ecd2a9
@@ -51,25 +57,26 @@ static const char *aas_print_string(int
ecd2a9
 }
ecd2a9
 
ecd2a9
 int
ecd2a9
-get_alua_info(int fd)
ecd2a9
+get_alua_info(int fd, struct alua_context *ct)
ecd2a9
 {
ecd2a9
 	int	rc;
ecd2a9
-	int	tpg;
ecd2a9
 	int	aas;
ecd2a9
 
ecd2a9
-	rc = get_target_port_group_support(fd);
ecd2a9
-	if (rc < 0)
ecd2a9
-		return -ALUA_PRIO_TPGS_FAILED;
ecd2a9
-
ecd2a9
-	if (rc == TPGS_NONE)
ecd2a9
-		return -ALUA_PRIO_NOT_SUPPORTED;
ecd2a9
-
ecd2a9
-	tpg = get_target_port_group(fd);
ecd2a9
-	if (tpg < 0)
ecd2a9
-		return -ALUA_PRIO_RTPG_FAILED;
ecd2a9
+	if (ct->tpg_support <= 0 || ct->tpg < 0) {
ecd2a9
+		ct->tpg_support = get_target_port_group_support(fd);
ecd2a9
+		if (ct->tpg_support < 0)
ecd2a9
+			return -ALUA_PRIO_TPGS_FAILED;
ecd2a9
+
ecd2a9
+		if (ct->tpg_support == TPGS_NONE)
ecd2a9
+			return -ALUA_PRIO_NOT_SUPPORTED;
ecd2a9
+
ecd2a9
+		ct->tpg = get_target_port_group(fd, &ct->buflen);
ecd2a9
+		if (ct->tpg < 0)
ecd2a9
+			return -ALUA_PRIO_RTPG_FAILED;
ecd2a9
+	}
ecd2a9
 
ecd2a9
-	condlog(3, "reported target port group is %i", tpg);
ecd2a9
-	rc = get_asymmetric_access_state(fd, tpg);
ecd2a9
+	condlog(3, "reported target port group is %i", ct->tpg);
ecd2a9
+	rc = get_asymmetric_access_state(fd, ct->tpg, &ct->buflen);
ecd2a9
 	if (rc < 0)
ecd2a9
 		return -ALUA_PRIO_GETAAS_FAILED;
ecd2a9
 	aas = (rc & 0x0f);
ecd2a9
@@ -88,7 +95,7 @@ int getprio (struct path * pp, char * ar
ecd2a9
 	if (pp->fd < 0)
ecd2a9
 		return -ALUA_PRIO_NO_INFORMATION;
ecd2a9
 
ecd2a9
-	rc = get_alua_info(pp->fd);
ecd2a9
+	rc = get_alua_info(pp->fd, pp->prio.context);
ecd2a9
 	if (rc >= 0) {
ecd2a9
 		aas = (rc & 0x0f);
ecd2a9
 		priopath = (rc & 0x80);
ecd2a9
@@ -128,3 +135,28 @@ int getprio (struct path * pp, char * ar
ecd2a9
 	}
ecd2a9
 	return rc;
ecd2a9
 }
ecd2a9
+
ecd2a9
+int initprio(struct prio *p)
ecd2a9
+{
ecd2a9
+	if (!p->context) {
ecd2a9
+		struct alua_context *ct;
ecd2a9
+
ecd2a9
+		ct = malloc(sizeof(struct alua_context));
ecd2a9
+		if (!ct)
ecd2a9
+			return 1;
ecd2a9
+		p->context = ct;
ecd2a9
+	}
ecd2a9
+	memset(p->context, 0, sizeof(struct alua_context));
ecd2a9
+	return 0;
ecd2a9
+}
ecd2a9
+
ecd2a9
+
ecd2a9
+int freeprio(struct prio *p)
ecd2a9
+{
ecd2a9
+	if (p->context) {
ecd2a9
+		free(p->context);
ecd2a9
+		p->context = NULL;
ecd2a9
+	}
ecd2a9
+	return 0;
ecd2a9
+}
ecd2a9
+
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/alua_rtpg.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/alua_rtpg.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/alua_rtpg.c
ecd2a9
@@ -171,7 +171,7 @@ get_target_port_group_support(int fd)
ecd2a9
 }
ecd2a9
 
ecd2a9
 int
ecd2a9
-get_target_port_group(int fd)
ecd2a9
+get_target_port_group(int fd, int *buflen_ptr)
ecd2a9
 {
ecd2a9
 	unsigned char		*buf;
ecd2a9
 	struct vpd83_data *	vpd83;
ecd2a9
@@ -179,7 +179,12 @@ get_target_port_group(int fd)
ecd2a9
 	int			rc;
ecd2a9
 	int			buflen, scsi_buflen;
ecd2a9
 
ecd2a9
-	buflen = 128; /* Lets start from 128 */
ecd2a9
+	if (!buflen_ptr || *buflen_ptr == 0) {
ecd2a9
+		buflen = 128; /* Lets start from 128 */
ecd2a9
+		if (buflen_ptr)
ecd2a9
+			*buflen_ptr = 128;
ecd2a9
+	} else
ecd2a9
+		buflen = *buflen_ptr;
ecd2a9
 	buf = (unsigned char *)malloc(buflen);
ecd2a9
 	if (!buf) {
ecd2a9
 		PRINT_DEBUG("malloc failed: could not allocate"
ecd2a9
@@ -202,6 +207,8 @@ get_target_port_group(int fd)
ecd2a9
 			return -RTPG_RTPG_FAILED;
ecd2a9
 		}
ecd2a9
 		buflen = scsi_buflen;
ecd2a9
+		if (buflen_ptr)
ecd2a9
+			*buflen_ptr = buflen;
ecd2a9
 		memset(buf, 0, buflen);
ecd2a9
 		rc = do_inquiry(fd, 1, 0x83, buf, buflen);
ecd2a9
 		if (rc < 0)
ecd2a9
@@ -269,7 +276,7 @@ do_rtpg(int fd, void* resp, long resplen
ecd2a9
 }
ecd2a9
 
ecd2a9
 int
ecd2a9
-get_asymmetric_access_state(int fd, unsigned int tpg)
ecd2a9
+get_asymmetric_access_state(int fd, unsigned int tpg, int *buflen_ptr)
ecd2a9
 {
ecd2a9
 	unsigned char		*buf;
ecd2a9
 	struct rtpg_data *	tpgd;
ecd2a9
@@ -278,7 +285,12 @@ get_asymmetric_access_state(int fd, unsi
ecd2a9
 	int			buflen;
ecd2a9
 	uint32_t		scsi_buflen;
ecd2a9
 
ecd2a9
-	buflen = 128; /* Initial value from old code */
ecd2a9
+	if (!buflen_ptr || *buflen_ptr == 0) {
ecd2a9
+		buflen = 128; /* Initial value from old code */
ecd2a9
+		if (buflen_ptr)
ecd2a9
+			*buflen_ptr = 128;
ecd2a9
+	} else
ecd2a9
+		buflen = *buflen_ptr;
ecd2a9
 	buf = (unsigned char *)malloc(buflen);
ecd2a9
 	if (!buf) {
ecd2a9
 		PRINT_DEBUG ("malloc failed: could not allocate"
ecd2a9
@@ -299,6 +311,8 @@ get_asymmetric_access_state(int fd, unsi
ecd2a9
 			return -RTPG_RTPG_FAILED;
ecd2a9
 		}
ecd2a9
 		buflen = scsi_buflen;
ecd2a9
+		if (buflen_ptr)
ecd2a9
+			*buflen_ptr = buflen;
ecd2a9
 		memset(buf, 0, buflen);
ecd2a9
 		rc = do_rtpg(fd, buf, buflen);
ecd2a9
 		if (rc < 0)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/alua_rtpg.h
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/alua_rtpg.h
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/alua_rtpg.h
ecd2a9
@@ -23,8 +23,8 @@
ecd2a9
 #define RTPG_TPG_NOT_FOUND			4
ecd2a9
 
ecd2a9
 int get_target_port_group_support(int fd);
ecd2a9
-int get_target_port_group(int fd);
ecd2a9
-int get_asymmetric_access_state(int fd, unsigned int tpg);
ecd2a9
+int get_target_port_group(int fd, int *buflen_ptr);
ecd2a9
+int get_asymmetric_access_state(int fd, unsigned int tpg, int *buflen_ptr);
ecd2a9
 
ecd2a9
 #endif /* __RTPG_H__ */
ecd2a9
 
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/const.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/const.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/const.c
ecd2a9
@@ -1,8 +1,12 @@
ecd2a9
 #include <stdio.h>
ecd2a9
 
ecd2a9
 #include <prio.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 int getprio (struct path * pp, char * args)
ecd2a9
 {
ecd2a9
 	return 1;
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/datacore.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/datacore.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/datacore.c
ecd2a9
@@ -25,6 +25,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <prio.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 #define INQ_REPLY_LEN 255
ecd2a9
 #define INQ_CMD_CODE 0x12
ecd2a9
@@ -111,3 +112,5 @@ int getprio (struct path * pp, char * ar
ecd2a9
         return datacore_prio(pp->dev, pp->fd, args);
ecd2a9
 }
ecd2a9
 
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/def_func.h
ecd2a9
===================================================================
ecd2a9
--- /dev/null
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/def_func.h
ecd2a9
@@ -0,0 +1,11 @@
ecd2a9
+#ifndef _DEF_FUNC_H
ecd2a9
+#define _DEF_FUNC_H
ecd2a9
+
ecd2a9
+#include "prio.h"
ecd2a9
+
ecd2a9
+#define declare_nop_prio(name)						\
ecd2a9
+int name (struct prio *p)						\
ecd2a9
+{									\
ecd2a9
+	return 0;							\
ecd2a9
+}
ecd2a9
+#endif /* _DEF_FUNC_H */
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/emc.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/emc.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/emc.c
ecd2a9
@@ -6,6 +6,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <prio.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 #define INQUIRY_CMD     0x12
ecd2a9
 #define INQUIRY_CMDLEN  6
ecd2a9
@@ -85,3 +86,6 @@ int getprio (struct path * pp, char * ar
ecd2a9
 {
ecd2a9
 	return emc_clariion_prio(pp->dev, pp->fd);
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/hds.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/hds.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/hds.c
ecd2a9
@@ -76,6 +76,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <prio.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 #define INQ_REPLY_LEN 255
ecd2a9
 #define INQ_CMD_CODE 0x12
ecd2a9
@@ -170,3 +171,6 @@ int getprio (struct path * pp, char * ar
ecd2a9
 {
ecd2a9
 	return hds_modular_prio(pp->dev, pp->fd);
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/hp_sw.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/hp_sw.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/hp_sw.c
ecd2a9
@@ -16,6 +16,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <prio.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 #define TUR_CMD_LEN		6
ecd2a9
 #define SCSI_CHECK_CONDITION	0x2
ecd2a9
@@ -99,3 +100,6 @@ int getprio (struct path * pp, char * ar
ecd2a9
 {
ecd2a9
 	return hp_sw_prio(pp->dev, pp->fd);
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/iet.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/iet.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/iet.c
ecd2a9
@@ -9,6 +9,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <unistd.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 //
ecd2a9
 // This prioritizer suits iSCSI needs, makes it possible to prefer one path.
ecd2a9
@@ -141,3 +142,6 @@ int getprio(struct path * pp, char * arg
ecd2a9
 {
ecd2a9
 	return iet_prio(pp->dev, args);
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/ontap.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/ontap.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/ontap.c
ecd2a9
@@ -23,6 +23,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <prio.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 #define INQUIRY_CMD	0x12
ecd2a9
 #define INQUIRY_CMDLEN	6
ecd2a9
@@ -245,3 +246,6 @@ int getprio (struct path * pp, char * ar
ecd2a9
 {
ecd2a9
 	return ontap_prio(pp->dev, pp->fd);
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/random.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/random.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/random.c
ecd2a9
@@ -4,6 +4,7 @@
ecd2a9
 #include <time.h>
ecd2a9
 
ecd2a9
 #include <prio.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 int getprio (struct path * pp, char * args)
ecd2a9
 {
ecd2a9
@@ -13,3 +14,6 @@ int getprio (struct path * pp, char * ar
ecd2a9
 	srand((unsigned int)tv.tv_usec);
ecd2a9
 	return 1+(int) (10.0*rand()/(RAND_MAX+1.0));
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/rdac.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/rdac.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/rdac.c
ecd2a9
@@ -6,6 +6,7 @@
ecd2a9
 #include <debug.h>
ecd2a9
 #include <prio.h>
ecd2a9
 #include <structs.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 #define INQUIRY_CMD     0x12
ecd2a9
 #define INQUIRY_CMDLEN  6
ecd2a9
@@ -95,3 +96,6 @@ int getprio (struct path * pp, char * ar
ecd2a9
 {
ecd2a9
 	return rdac_prio(pp->dev, pp->fd);
ecd2a9
 }
ecd2a9
+
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/prioritizers/weightedpath.c
ecd2a9
+++ multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
ecd2a9
@@ -32,6 +32,7 @@
ecd2a9
 #include <memory.h>
ecd2a9
 #include <debug.h>
ecd2a9
 #include <regex.h>
ecd2a9
+#include "def_func.h"
ecd2a9
 
ecd2a9
 char *get_next_string(char **temp, char *split_char)
ecd2a9
 {
ecd2a9
@@ -104,3 +105,5 @@ int getprio(struct path *pp, char *args)
ecd2a9
 	return prio_path_weight(pp, args);
ecd2a9
 }
ecd2a9
 
ecd2a9
+declare_nop_prio(initprio)
ecd2a9
+declare_nop_prio(freeprio)
ecd2a9
Index: multipath-tools-130222/libmultipath/propsel.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/libmultipath/propsel.c
ecd2a9
+++ multipath-tools-130222/libmultipath/propsel.c
ecd2a9
@@ -401,10 +401,10 @@ detect_prio(struct path * pp)
ecd2a9
 
ecd2a9
 	if (get_target_port_group_support(pp->fd) <= 0)
ecd2a9
 		return;
ecd2a9
-	ret = get_target_port_group(pp->fd);
ecd2a9
+	ret = get_target_port_group(pp->fd, NULL);
ecd2a9
 	if (ret < 0)
ecd2a9
 		return;
ecd2a9
-	if (get_asymmetric_access_state(pp->fd, ret) < 0)
ecd2a9
+	if (get_asymmetric_access_state(pp->fd, ret, NULL) < 0)
ecd2a9
 		return;
ecd2a9
 	prio_get(p, PRIO_ALUA, DEFAULT_PRIO_ARGS);
ecd2a9
 }
ecd2a9
Index: multipath-tools-130222/multipathd/main.c
ecd2a9
===================================================================
ecd2a9
--- multipath-tools-130222.orig/multipathd/main.c
ecd2a9
+++ multipath-tools-130222/multipathd/main.c
ecd2a9
@@ -700,20 +700,23 @@ static int
ecd2a9
 uev_update_path (struct uevent *uev, struct vectors * vecs)
ecd2a9
 {
ecd2a9
 	int ro, retval = 0;
ecd2a9
+	struct path * pp;
ecd2a9
+
ecd2a9
+	pp = find_path_by_dev(vecs->pathvec, uev->kernel);
ecd2a9
+	if (!pp) {
ecd2a9
+		condlog(0, "%s: spurious uevent, path not found",
ecd2a9
+			uev->kernel);
ecd2a9
+		return 1;
ecd2a9
+	}
ecd2a9
+	/* reinit the prio values on change event, in case something is
ecd2a9
+	 * different */
ecd2a9
+	prio_init(&pp->prio);
ecd2a9
 
ecd2a9
 	ro = uevent_get_disk_ro(uev);
ecd2a9
 
ecd2a9
 	if (ro >= 0) {
ecd2a9
-		struct path * pp;
ecd2a9
-
ecd2a9
 		condlog(2, "%s: update path write_protect to '%d' (uevent)",
ecd2a9
 			uev->kernel, ro);
ecd2a9
-		pp = find_path_by_dev(vecs->pathvec, uev->kernel);
ecd2a9
-		if (!pp) {
ecd2a9
-			condlog(0, "%s: spurious uevent, path not found",
ecd2a9
-				uev->kernel);
ecd2a9
-			return 1;
ecd2a9
-		}
ecd2a9
 		if (pp->mpp) {
ecd2a9
 			retval = reload_map(vecs, pp->mpp, 0);
ecd2a9
 
ecd2a9
@@ -1218,6 +1221,11 @@ check_path (struct vectors * vecs, struc
ecd2a9
 		}
ecd2a9
 
ecd2a9
 		if(newstate == PATH_UP || newstate == PATH_GHOST){
ecd2a9
+		 	/*
ecd2a9
+			 * Reinitialize the prioritizer, in case something
ecd2a9
+		 	 * changed.
ecd2a9
+		 	 */
ecd2a9
+			prio_init(&pp->prio);
ecd2a9
 			if ( pp->mpp && pp->mpp->prflag ){
ecd2a9
 				/*
ecd2a9
 				 * Check Persistent Reservation.