[PATCH v2 04/18] multipathd: simplify cli_del_map()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cli_del_map() does a lot of unnecessary work to match the arguments of
ev_remove_map(), of which it is the only caller.  Then ev_remove_map()
does more unnecessary work to verify the arguments passed in. remove
ev_remove_map() and make cli_del_map() get the mpp like the rest of
the client handlers do.

Reviewed-by: Martin Wilck <mwilck@xxxxxxxx>
Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 multipathd/cli_handlers.c | 23 ++++++-----------------
 multipathd/main.c         | 21 ---------------------
 multipathd/main.h         |  1 -
 3 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index dc547be8..9a0cd065 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -742,28 +742,17 @@ cli_del_map (void * v, struct strbuf *reply, void * data)
 {
 	struct vectors * vecs = (struct vectors *)data;
 	char * param = get_keyparam(v, KEY_MAP);
-	int major, minor;
-	char *alias;
-	int rc;
+	struct multipath *mpp;
 
 	param = convert_dev(param, 0);
 	condlog(2, "%s: remove map (operator)", param);
-	if (dm_get_major_minor(param, &major, &minor) < 0) {
-		condlog(2, "%s: not a device mapper table", param);
-		return 1;
-	}
-	alias = dm_mapname(major, minor);
-	if (!alias) {
-		condlog(2, "%s: mapname not found for %d:%d",
-			param, major, minor);
+
+	mpp = find_mp_by_str(vecs->mpvec, param);
+
+	if (!mpp)
 		return 1;
-	}
-	rc = ev_remove_map(param, alias, minor, vecs);
-	if (rc == 2)
-		append_strbuf_str(reply, "delayed\n");
 
-	free(alias);
-	return rc;
+	return flush_map(mpp, vecs);
 }
 
 static int
diff --git a/multipathd/main.c b/multipathd/main.c
index 6b66a5ee..17468985 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -931,27 +931,6 @@ out:
 	return 0;
 }
 
-/* Called from CLI handler */
-int
-ev_remove_map (char * devname, char * alias, int minor, struct vectors * vecs)
-{
-	struct multipath * mpp;
-
-	mpp = find_mp_by_minor(vecs->mpvec, minor);
-
-	if (!mpp) {
-		condlog(2, "%s: devmap not registered, can't remove",
-			devname);
-		return 1;
-	}
-	if (strcmp(mpp->alias, alias)) {
-		condlog(2, "%s: minor number mismatch (map %d, event %d)",
-			mpp->alias, mpp->dmi.minor, minor);
-		return 1;
-	}
-	return flush_map(mpp, vecs);
-}
-
 static void
 rescan_path(struct udev_device *ud)
 {
diff --git a/multipathd/main.h b/multipathd/main.h
index e050b5c5..4fcd6402 100644
--- a/multipathd/main.h
+++ b/multipathd/main.h
@@ -39,7 +39,6 @@ int need_to_delay_reconfig (struct vectors *);
 int ev_add_path (struct path *, struct vectors *, int);
 int ev_remove_path (struct path *, struct vectors *, int);
 int ev_add_map (char *, const char *, struct vectors *);
-int ev_remove_map (char *, char *, int, struct vectors *);
 int flush_map(struct multipath *, struct vectors *);
 
 void handle_signals(bool);
-- 
2.43.0





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux