Blame SOURCES/0216-RHBZ-1448562-fix-reserve.patch

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