Blame SOURCES/0154-UPBZ-1291406-disable-reinstate.patch

4728c8
---
4728c8
 libmultipath/propsel.c |   20 ++++++++++++++++----
4728c8
 libmultipath/structs.h |    1 +
4728c8
 multipathd/main.c      |   37 ++++++++++++++++++++++++++-----------
4728c8
 3 files changed, 43 insertions(+), 15 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/propsel.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/propsel.c
4728c8
+++ multipath-tools-130222/libmultipath/propsel.c
4728c8
@@ -398,9 +398,11 @@ detect_prio(struct path * pp)
4728c8
 {
4728c8
 	int ret;
4728c8
 	struct prio *p = &pp->prio;
4728c8
+	int tpgs = 0;
4728c8
 
4728c8
-	if (get_target_port_group_support(pp->fd) <= 0)
4728c8
+	if ((tpgs = get_target_port_group_support(pp->fd)) <= 0)
4728c8
 		return;
4728c8
+	pp->tpgs = tpgs;
4728c8
 	ret = get_target_port_group(pp->fd, NULL);
4728c8
 	if (ret < 0)
4728c8
 		return;
4728c8
@@ -432,7 +434,7 @@ select_prio (struct path * pp)
4728c8
 			pp->dev, prio_name(p));
4728c8
 		condlog(3, "%s: prio args = %s (LUN setting)",
4728c8
 			pp->dev, prio_args(p));
4728c8
-		return 0;
4728c8
+		goto out;
4728c8
 	}
4728c8
 
4728c8
 	if (pp->hwe && pp->hwe->prio_name) {
4728c8
@@ -441,7 +443,7 @@ select_prio (struct path * pp)
4728c8
 			pp->dev, pp->hwe->prio_name);
4728c8
 		condlog(3, "%s: prio args = %s (controller setting)",
4728c8
 			pp->dev, pp->hwe->prio_args);
4728c8
-		return 0;
4728c8
+		goto out;
4728c8
 	}
4728c8
 	if (conf->prio_name) {
4728c8
 		prio_get(p, conf->prio_name, conf->prio_args);
4728c8
@@ -449,13 +451,23 @@ select_prio (struct path * pp)
4728c8
 			pp->dev, conf->prio_name);
4728c8
 		condlog(3, "%s: prio args = %s (config file default)",
4728c8
 			pp->dev, conf->prio_args);
4728c8
-		return 0;
4728c8
+		goto out;
4728c8
 	}
4728c8
 	prio_get(p, DEFAULT_PRIO, DEFAULT_PRIO_ARGS);
4728c8
 	condlog(3, "%s: prio = %s (internal default)",
4728c8
 		pp->dev, DEFAULT_PRIO);
4728c8
 	condlog(3, "%s: prio args = %s (internal default)",
4728c8
 		pp->dev, DEFAULT_PRIO_ARGS);
4728c8
+out:
4728c8
+	/*
4728c8
+ 	 * fetch tpgs mode for alua
4728c8
+ 	 */
4728c8
+	if (!strncmp(prio_name(p), PRIO_ALUA, PRIO_NAME_LEN)) {
4728c8
+		int tpgs = 0;
4728c8
+		if (!pp->tpgs &&
4728c8
+		    (tpgs = get_target_port_group_support(pp->fd)) >= 0)
4728c8
+			pp->tpgs = tpgs;
4728c8
+	}
4728c8
 	return 0;
4728c8
 }
4728c8
 
4728c8
Index: multipath-tools-130222/libmultipath/structs.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/structs.h
4728c8
+++ multipath-tools-130222/libmultipath/structs.h
4728c8
@@ -193,6 +193,7 @@ struct path {
4728c8
 	int detect_prio;
4728c8
 	int watch_checks;
4728c8
 	int wait_checks;
4728c8
+	int tpgs;
4728c8
 	char * uid_attribute;
4728c8
 	struct prio prio;
4728c8
 	char * prio_args;
4728c8
Index: multipath-tools-130222/multipathd/main.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/multipathd/main.c
4728c8
+++ multipath-tools-130222/multipathd/main.c
4728c8
@@ -19,6 +19,7 @@
4728c8
 #include <libudev.h>
4728c8
 #include <semaphore.h>
4728c8
 #include <mpath_persist.h>
4728c8
+#include "prioritizers/alua_rtpg.h"
4728c8
 
4728c8
 /*
4728c8
  * libcheckers
4728c8
@@ -1248,6 +1249,7 @@ check_path (struct vectors * vecs, struc
4728c8
 	int newstate;
4728c8
 	int new_path_up = 0;
4728c8
 	int chkr_new_path_up = 0;
4728c8
+	int disable_reinstate = 0;
4728c8
 	int oldchkrstate = pp->chkrstate;
4728c8
 
4728c8
 	if (!pp->mpp && (pp->missing_udev_info != INFO_MISSING ||
4728c8
@@ -1312,6 +1314,16 @@ check_path (struct vectors * vecs, struc
4728c8
 			pp->wait_checks = 0;
4728c8
 	}
4728c8
 
4728c8
+	/*
4728c8
+	 * don't reinstate failed path, if its in stand-by
4728c8
+	 * and if target supports only implicit tpgs mode.
4728c8
+	 * this will prevent unnecessary i/o by dm on stand-by
4728c8
+	 * paths if there are no other active paths in map.
4728c8
+	 */
4728c8
+	disable_reinstate = (newstate == PATH_GHOST &&
4728c8
+			    pp->mpp->nr_active == 0 &&
4728c8
+			    pp->tpgs == TPGS_IMPLICIT) ? 1 : 0;
4728c8
+
4728c8
 	pp->chkrstate = newstate;
4728c8
 	if (newstate != pp->state) {
4728c8
 		int oldstate = pp->state;
4728c8
@@ -1367,15 +1379,17 @@ check_path (struct vectors * vecs, struc
4728c8
 		/*
4728c8
 		 * reinstate this path
4728c8
 		 */
4728c8
-		if (oldstate != PATH_UP &&
4728c8
-		    oldstate != PATH_GHOST) {
4728c8
-			if (pp->mpp->delay_watch_checks > 0)
4728c8
-				pp->watch_checks = pp->mpp->delay_watch_checks;
4728c8
-			reinstate_path(pp, 1);
4728c8
-		} else {
4728c8
-			if (pp->watch_checks > 0)
4728c8
-				pp->watch_checks--;
4728c8
-			reinstate_path(pp, 0);
4728c8
+		if (!disable_reinstate) {
4728c8
+			if (oldstate != PATH_UP &&
4728c8
+			    oldstate != PATH_GHOST) {
4728c8
+				if (pp->mpp->delay_watch_checks > 0)
4728c8
+					pp->watch_checks = pp->mpp->delay_watch_checks;
4728c8
+				reinstate_path(pp, 1);
4728c8
+			} else {
4728c8
+				if (pp->watch_checks > 0)
4728c8
+					pp->watch_checks--;
4728c8
+				reinstate_path(pp, 0);
4728c8
+			}
4728c8
 		}
4728c8
 		new_path_up = 1;
4728c8
 
4728c8
@@ -1390,8 +1404,9 @@ check_path (struct vectors * vecs, struc
4728c8
 			enable_group(pp);
4728c8
 	}
4728c8
 	else if (newstate == PATH_UP || newstate == PATH_GHOST) {
4728c8
-		if (pp->dmstate == PSTATE_FAILED ||
4728c8
-		    pp->dmstate == PSTATE_UNDEF) {
4728c8
+		if ((pp->dmstate == PSTATE_FAILED ||
4728c8
+		    pp->dmstate == PSTATE_UNDEF) &&
4728c8
+		    !disable_reinstate) {
4728c8
 			/* Clear IO errors */
4728c8
 			reinstate_path(pp, 0);
4728c8
 		} else {