Blame SOURCES/0266-RHBZ-1696817-fix-emc-checker.patch

4728c8
---
4728c8
 libmultipath/checkers.c              |   29 +++++++++++++++++++++++++++--
4728c8
 libmultipath/checkers.h              |    2 ++
4728c8
 libmultipath/checkers/cciss_tur.c    |    5 +++++
4728c8
 libmultipath/checkers/directio.c     |    5 +++++
4728c8
 libmultipath/checkers/emc_clariion.c |    7 +++++++
4728c8
 libmultipath/checkers/hp_sw.c        |    5 +++++
4728c8
 libmultipath/checkers/rdac.c         |    5 +++++
4728c8
 libmultipath/checkers/readsector0.c  |    5 +++++
4728c8
 libmultipath/checkers/tur.c          |    5 +++++
4728c8
 libmultipath/discovery.c             |    2 ++
4728c8
 10 files changed, 68 insertions(+), 2 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/checkers.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers.c
4728c8
@@ -132,6 +132,13 @@ struct checker * add_checker (char * nam
4728c8
 	if (!c->init)
4728c8
 		goto out;
4728c8
 
4728c8
+	c->mp_init = (int (*)(struct checker *)) dlsym(c->handle, "libcheck_mp_init");
4728c8
+	errstr = dlerror();
4728c8
+	if (errstr != NULL)
4728c8
+		condlog(0, "A dynamic linking error occurred: (%s)", errstr);
4728c8
+	if (!c->mp_init)
4728c8
+		goto out;
4728c8
+
4728c8
 	c->free = (void (*)(struct checker *)) dlsym(c->handle, "libcheck_free");
4728c8
 	errstr = dlerror();
4728c8
 	if (errstr != NULL)
4728c8
@@ -189,8 +196,25 @@ int checker_init (struct checker * c, vo
4728c8
 	if (!c)
4728c8
 		return 1;
4728c8
 	c->mpcontext = mpctxt_addr;
4728c8
-	if (c->init)
4728c8
-		return c->init(c);
4728c8
+	if (c->init && c->init(c) != 0)
4728c8
+		return 1;
4728c8
+	if (mpctxt_addr && *mpctxt_addr == NULL && c->mp_init &&
4728c8
+	    c->mp_init(c) != 0) /* for now, continue even if mp_init fails */
4728c8
+		c->mpcontext = NULL;
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
+int checker_mp_init(struct checker * c, void ** mpctxt_addr)
4728c8
+{
4728c8
+	if (!c)
4728c8
+		return 1;
4728c8
+	if (c->mp_init && !c->mpcontext && mpctxt_addr) {
4728c8
+		c->mpcontext = mpctxt_addr;
4728c8
+		if (c->mp_init(c) != 0) {
4728c8
+			c->mpcontext = NULL;
4728c8
+			return 1;
4728c8
+		}
4728c8
+	}
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
@@ -277,6 +301,7 @@ void checker_get (struct checker * dst,
4728c8
 	strncpy(dst->message, src->message, CHECKER_MSG_LEN);
4728c8
 	dst->check = src->check;
4728c8
 	dst->init = src->init;
4728c8
+	dst->mp_init = src->mp_init;
4728c8
 	dst->free = src->free;
4728c8
 	dst->handle = NULL;
4728c8
 	src->refcount++;
4728c8
Index: multipath-tools-130222/libmultipath/checkers.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers.h
4728c8
+++ multipath-tools-130222/libmultipath/checkers.h
4728c8
@@ -107,6 +107,7 @@ struct checker {
4728c8
 						you want to stuff data in. */
4728c8
 	int (*check)(struct checker *);
4728c8
 	int (*init)(struct checker *);       /* to allocate the context */
4728c8
+	int (*mp_init)(struct checker *);    /* to allocate the mpcontext */
4728c8
 	void (*free)(struct checker *);      /* to free the context */
4728c8
 };
4728c8
 
4728c8
@@ -118,6 +119,7 @@ void cleanup_checkers (void);
4728c8
 struct checker * add_checker (char *);
4728c8
 struct checker * checker_lookup (char *);
4728c8
 int checker_init (struct checker *, void **);
4728c8
+int checker_mp_init (struct checker *, void **);
4728c8
 void checker_put (struct checker *);
4728c8
 void checker_reset (struct checker *);
4728c8
 void checker_set_sync (struct checker *);
4728c8
Index: multipath-tools-130222/libmultipath/discovery.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/discovery.c
4728c8
+++ multipath-tools-130222/libmultipath/discovery.c
4728c8
@@ -1217,6 +1217,8 @@ get_state (struct path * pp, int daemon,
4728c8
 			return PATH_UNCHECKED;
4728c8
 		}
4728c8
 	}
4728c8
+	if (pp->mpp && !c->mpcontext)
4728c8
+		checker_mp_init(c, &pp->mpp->mpcontext);
4728c8
 	checker_clear_message(c);
4728c8
 	if (daemon) {
4728c8
 		if (conf->force_sync == 0)
4728c8
Index: multipath-tools-130222/libmultipath/checkers/cciss_tur.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/cciss_tur.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/cciss_tur.c
4728c8
@@ -58,6 +58,11 @@ int libcheck_init (struct checker * c)
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+int libcheck_mp_init (struct checker * c)
4728c8
+{
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 void libcheck_free (struct checker * c)
4728c8
 {
4728c8
 	return;
4728c8
Index: multipath-tools-130222/libmultipath/checkers/directio.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/directio.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/directio.c
4728c8
@@ -94,6 +94,11 @@ out:
4728c8
 	return 1;
4728c8
 }
4728c8
 
4728c8
+int libcheck_mp_init(struct checker * c)
4728c8
+{
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 void libcheck_free (struct checker * c)
4728c8
 {
4728c8
 	struct directio_context * ct = (struct directio_context *)c->context;
4728c8
Index: multipath-tools-130222/libmultipath/checkers/emc_clariion.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/emc_clariion.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/emc_clariion.c
4728c8
@@ -73,11 +73,18 @@ int libcheck_init (struct checker * c)
4728c8
 		return 1;
4728c8
 	((struct emc_clariion_checker_path_context *)c->context)->wwn_set = 0;
4728c8
 
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
+int libcheck_mp_init (struct checker * c)
4728c8
+{
4728c8
 	/*
4728c8
 	 * Allocate and initialize the multi-path global context.
4728c8
 	 */
4728c8
 	if (c->mpcontext && *c->mpcontext == NULL) {
4728c8
 		void * mpctxt = malloc(sizeof(int));
4728c8
+		if (!mpctxt)
4728c8
+			return 1;
4728c8
 		*c->mpcontext = mpctxt;
4728c8
 		CLR_INACTIVE_SNAP(c);
4728c8
 	}
4728c8
Index: multipath-tools-130222/libmultipath/checkers/hp_sw.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/hp_sw.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/hp_sw.c
4728c8
@@ -39,6 +39,11 @@ int libcheck_init (struct checker * c)
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+int libcheck_mp_init(struct checker * c)
4728c8
+{
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 void libcheck_free (struct checker * c)
4728c8
 {
4728c8
 	return;
4728c8
Index: multipath-tools-130222/libmultipath/checkers/rdac.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/rdac.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/rdac.c
4728c8
@@ -134,6 +134,11 @@ out:
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+int libcheck_mp_init(struct checker * c)
4728c8
+{
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 void libcheck_free (struct checker * c)
4728c8
 {
4728c8
 	return;
4728c8
Index: multipath-tools-130222/libmultipath/checkers/readsector0.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/readsector0.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/readsector0.c
4728c8
@@ -18,6 +18,11 @@ int libcheck_init (struct checker * c)
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+int libcheck_mp_init(struct checker * c)
4728c8
+{
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 void libcheck_free (struct checker * c)
4728c8
 {
4728c8
 	return;
4728c8
Index: multipath-tools-130222/libmultipath/checkers/tur.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/checkers/tur.c
4728c8
+++ multipath-tools-130222/libmultipath/checkers/tur.c
4728c8
@@ -158,6 +158,11 @@ int libcheck_init (struct checker * c)
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
+int libcheck_mp_init(struct checker * c)
4728c8
+{
4728c8
+	return 0;
4728c8
+}
4728c8
+
4728c8
 void cleanup_context(struct tur_checker_context *ct)
4728c8
 {
4728c8
 	pthread_mutex_destroy(&ct->lock);