4728c8
---
4728c8
 libmpathpersist/mpath_persist.c |   43 +++++++++++++++++++++++++---------------
4728c8
 libmpathpersist/mpath_persist.h |    4 ++-
4728c8
 2 files changed, 30 insertions(+), 17 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
4728c8
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
4728c8
@@ -440,7 +440,7 @@ int mpath_prout_reg(struct multipath *mp
4728c8
 		thread[i].param.rq_type = rq_type;
4728c8
 		thread[i].param.paramp = paramp;
4728c8
 		thread[i].param.noisy = noisy;
4728c8
-		thread[i].param.status = -1;
4728c8
+		thread[i].param.status = MPATH_PR_SKIP;
4728c8
 
4728c8
 		condlog (3, "THRED ID [%d] INFO]", i);
4728c8
 		condlog (3, "rq_servact=%d ", thread[i].param.rq_servact);
4728c8
@@ -476,14 +476,17 @@ int mpath_prout_reg(struct multipath *mp
4728c8
 			rc = pthread_create(&thread[count].id, &attr, mpath_prout_pthread_fn, (void *)(&thread[count].param));
4728c8
 			if (rc){
4728c8
 				condlog (0, "%s: failed to create thread %d", mpp->wwid, rc);
4728c8
+				thread[count].param.status = MPATH_PR_THREAD_ERROR;
4728c8
 			}
4728c8
 			count = count +1;
4728c8
 		}
4728c8
 	}
4728c8
 	for( i=0; i < active_pathcount ; i++){
4728c8
-		rc = pthread_join(thread[i].id, NULL);
4728c8
-		if (rc){
4728c8
-			condlog (0, "%s: Thread[%d] failed to join thread %d", mpp->wwid, i, rc);
4728c8
+		if (thread[i].param.status != MPATH_PR_THREAD_ERROR) {
4728c8
+			rc = pthread_join(thread[i].id, NULL);
4728c8
+			if (rc){
4728c8
+				condlog (0, "%s: Thread[%d] failed to join thread %d", mpp->wwid, i, rc);
4728c8
+			}
4728c8
 		}
4728c8
 		if (!rollback && (thread[i].param.status == MPATH_PR_RESERV_CONFLICT)){
4728c8
 			rollback = 1;
4728c8
@@ -502,23 +505,27 @@ int mpath_prout_reg(struct multipath *mp
4728c8
 	if (rollback && ((rq_servact == MPATH_PROUT_REG_SA) && sa_key != 0 )){
4728c8
 		condlog (3, "%s: ERROR: initiating pr out rollback", mpp->wwid);
4728c8
 		for( i=0 ; i < active_pathcount ; i++){
4728c8
-			if((thread[i].param.status == MPATH_PR_SUCCESS) &&
4728c8
-					((pp->state == PATH_UP) || (pp->state == PATH_GHOST))){
4728c8
+			if (thread[i].param.status == MPATH_PR_SUCCESS) {
4728c8
 				memcpy(&thread[i].param.paramp->key, &thread[i].param.paramp->sa_key, 8);
4728c8
 				memset(&thread[i].param.paramp->sa_key, 0, 8);
4728c8
 				thread[i].param.status = MPATH_PR_SUCCESS;
4728c8
 				rc = pthread_create(&thread[i].id, &attr, mpath_prout_pthread_fn, 
4728c8
-						(void *)(&thread[count].param));
4728c8
+						(void *)(&thread[i].param));
4728c8
 				if (rc){
4728c8
 					condlog (0, "%s: failed to create thread for rollback. %d",  mpp->wwid, rc);
4728c8
+					thread[i].param.status = MPATH_PR_THREAD_ERROR;
4728c8
 				}
4728c8
-			}
4728c8
+			} else
4728c8
+				thread[i].param.status = MPATH_PR_SKIP;
4728c8
 		}
4728c8
 		for(i=0; i < active_pathcount ; i++){
4728c8
-			rc = pthread_join(thread[i].id, NULL);
4728c8
-			if (rc){
4728c8
-				condlog (3, "%s: failed to join thread while rolling back %d",
4728c8
-						mpp->wwid, i);
4728c8
+			if (thread[i].param.status != MPATH_PR_SKIP &&
4728c8
+			    thread[i].param.status != MPATH_PR_THREAD_ERROR) {
4728c8
+				rc = pthread_join(thread[i].id, NULL);
4728c8
+				if (rc){
4728c8
+					condlog (3, "%s: failed to join thread while rolling back %d",
4728c8
+						 mpp->wwid, i);
4728c8
+				}
4728c8
 			}
4728c8
 		}
4728c8
 	}
4728c8
@@ -649,16 +656,20 @@ int mpath_prout_rel(struct multipath *mp
4728c8
 			condlog (3, "%s: sending pr out command to %s", mpp->wwid, pp->dev);
4728c8
 			rc = pthread_create (&thread[count].id, &attr, mpath_prout_pthread_fn,
4728c8
 					(void *) (&thread[count].param));
4728c8
-			if (rc)
4728c8
+			if (rc) {
4728c8
 				condlog (0, "%s: failed to create thread. %d",  mpp->wwid, rc);
4728c8
+				thread[count].param.status = MPATH_PR_THREAD_ERROR;
4728c8
+			}
4728c8
 			count = count + 1;
4728c8
 		}
4728c8
 	}
4728c8
 	pthread_attr_destroy (&attr);
4728c8
 	for (i = 0; i < active_pathcount; i++){
4728c8
-		rc = pthread_join (thread[i].id, NULL);
4728c8
-		if (rc){
4728c8
-			condlog (1, "%s: failed to join thread.  %d",  mpp->wwid,  rc);
4728c8
+		if (thread[i].param.status != MPATH_PR_THREAD_ERROR) {
4728c8
+			rc = pthread_join (thread[i].id, NULL);
4728c8
+			if (rc){
4728c8
+				condlog (1, "%s: failed to join thread.  %d",  mpp->wwid,  rc);
4728c8
+			}
4728c8
 		}
4728c8
 	}
4728c8
 
4728c8
Index: multipath-tools-130222/libmpathpersist/mpath_persist.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.h
4728c8
+++ multipath-tools-130222/libmpathpersist/mpath_persist.h
4728c8
@@ -43,6 +43,7 @@ extern "C" {
4728c8
 
4728c8
 
4728c8
 /* PR RETURN_STATUS */
4728c8
+#define MPATH_PR_SKIP			-1  /* skipping this path */
4728c8
 #define MPATH_PR_SUCCESS 		0
4728c8
 #define MPATH_PR_SYNTAX_ERROR		1   /*  syntax error or invalid parameter */
4728c8
 					    /* status for check condition */
4728c8
@@ -59,7 +60,8 @@ extern "C" {
4728c8
 #define MPATH_PR_RESERV_CONFLICT	11  /* Reservation conflict on the device */
4728c8
 #define MPATH_PR_FILE_ERROR		12  /* file (device node) problems(e.g. not found)*/
4728c8
 #define MPATH_PR_DMMP_ERROR		13  /* DMMP related error.(e.g Error in getting dm info */
4728c8
-#define MPATH_PR_OTHER			14  /*other error/warning has occurred(transport
4728c8
+#define MPATH_PR_THREAD_ERROR		14  /* pthreads error (e.g. unable to create new thread) */
4728c8
+#define MPATH_PR_OTHER			15  /*other error/warning has occurred(transport
4728c8
 					      or driver error) */
4728c8
 
4728c8
 /* PR MASK */