dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Martin Wilck <mwilck@suse.com>
Subject: [PATCH 09/12] multipathd: move recovery mode code to function
Date: Thu,  7 Dec 2017 12:49:03 -0600	[thread overview]
Message-ID: <1512672546-12785-10-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1512672546-12785-1-git-send-email-bmarzins@redhat.com>

Instead of having multiple functions all running slightly different
code to move a multipath device to recovery mode, there is now
an enter_recovery_mode() function that all of them call.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/structs_vec.c | 52 ++++++++++++++++++++--------------------------
 libmultipath/structs_vec.h |  2 +-
 multipathd/cli_handlers.c  | 14 ++++---------
 3 files changed, 28 insertions(+), 40 deletions(-)

diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 814a4b9..2f1f277 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -307,7 +307,23 @@ update_multipath_strings(struct multipath *mpp, vector pathvec, int is_daemon)
 	return 0;
 }
 
-void set_no_path_retry(struct config *conf, struct multipath *mpp)
+void enter_recovery_mode(struct multipath *mpp)
+{
+	struct config *conf = get_multipath_config();
+
+	/*
+	 * Enter retry mode.
+	 * meaning of +1: retry_tick may be decremented in checkerloop before
+	 * starting retry.
+	 */
+	mpp->stat_queueing_timeouts++;
+	mpp->retry_tick = mpp->no_path_retry * conf->checkint + 1;
+	condlog(1, "%s: Entering recovery mode: max_retries=%d",
+		mpp->alias, mpp->no_path_retry);
+	put_multipath_config(conf);
+}
+
+static void set_no_path_retry(struct multipath *mpp)
 {
 	mpp->retry_tick = 0;
 	mpp->nr_active = pathcount(mpp, PATH_UP) + pathcount(mpp, PATH_GHOST);
@@ -323,14 +339,8 @@ void set_no_path_retry(struct config *conf, struct multipath *mpp)
 		break;
 	default:
 		dm_queue_if_no_path(mpp->alias, 1);
-		if (mpp->nr_active == 0) {
-			struct config *conf = get_multipath_config();
-			/* Enter retry mode */
-			mpp->retry_tick = mpp->no_path_retry * conf->checkint;
-			condlog(1, "%s: Entering recovery mode: max_retries=%d",
-				mpp->alias, mpp->no_path_retry);
-			put_multipath_config(conf);
-		}
+		if (mpp->nr_active == 0)
+			enter_recovery_mode(mpp);
 		break;
 	}
 }
@@ -338,8 +348,6 @@ void set_no_path_retry(struct config *conf, struct multipath *mpp)
 int __setup_multipath(struct vectors *vecs, struct multipath *mpp,
 		      int reset)
 {
-	struct config *conf;
-
 	if (dm_get_info(mpp->alias, &mpp->dmi)) {
 		/* Error accessing table */
 		condlog(3, "%s: cannot access table", mpp->alias);
@@ -358,9 +366,7 @@ int __setup_multipath(struct vectors *vecs, struct multipath *mpp,
 	}
 
 	if (reset) {
-		conf = get_multipath_config();
-		set_no_path_retry(conf, mpp);
-		put_multipath_config(conf);
+		set_no_path_retry(mpp);
 		if (VECTOR_SIZE(mpp->paths) != 0)
 			dm_cancel_deferred_remove(mpp);
 	}
@@ -638,21 +644,9 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)
 void update_queue_mode_del_path(struct multipath *mpp)
 {
 	if (--mpp->nr_active == 0) {
-		if (mpp->no_path_retry > 0) {
-			struct config *conf = get_multipath_config();
-
-			/*
-			 * Enter retry mode.
-			 * meaning of +1: retry_tick may be decremented in
-			 *                checkerloop before starting retry.
-			 */
-			mpp->stat_queueing_timeouts++;
-			mpp->retry_tick = mpp->no_path_retry *
-					  conf->checkint + 1;
-			condlog(1, "%s: Entering recovery mode: max_retries=%d",
-				mpp->alias, mpp->no_path_retry);
-			put_multipath_config(conf);
-		} else if (mpp->no_path_retry != NO_PATH_RETRY_QUEUE)
+		if (mpp->no_path_retry > 0)
+			enter_recovery_mode(mpp);
+		else if (mpp->no_path_retry != NO_PATH_RETRY_QUEUE)
 			mpp->stat_map_failures++;
 	}
 	condlog(2, "%s: remaining active paths: %d", mpp->alias, mpp->nr_active);
diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
index 04fa0dd..b81413b 100644
--- a/libmultipath/structs_vec.h
+++ b/libmultipath/structs_vec.h
@@ -11,7 +11,7 @@ struct vectors {
 	vector mpvec;
 };
 
-void set_no_path_retry(struct config *conf, struct multipath *mpp);
+void enter_recovery_mode(struct multipath *mpp);
 
 int adopt_paths (vector pathvec, struct multipath * mpp);
 void orphan_paths (vector pathvec, struct multipath * mpp);
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index bf0d9f6..7f13bc9 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -997,11 +997,8 @@ cli_restore_queueing(void *v, char **reply, int *len, void *data)
 		dm_queue_if_no_path(mpp->alias, 1);
 		if (mpp->nr_active > 0)
 			mpp->retry_tick = 0;
-		else {
-			struct config *conf = get_multipath_config();
-			mpp->retry_tick = mpp->no_path_retry * conf->checkint;
-			put_multipath_config(conf);
-		}
+		else
+			enter_recovery_mode(mpp);
 	}
 	return 0;
 }
@@ -1024,11 +1021,8 @@ cli_restore_all_queueing(void *v, char **reply, int *len, void *data)
 			dm_queue_if_no_path(mpp->alias, 1);
 			if (mpp->nr_active > 0)
 				mpp->retry_tick = 0;
-			else {
-				conf = get_multipath_config();
-				mpp->retry_tick = mpp->no_path_retry * conf->checkint;
-				put_multipath_config(conf);
-			}
+			else
+				enter_recovery_mode(mpp);
 		}
 	}
 	return 0;
-- 
2.7.4

  parent reply	other threads:[~2017-12-07 18:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 18:48 [PATCH 00/12] Misc fixes Benjamin Marzinski
2017-12-07 18:48 ` [PATCH 01/12] multipath: add "ghost_delay" parameter Benjamin Marzinski
2017-12-07 22:08   ` Martin Wilck
2017-12-07 18:48 ` [PATCH 02/12] kpartx: don't delete partitions from partitions Benjamin Marzinski
2017-12-07 22:09   ` Martin Wilck
2017-12-07 18:48 ` [PATCH 03/12] multipath: fix hwhandler check in select_action Benjamin Marzinski
2017-12-07 22:09   ` Martin Wilck
2017-12-07 18:48 ` [PATCH 04/12] libmultipath: cleanup features handling code Benjamin Marzinski
2017-12-07 22:10   ` Martin Wilck
2017-12-08 15:24   ` Martin Wilck
2017-12-08 21:12     ` Benjamin Marzinski
2017-12-07 18:48 ` [PATCH 05/12] multipathd: move helper functions to libmultipath Benjamin Marzinski
2017-12-07 22:11   ` Martin Wilck
2017-12-07 18:49 ` [PATCH 06/12] multipathd: fix device creation issues Benjamin Marzinski
2017-12-08 17:26   ` Martin Wilck
2018-01-30 16:51   ` Martin Wilck
2018-01-30 18:34     ` Benjamin Marzinski
2018-01-30 19:02       ` Martin Wilck
2017-12-07 18:49 ` [PATCH 07/12] multipathd: remove select_* from setup_multipath Benjamin Marzinski
2017-12-08 20:08   ` Martin Wilck
2017-12-07 18:49 ` [PATCH 08/12] libmultipath: __setup_multipath param cleanup Benjamin Marzinski
2017-12-08 20:13   ` Martin Wilck
2017-12-07 18:49 ` Benjamin Marzinski [this message]
2017-12-07 22:13   ` [PATCH 09/12] multipathd: move recovery mode code to function Martin Wilck
2017-12-07 18:49 ` [PATCH 10/12] multipathd: clean up set_no_path_retry Benjamin Marzinski
2017-12-07 22:14   ` Martin Wilck
2017-12-07 18:49 ` [PATCH 11/12] multipath: check failed path dmstate in check_path Benjamin Marzinski
2017-12-07 22:14   ` Martin Wilck
2017-12-07 18:49 ` [PATCH 12/12] multipathd: marginal path code fixes Benjamin Marzinski
2017-12-07 22:15   ` Martin Wilck
2018-01-13  9:19 ` [PATCH 00/12] Misc fixes Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1512672546-12785-10-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).