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