Blame SOURCES/0028-multipath-make-flushing-maps-work-like-other-command.patch

96a22b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
96a22b
From: Benjamin Marzinski <bmarzins@redhat.com>
96a22b
Date: Mon, 15 Jun 2020 23:54:29 -0500
96a22b
Subject: [PATCH] multipath: make flushing maps work like other commands
96a22b
96a22b
The config structure doesn't need a special variable just for removes.
96a22b
Multipath can just use the cmd variable, like it does for the other
96a22b
commands.
96a22b
96a22b
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
96a22b
---
96a22b
 libmultipath/config.h    |  3 ++-
96a22b
 libmultipath/configure.h |  3 ---
96a22b
 multipath/main.c         | 20 ++++++++++----------
96a22b
 3 files changed, 12 insertions(+), 14 deletions(-)
96a22b
96a22b
diff --git a/libmultipath/config.h b/libmultipath/config.h
96a22b
index 3368d8c9..4042eba6 100644
96a22b
--- a/libmultipath/config.h
96a22b
+++ b/libmultipath/config.h
96a22b
@@ -39,6 +39,8 @@ enum mpath_cmds {
96a22b
 	CMD_ADD_WWID,
96a22b
 	CMD_USABLE_PATHS,
96a22b
 	CMD_DUMP_CONFIG,
96a22b
+	CMD_FLUSH_ONE,
96a22b
+	CMD_FLUSH_ALL,
96a22b
 };
96a22b
 
96a22b
 enum force_reload_types {
96a22b
@@ -143,7 +145,6 @@ struct config {
96a22b
 	unsigned int max_checkint;
96a22b
 	bool use_watchdog;
96a22b
 	int pgfailback;
96a22b
-	int remove;
96a22b
 	int rr_weight;
96a22b
 	int no_path_retry;
96a22b
 	int user_friendly_names;
96a22b
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
96a22b
index d7509000..0e33bf40 100644
96a22b
--- a/libmultipath/configure.h
96a22b
+++ b/libmultipath/configure.h
96a22b
@@ -45,9 +45,6 @@ enum {
96a22b
 	CP_RETRY,
96a22b
 };
96a22b
 
96a22b
-#define FLUSH_ONE 1
96a22b
-#define FLUSH_ALL 2
96a22b
-
96a22b
 struct vectors;
96a22b
 
96a22b
 int setup_map (struct multipath * mpp, char * params, int params_size,
96a22b
diff --git a/multipath/main.c b/multipath/main.c
96a22b
index 7ab3102f..a2080029 100644
96a22b
--- a/multipath/main.c
96a22b
+++ b/multipath/main.c
96a22b
@@ -942,10 +942,10 @@ main (int argc, char *argv[])
96a22b
 				cmd = CMD_DRY_RUN;
96a22b
 			break;
96a22b
 		case 'f':
96a22b
-			conf->remove = FLUSH_ONE;
96a22b
+			cmd = CMD_FLUSH_ONE;
96a22b
 			break;
96a22b
 		case 'F':
96a22b
-			conf->remove = FLUSH_ALL;
96a22b
+			cmd = CMD_FLUSH_ALL;
96a22b
 			break;
96a22b
 		case 'l':
96a22b
 			if (optarg && !strncmp(optarg, "l", 1))
96a22b
@@ -1084,6 +1084,10 @@ main (int argc, char *argv[])
96a22b
 		condlog(0, "the -w option requires a device");
96a22b
 		goto out;
96a22b
 	}
96a22b
+	if (cmd == CMD_FLUSH_ONE && dev_type != DEV_DEVMAP) {
96a22b
+		condlog(0, "the -f option requires a map name to remove");
96a22b
+		goto out;
96a22b
+	}
96a22b
 
96a22b
 	switch(delegate_to_multipathd(cmd, dev, dev_type, conf)) {
96a22b
 	case DELEGATE_OK:
96a22b
@@ -1117,16 +1121,12 @@ main (int argc, char *argv[])
96a22b
 	}
96a22b
 	if (retries < 0)
96a22b
 		retries = conf->remove_retries;
96a22b
-	if (conf->remove == FLUSH_ONE) {
96a22b
-		if (dev_type == DEV_DEVMAP) {
96a22b
-			r = dm_suspend_and_flush_map(dev, retries) ?
96a22b
-				RTVL_FAIL : RTVL_OK;
96a22b
-		} else
96a22b
-			condlog(0, "must provide a map name to remove");
96a22b
-
96a22b
+	if (cmd == CMD_FLUSH_ONE) {
96a22b
+		r = dm_suspend_and_flush_map(dev, retries) ?
96a22b
+		    RTVL_FAIL : RTVL_OK;
96a22b
 		goto out;
96a22b
 	}
96a22b
-	else if (conf->remove == FLUSH_ALL) {
96a22b
+	else if (cmd == CMD_FLUSH_ALL) {
96a22b
 		r = dm_flush_maps(1, retries) ? RTVL_FAIL : RTVL_OK;
96a22b
 		goto out;
96a22b
 	}
96a22b
-- 
96a22b
2.17.2
96a22b