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