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

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