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

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