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

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