Blame SOURCES/0069-UPBZ-1033791-improve-rdac-checker.patch

f20720
---
f20720
 libmultipath/checkers/rdac.c |   91 ++++++++++++++++++++++++++++++++++++++-----
f20720
 libmultipath/discovery.c     |    2 
f20720
 2 files changed, 81 insertions(+), 12 deletions(-)
f20720
f20720
Index: multipath-tools-130222/libmultipath/checkers/rdac.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/checkers/rdac.c
f20720
+++ multipath-tools-130222/libmultipath/checkers/rdac.c
f20720
@@ -34,6 +34,18 @@
f20720
 #define MSG_RDAC_UP    "rdac checker reports path is up"
f20720
 #define MSG_RDAC_DOWN  "rdac checker reports path is down"
f20720
 #define MSG_RDAC_GHOST "rdac checker reports path is ghost"
f20720
+#define MSG_RDAC_DOWN_TYPE(STR) MSG_RDAC_DOWN": "STR
f20720
+
f20720
+#define RTPG_UNAVAILABLE	0x3
f20720
+#define RTPG_OFFLINE		0xE
f20720
+#define RTPG_TRANSITIONING	0xF
f20720
+
f20720
+#define RTPG_UNAVAIL_NON_RESPONSIVE	0x2
f20720
+#define RTPG_UNAVAIL_IN_RESET		0x3
f20720
+#define RTPG_UNAVAIL_CFW_DL1		0x4
f20720
+#define RTPG_UNAVAIL_CFW_DL2		0x5
f20720
+#define RTPG_UNAVAIL_QUIESCED		0x6
f20720
+#define RTPG_UNAVAIL_SERVICE_MODE	0x7
f20720
 
f20720
 struct control_mode_page {
f20720
 	unsigned char header[8];
f20720
@@ -199,22 +211,64 @@ struct volume_access_inq
f20720
 	char PQ_PDT;
f20720
 	char dontcare0[7];
f20720
 	char avtcvp;
f20720
-	char dontcare1;
f20720
-	char asym_access_state_cur;
f20720
+	char vol_ppp;
f20720
+	char aas_cur;
f20720
 	char vendor_specific_cur;
f20720
-	char dontcare2[36];
f20720
+	char aas_alt;
f20720
+	char vendor_specific_alt;
f20720
+	char dontcare1[34];
f20720
 };
f20720
 
f20720
+const char
f20720
+*checker_msg_string(struct volume_access_inq *inq)
f20720
+{
f20720
+	/* lun not connected */
f20720
+	if (((inq->PQ_PDT & 0xE0) == 0x20) || (inq->PQ_PDT & 0x7f))
f20720
+		return MSG_RDAC_DOWN_TYPE("lun not connected");
f20720
+
f20720
+	/* if no tpg data is available, give the generic path down message */
f20720
+	if (!(inq->avtcvp & 0x10))
f20720
+		return MSG_RDAC_DOWN;
f20720
+
f20720
+	/* controller is booting up */
f20720
+	if (((inq->aas_cur & 0x0F) == RTPG_TRANSITIONING) &&
f20720
+		(inq->aas_alt & 0x0F) != RTPG_TRANSITIONING)
f20720
+		return MSG_RDAC_DOWN_TYPE("ctlr is in startup sequence");
f20720
+
f20720
+	/* if not unavailable, give generic message */
f20720
+	if ((inq->aas_cur & 0x0F) != RTPG_UNAVAILABLE)
f20720
+		return MSG_RDAC_DOWN;
f20720
+
f20720
+	/* target port group unavailable */
f20720
+	switch (inq->vendor_specific_cur) {
f20720
+	case RTPG_UNAVAIL_NON_RESPONSIVE:
f20720
+		return MSG_RDAC_DOWN_TYPE("non-responsive to queries");
f20720
+	case RTPG_UNAVAIL_IN_RESET:
f20720
+		return MSG_RDAC_DOWN_TYPE("ctlr held in reset");
f20720
+	case RTPG_UNAVAIL_CFW_DL1:
f20720
+	case RTPG_UNAVAIL_CFW_DL2:
f20720
+		return MSG_RDAC_DOWN_TYPE("ctlr firmware downloading");
f20720
+	case RTPG_UNAVAIL_QUIESCED:
f20720
+		return MSG_RDAC_DOWN_TYPE("ctlr quiesced by admin request");
f20720
+	case RTPG_UNAVAIL_SERVICE_MODE:
f20720
+		return MSG_RDAC_DOWN_TYPE("ctlr is in service mode");
f20720
+	default:
f20720
+		return MSG_RDAC_DOWN_TYPE("ctlr is unavailable");
f20720
+	}
f20720
+}
f20720
+
f20720
 extern int
f20720
 libcheck_check (struct checker * c)
f20720
 {
f20720
 	struct volume_access_inq inq;
f20720
-	int ret;
f20720
+	int ret, inqfail;
f20720
 
f20720
+	inqfail = 0;
f20720
 	memset(&inq, 0, sizeof(struct volume_access_inq));
f20720
 	if (0 != do_inq(c->fd, 0xC9, &inq, sizeof(struct volume_access_inq),
f20720
 			c->timeout)) {
f20720
 		ret = PATH_DOWN;
f20720
+		inqfail = 1;
f20720
 		goto done;
f20720
 	} else if (((inq.PQ_PDT & 0xE0) == 0x20) || (inq.PQ_PDT & 0x7f)) {
f20720
 		/* LUN not connected*/
f20720
@@ -222,11 +276,27 @@ libcheck_check (struct checker * c)
f20720
 		goto done;
f20720
 	}
f20720
 
f20720
-	/* check if controller is reporting asymmetric access state of unavailable */
f20720
-	if ((inq.avtcvp & 0x10) &&
f20720
-	    ((inq.asym_access_state_cur & 0x0F) == 0x3)) {
f20720
-		ret = PATH_DOWN;
f20720
-		goto done;
f20720
+	/* If TPGDE bit set, evaluate TPG information */
f20720
+	if ((inq.avtcvp & 0x10)) {
f20720
+		switch (inq.aas_cur & 0x0F) {
f20720
+		/* Never use the path if it reports unavailable */
f20720
+		case RTPG_UNAVAILABLE:
f20720
+			ret = PATH_DOWN;
f20720
+			goto done;
f20720
+		/*
f20720
+		 * If both controllers report transitioning, it
f20720
+		 * means mode select or STPG is being processed.
f20720
+		 *
f20720
+		 * If this controller alone is transitioning, it's
f20720
+		 * booting and we shouldn't use it yet.
f20720
+		 */
f20720
+		case RTPG_TRANSITIONING:
f20720
+			if ((inq.aas_alt & 0xF) != RTPG_TRANSITIONING) {
f20720
+				ret = PATH_DOWN;
f20720
+				goto done;
f20720
+			}
f20720
+			break;
f20720
+		}
f20720
 	}
f20720
 
f20720
 	/* If owner set or ioship mode is enabled return PATH_UP always */
f20720
@@ -238,7 +308,8 @@ libcheck_check (struct checker * c)
f20720
 done:
f20720
 	switch (ret) {
f20720
 	case PATH_DOWN:
f20720
-		MSG(c, MSG_RDAC_DOWN);
f20720
+		MSG(c, (inqfail) ? MSG_RDAC_DOWN_TYPE("inquiry failed") :
f20720
+			checker_msg_string(&inq));
f20720
 		break;
f20720
 	case PATH_UP:
f20720
 		MSG(c, MSG_RDAC_UP);
f20720
Index: multipath-tools-130222/libmultipath/discovery.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/discovery.c
f20720
+++ multipath-tools-130222/libmultipath/discovery.c
f20720
@@ -1116,8 +1116,6 @@ pathinfo (struct path *pp, vector hwtabl
f20720
 			if (!strlen(pp->wwid))
f20720
 				get_uid(pp);
f20720
 			get_prio(pp);
f20720
-		} else {
f20720
-			pp->priority = PRIO_UNDEF;
f20720
 		}
f20720
 	}
f20720