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

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