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

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