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

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