|
|
b7337d |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
b7337d |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
b7337d |
Date: Mon, 15 Jun 2020 17:00:54 -0500
|
|
|
b7337d |
Subject: [PATCH] multipathd: add "del maps" multipathd command
|
|
|
b7337d |
|
|
|
b7337d |
This will flush all multipath devices.
|
|
|
b7337d |
|
|
|
b7337d |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
b7337d |
---
|
|
|
b7337d |
libmultipath/devmapper.c | 7 +++++--
|
|
|
b7337d |
libmultipath/devmapper.h | 2 +-
|
|
|
b7337d |
multipath/main.c | 2 +-
|
|
|
b7337d |
multipathd/cli.c | 1 +
|
|
|
b7337d |
multipathd/cli_handlers.c | 19 +++++++++++++++++++
|
|
|
b7337d |
multipathd/cli_handlers.h | 1 +
|
|
|
b7337d |
multipathd/main.c | 3 ++-
|
|
|
b7337d |
multipathd/main.h | 1 +
|
|
|
b7337d |
8 files changed, 31 insertions(+), 5 deletions(-)
|
|
|
b7337d |
|
|
|
b7337d |
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
|
|
|
b7337d |
index cda83ce4..7f98bf9d 100644
|
|
|
b7337d |
--- a/libmultipath/devmapper.c
|
|
|
b7337d |
+++ b/libmultipath/devmapper.c
|
|
|
b7337d |
@@ -951,7 +951,7 @@ dm_flush_map_nopaths(const char * mapname, int deferred_remove)
|
|
|
b7337d |
|
|
|
b7337d |
#endif
|
|
|
b7337d |
|
|
|
b7337d |
-int dm_flush_maps (int retries)
|
|
|
b7337d |
+int dm_flush_maps (int need_suspend, int retries)
|
|
|
b7337d |
{
|
|
|
b7337d |
int r = 1;
|
|
|
b7337d |
struct dm_task *dmt;
|
|
|
b7337d |
@@ -974,7 +974,10 @@ int dm_flush_maps (int retries)
|
|
|
b7337d |
|
|
|
b7337d |
r = 0;
|
|
|
b7337d |
do {
|
|
|
b7337d |
- r |= dm_suspend_and_flush_map(names->name, retries);
|
|
|
b7337d |
+ if (need_suspend)
|
|
|
b7337d |
+ r |= dm_suspend_and_flush_map(names->name, retries);
|
|
|
b7337d |
+ else
|
|
|
b7337d |
+ r |= dm_flush_map(names->name);
|
|
|
b7337d |
next = names->next;
|
|
|
b7337d |
names = (void *) names + next;
|
|
|
b7337d |
} while (next);
|
|
|
b7337d |
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
|
|
|
b7337d |
index adb55000..7e8812ad 100644
|
|
|
b7337d |
--- a/libmultipath/devmapper.h
|
|
|
b7337d |
+++ b/libmultipath/devmapper.h
|
|
|
b7337d |
@@ -55,7 +55,7 @@ int dm_flush_map_nopaths(const char * mapname, int deferred_remove);
|
|
|
b7337d |
#define dm_suspend_and_flush_map(mapname, retries) \
|
|
|
b7337d |
_dm_flush_map(mapname, 1, 0, 1, retries)
|
|
|
b7337d |
int dm_cancel_deferred_remove(struct multipath *mpp);
|
|
|
b7337d |
-int dm_flush_maps (int retries);
|
|
|
b7337d |
+int dm_flush_maps (int need_suspend, int retries);
|
|
|
b7337d |
int dm_fail_path(const char * mapname, char * path);
|
|
|
b7337d |
int dm_reinstate_path(const char * mapname, char * path);
|
|
|
b7337d |
int dm_queue_if_no_path(const char *mapname, int enable);
|
|
|
b7337d |
diff --git a/multipath/main.c b/multipath/main.c
|
|
|
b7337d |
index 78822ee1..7ab3102f 100644
|
|
|
b7337d |
--- a/multipath/main.c
|
|
|
b7337d |
+++ b/multipath/main.c
|
|
|
b7337d |
@@ -1127,7 +1127,7 @@ main (int argc, char *argv[])
|
|
|
b7337d |
goto out;
|
|
|
b7337d |
}
|
|
|
b7337d |
else if (conf->remove == FLUSH_ALL) {
|
|
|
b7337d |
- r = dm_flush_maps(retries) ? RTVL_FAIL : RTVL_OK;
|
|
|
b7337d |
+ r = dm_flush_maps(1, retries) ? RTVL_FAIL : RTVL_OK;
|
|
|
b7337d |
goto out;
|
|
|
b7337d |
}
|
|
|
b7337d |
while ((r = configure(conf, cmd, dev_type, dev)) == RTVL_RETRY)
|
|
|
b7337d |
diff --git a/multipathd/cli.c b/multipathd/cli.c
|
|
|
b7337d |
index 800c0fbe..bdc9fb10 100644
|
|
|
b7337d |
--- a/multipathd/cli.c
|
|
|
b7337d |
+++ b/multipathd/cli.c
|
|
|
b7337d |
@@ -568,6 +568,7 @@ cli_init (void) {
|
|
|
b7337d |
add_handler(DEL+PATH, NULL);
|
|
|
b7337d |
add_handler(ADD+MAP, NULL);
|
|
|
b7337d |
add_handler(DEL+MAP, NULL);
|
|
|
b7337d |
+ add_handler(DEL+MAPS, NULL);
|
|
|
b7337d |
add_handler(SWITCH+MAP+GROUP, NULL);
|
|
|
b7337d |
add_handler(RECONFIGURE, NULL);
|
|
|
b7337d |
add_handler(SUSPEND+MAP, NULL);
|
|
|
b7337d |
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
|
|
|
b7337d |
index 31c3d9fd..782bb003 100644
|
|
|
b7337d |
--- a/multipathd/cli_handlers.c
|
|
|
b7337d |
+++ b/multipathd/cli_handlers.c
|
|
|
b7337d |
@@ -852,6 +852,25 @@ cli_del_map (void * v, char ** reply, int * len, void * data)
|
|
|
b7337d |
return rc;
|
|
|
b7337d |
}
|
|
|
b7337d |
|
|
|
b7337d |
+int
|
|
|
b7337d |
+cli_del_maps (void *v, char **reply, int *len, void *data)
|
|
|
b7337d |
+{
|
|
|
b7337d |
+ struct vectors * vecs = (struct vectors *)data;
|
|
|
b7337d |
+ struct multipath *mpp;
|
|
|
b7337d |
+ int i, ret = 0;
|
|
|
b7337d |
+
|
|
|
b7337d |
+ condlog(2, "remove maps (operator)");
|
|
|
b7337d |
+ vector_foreach_slot(vecs->mpvec, mpp, i) {
|
|
|
b7337d |
+ if (flush_map(mpp, vecs, 0))
|
|
|
b7337d |
+ ret++;
|
|
|
b7337d |
+ else
|
|
|
b7337d |
+ i--;
|
|
|
b7337d |
+ }
|
|
|
b7337d |
+ /* flush any multipath maps that aren't currently known by multipathd */
|
|
|
b7337d |
+ ret |= dm_flush_maps(0, 0);
|
|
|
b7337d |
+ return ret;
|
|
|
b7337d |
+}
|
|
|
b7337d |
+
|
|
|
b7337d |
int
|
|
|
b7337d |
cli_reload(void *v, char **reply, int *len, void *data)
|
|
|
b7337d |
{
|
|
|
b7337d |
diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h
|
|
|
b7337d |
index 0f451064..6f57b429 100644
|
|
|
b7337d |
--- a/multipathd/cli_handlers.h
|
|
|
b7337d |
+++ b/multipathd/cli_handlers.h
|
|
|
b7337d |
@@ -26,6 +26,7 @@ int cli_add_path (void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
int cli_del_path (void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
int cli_add_map (void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
int cli_del_map (void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
+int cli_del_maps (void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
int cli_switch_group(void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
int cli_reconfigure(void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
int cli_resize(void * v, char ** reply, int * len, void * data);
|
|
|
b7337d |
diff --git a/multipathd/main.c b/multipathd/main.c
|
|
|
b7337d |
index 1d9ce7f7..1d0579e9 100644
|
|
|
b7337d |
--- a/multipathd/main.c
|
|
|
b7337d |
+++ b/multipathd/main.c
|
|
|
b7337d |
@@ -631,7 +631,7 @@ sync_maps_state(vector mpvec)
|
|
|
b7337d |
sync_map_state(mpp);
|
|
|
b7337d |
}
|
|
|
b7337d |
|
|
|
b7337d |
-static int
|
|
|
b7337d |
+int
|
|
|
b7337d |
flush_map(struct multipath * mpp, struct vectors * vecs, int nopaths)
|
|
|
b7337d |
{
|
|
|
b7337d |
int r;
|
|
|
b7337d |
@@ -1551,6 +1551,7 @@ uxlsnrloop (void * ap)
|
|
|
b7337d |
set_handler_callback(DEL+PATH, cli_del_path);
|
|
|
b7337d |
set_handler_callback(ADD+MAP, cli_add_map);
|
|
|
b7337d |
set_handler_callback(DEL+MAP, cli_del_map);
|
|
|
b7337d |
+ set_handler_callback(DEL+MAPS, cli_del_maps);
|
|
|
b7337d |
set_handler_callback(SWITCH+MAP+GROUP, cli_switch_group);
|
|
|
b7337d |
set_unlocked_handler_callback(RECONFIGURE, cli_reconfigure);
|
|
|
b7337d |
set_handler_callback(SUSPEND+MAP, cli_suspend);
|
|
|
b7337d |
diff --git a/multipathd/main.h b/multipathd/main.h
|
|
|
b7337d |
index 7bb8463f..5dff17e5 100644
|
|
|
b7337d |
--- a/multipathd/main.h
|
|
|
b7337d |
+++ b/multipathd/main.h
|
|
|
b7337d |
@@ -28,6 +28,7 @@ int ev_add_path (struct path *, struct vectors *, int);
|
|
|
b7337d |
int ev_remove_path (struct path *, struct vectors *, int);
|
|
|
b7337d |
int ev_add_map (char *, const char *, struct vectors *);
|
|
|
b7337d |
int ev_remove_map (char *, char *, int, struct vectors *);
|
|
|
b7337d |
+int flush_map(struct multipath *, struct vectors *, int);
|
|
|
b7337d |
int set_config_state(enum daemon_status);
|
|
|
b7337d |
void * mpath_alloc_prin_response(int prin_sa);
|
|
|
b7337d |
int prin_do_scsi_ioctl(char *, int rq_servact, struct prin_resp * resp,
|
|
|
b7337d |
--
|
|
|
b7337d |
2.17.2
|
|
|
b7337d |
|