Blame SOURCES/0058-multipathd-cleanup-logging-for-marginal-paths.patch

05be62
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
05be62
From: Benjamin Marzinski <bmarzins@redhat.com>
05be62
Date: Mon, 18 Jan 2021 22:46:04 -0600
05be62
Subject: [PATCH] multipathd: cleanup logging for marginal paths
05be62
05be62
io_err_stat logged at level 2 whenever it enqueued a path to check,
05be62
which could happen multiple times while a path was marginal.  On the
05be62
other hand if marginal_pathgroups wasn't set, multipathd didn't log when
05be62
paths were set to marginal. Now io_err_stat only logs at level 2 when
05be62
something unexpected happens, but multipathd will always log when a
05be62
path switches its marginal state.
05be62
05be62
This patch also fixes an issue where paths in the delayed state could
05be62
get set to the pending state if they could not be checked in time.
05be62
Aside from going against the idea the paths should not be set to pending
05be62
if they already have a valid state, this caused multipathd to log a
05be62
message whenever the path state switched to from delayed to pending and
05be62
then back.
05be62
05be62
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
05be62
Reviewed-by: Martin Wilck <mwilck@suse.com>
05be62
---
05be62
 libmultipath/io_err_stat.c |  7 +++----
05be62
 multipathd/main.c          | 20 +++++++++++++-------
05be62
 2 files changed, 16 insertions(+), 11 deletions(-)
05be62
05be62
diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
05be62
index bf1d3910..ee711f7f 100644
05be62
--- a/libmultipath/io_err_stat.c
05be62
+++ b/libmultipath/io_err_stat.c
05be62
@@ -254,7 +254,7 @@ static int enqueue_io_err_stat_by_path(struct path *path)
05be62
 	vector_set_slot(io_err_pathvec, p);
05be62
 	pthread_mutex_unlock(&io_err_pathvec_lock);
05be62
 
05be62
-	io_err_stat_log(2, "%s: enqueue path %s to check",
05be62
+	io_err_stat_log(3, "%s: enqueue path %s to check",
05be62
 			path->mpp->alias, path->dev);
05be62
 	return 0;
05be62
 
05be62
@@ -353,7 +353,7 @@ int need_io_err_check(struct path *pp)
05be62
 	if (uatomic_read(&io_err_thread_running) == 0)
05be62
 		return 0;
05be62
 	if (count_active_paths(pp->mpp) <= 0) {
05be62
-		io_err_stat_log(2, "%s: recover path early", pp->dev);
05be62
+		io_err_stat_log(2, "%s: no paths. recovering early", pp->dev);
05be62
 		goto recover;
05be62
 	}
05be62
 	if (pp->io_err_pathfail_cnt != PATH_IO_ERR_WAITING_TO_CHECK)
05be62
@@ -371,8 +371,7 @@ int need_io_err_check(struct path *pp)
05be62
 		 * Or else,  return 1 to set path state to PATH_SHAKY
05be62
 		 */
05be62
 		if (r == 1) {
05be62
-			io_err_stat_log(3, "%s: enqueue fails, to recover",
05be62
-					pp->dev);
05be62
+			io_err_stat_log(2, "%s: enqueue failed. recovering early", pp->dev);
05be62
 			goto recover;
05be62
 		} else
05be62
 			pp->io_err_pathfail_cnt = PATH_IO_ERR_IN_CHECKING;
05be62
diff --git a/multipathd/main.c b/multipathd/main.c
05be62
index 1d0579e9..cc1aeea2 100644
05be62
--- a/multipathd/main.c
05be62
+++ b/multipathd/main.c
05be62
@@ -2041,8 +2041,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
05be62
 		pathinfo(pp, conf, 0);
05be62
 		pthread_cleanup_pop(1);
05be62
 		return 1;
05be62
-	} else if ((newstate != PATH_UP && newstate != PATH_GHOST) &&
05be62
-			(pp->state == PATH_DELAYED)) {
05be62
+	} else if ((newstate != PATH_UP && newstate != PATH_GHOST &&
05be62
+		    newstate != PATH_PENDING) && (pp->state == PATH_DELAYED)) {
05be62
 		/* If path state become failed again cancel path delay state */
05be62
 		pp->state = newstate;
05be62
 		return 1;
05be62
@@ -2104,8 +2104,9 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
05be62
 	if ((newstate == PATH_UP || newstate == PATH_GHOST) &&
05be62
 	    (san_path_check_enabled(pp->mpp) ||
05be62
 	     marginal_path_check_enabled(pp->mpp))) {
05be62
-		int was_marginal = pp->marginal;
05be62
 		if (should_skip_path(pp)) {
05be62
+			if (!pp->marginal && pp->state != PATH_DELAYED)
05be62
+				condlog(2, "%s: path is now marginal", pp->dev);
05be62
 			if (!marginal_pathgroups) {
05be62
 				if (marginal_path_check_enabled(pp->mpp))
05be62
 					/* to reschedule as soon as possible,
05be62
@@ -2115,13 +2116,18 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
05be62
 				pp->state = PATH_DELAYED;
05be62
 				return 1;
05be62
 			}
05be62
-			if (!was_marginal) {
05be62
+			if (!pp->marginal) {
05be62
 				pp->marginal = 1;
05be62
 				marginal_changed = 1;
05be62
 			}
05be62
-		} else if (marginal_pathgroups && was_marginal) {
05be62
-			pp->marginal = 0;
05be62
-			marginal_changed = 1;
05be62
+		} else {
05be62
+			if (pp->marginal || pp->state == PATH_DELAYED)
05be62
+				condlog(2, "%s: path is no longer marginal",
05be62
+					pp->dev);
05be62
+			if (marginal_pathgroups && pp->marginal) {
05be62
+				pp->marginal = 0;
05be62
+				marginal_changed = 1;
05be62
+			}
05be62
 		}
05be62
 	}
05be62
 
05be62
-- 
05be62
2.17.2
05be62