From: Mike Christie <[email-masked]>

If there are only bypassed PGs available then we do not want
to retry right away. If for example the controller was getting
reset or there was a fw upgrade going on and that was the reason
for the bypass, then retrying right away is going to cause a flood of
log messages and retries for what could be a longish time (more than
a couple seconds and possible up to several minutes).

For the case where the only PGs are ones that are bypassed this
patch will have dm-multipath delay the pg init by setting the
pg_init_delay_retry flag.

Signed-off-by: Mike Christie <[email-masked]>
Acked-by: Mike Snitzer <[email-masked]>

---
 drivers/md/dm-mpath.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: linux-3.4/drivers/md/dm-mpath.c
===================================================================
--- linux-3.4.orig/drivers/md/dm-mpath.c
+++ linux-3.4/drivers/md/dm-mpath.c
@@ -329,14 +329,18 @@ static void __choose_pgpath(struct multi
 	/*
 	 * Loop through priority groups until we find a valid path.
 	 * First time we skip PGs marked 'bypassed'.
-	 * Second time we only try the ones we skipped.
+	 * Second time we only try the ones we skipped, but will set
+	 * pg_init_delay_retry so we do not hammer controllers.
 	 */
 	do {
 		list_for_each_entry(pg, &m->priority_groups, list) {
 			if (pg->bypassed == bypassed)
 				continue;
-			if (!__choose_path_in_pg(m, pg, nr_bytes))
+			if (!__choose_path_in_pg(m, pg, nr_bytes)) {
+				if (!bypassed)
+					m->pg_init_delay_retry = 1;
 				return;
+			}
 		}
 	} while (bypassed--);