dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches
@ 2021-09-02 21:57 Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 1/6] multipath.conf: fix typo in ghost_delay description Benjamin Marzinski
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

Here are a couple of unconnected patches. They (at least
libmultipath.version) are meant to be applied on top of
Martin's recent patchset.

Changes from v1:

3/6: Reworked this to keep the logic in multipath, and prefix the output
     with "Warning" as suggested by Martin Wilck.
6/6: New patch to simplify code that I noticed while reworking patch
     3/6.

Benjamin Marzinski (6):
  multipath.conf: fix typo in ghost_delay description
  mpathpersist: fail commands when no usable paths exist
  multipath: print warning if multipathd is not running.
  libmultipath: remove unneeded code in coalesce_paths
  libmultipath: deal with dynamic PTHREAD_STACK_MIN
  libmultipath: drop unnecessary parameter from remove_map()

 libmpathpersist/mpath_persist.c   | 10 ++++-
 libmultipath/configure.c          | 62 ++++---------------------------
 libmultipath/configure.h          |  1 +
 libmultipath/libmultipath.version |  5 +++
 libmultipath/structs_vec.c        | 12 +++---
 libmultipath/structs_vec.h        | 11 +-----
 libmultipath/util.c               |  4 +-
 multipath/main.c                  | 18 +++++++--
 multipath/multipath.conf.5        |  2 +-
 multipathd/dmevents.c             |  2 +-
 multipathd/main.c                 | 12 +++---
 11 files changed, 54 insertions(+), 85 deletions(-)

-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dm-devel] [PATCH v2 1/6] multipath.conf: fix typo in ghost_delay description
  2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
@ 2021-09-02 21:57 ` Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 2/6] mpathpersist: fail commands when no usable paths exist Benjamin Marzinski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 multipath/multipath.conf.5 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index 064e4826..d6b8c7f6 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -1251,7 +1251,7 @@ The default is: in \fB/sys/block/<dev>/queue/max_sectors_kb\fR
 Sets the number of seconds that multipath will wait after creating a device
 with only ghost paths before marking it ready for use in systemd. This gives
 the active paths time to appear before the multipath runs the hardware handler
-to switch the ghost paths to active ones. Setting this to \fI0\fR or \fIon\fR
+to switch the ghost paths to active ones. Setting this to \fI0\fR or \fIno\fR
 makes multipath immediately mark a device with only ghost paths as ready.
 .RS
 .TP
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dm-devel] [PATCH v2 2/6] mpathpersist: fail commands when no usable paths exist
  2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 1/6] multipath.conf: fix typo in ghost_delay description Benjamin Marzinski
@ 2021-09-02 21:57 ` Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 3/6] multipath: print warning if multipathd is not running Benjamin Marzinski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

"mpathpersist -oCK <reservation_key> <device>" will return success if it
is run on devices with no usable paths, but nothing is actually done.
The -L command will fail, but it should give up sooner, and with a more
helpful error message.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmpathpersist/mpath_persist.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 190e9707..26710e79 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -604,7 +604,8 @@ int mpath_prout_common(struct multipath *mpp,int rq_servact, int rq_scope,
 			return ret ;
 		}
 	}
-	return MPATH_PR_SUCCESS;
+	condlog (0, "%s: no path available", mpp->wwid);
+	return MPATH_PR_DMMP_ERROR;
 }
 
 int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
@@ -663,6 +664,11 @@ int mpath_prout_rel(struct multipath *mpp,int rq_servact, int rq_scope,
 
 	active_pathcount = count_active_paths(mpp);
 
+	if (active_pathcount == 0) {
+		condlog (0, "%s: no path available", mpp->wwid);
+		return MPATH_PR_DMMP_ERROR;
+	}
+
 	struct threadinfo thread[active_pathcount];
 	memset(thread, 0, sizeof(thread));
 	for (i = 0; i < active_pathcount; i++){
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dm-devel] [PATCH v2 3/6] multipath: print warning if multipathd is not running.
  2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 1/6] multipath.conf: fix typo in ghost_delay description Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 2/6] mpathpersist: fail commands when no usable paths exist Benjamin Marzinski
@ 2021-09-02 21:57 ` Benjamin Marzinski
  2021-09-03  8:20   ` Martin Wilck
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 4/6] libmultipath: remove unneeded code in coalesce_paths Benjamin Marzinski
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

If multipath notices that multipath devices exist or were created, and
multipathd is not running, it now prints a warning message, so users are
notified of the issue.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/configure.c          |  3 ++-
 libmultipath/configure.h          |  1 +
 libmultipath/libmultipath.version |  5 +++++
 multipath/main.c                  | 14 ++++++++++++--
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 12278640..2f417914 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -1082,7 +1082,8 @@ deadmap (struct multipath * mpp)
 	return 1; /* dead */
 }
 
-int check_daemon(void)
+extern int
+check_daemon(void)
 {
 	int fd;
 	char *reply;
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index 92a5aba6..efe18b7d 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -59,3 +59,4 @@ struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);
 void trigger_paths_udev_change(struct multipath *mpp, bool is_mpath);
 void trigger_partitions_udev_change(struct udev_device *dev, const char *action,
 				    int len);
+int check_daemon(void);
diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version
index 1d84d97c..7b48265f 100644
--- a/libmultipath/libmultipath.version
+++ b/libmultipath/libmultipath.version
@@ -285,3 +285,8 @@ global:
 	print_strbuf;
 	truncate_strbuf;
 } LIBMULTIPATH_8.0.0;
+
+LIBMULTIPATH_8.2.0 {
+global:
+	check_daemon;
+} LIBMULTIPATH_8.1.0;
diff --git a/multipath/main.c b/multipath/main.c
index 8fc0e15f..6c70760f 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -456,6 +456,7 @@ configure (struct config *conf, enum mpath_cmds cmd,
 {
 	vector curmp = NULL;
 	vector pathvec = NULL;
+	vector newmp = NULL;
 	int r = RTVL_FAIL, rc;
 	int di_flag = 0;
 	char * refwwid = NULL;
@@ -466,8 +467,9 @@ configure (struct config *conf, enum mpath_cmds cmd,
 	 */
 	curmp = vector_alloc();
 	pathvec = vector_alloc();
+	newmp = vector_alloc();
 
-	if (!curmp || !pathvec) {
+	if (!curmp || !pathvec || !newmp) {
 		condlog(0, "can not allocate memory");
 		goto out;
 	}
@@ -569,16 +571,24 @@ configure (struct config *conf, enum mpath_cmds cmd,
 	/*
 	 * core logic entry point
 	 */
-	rc = coalesce_paths(&vecs, NULL, refwwid,
+	rc = coalesce_paths(&vecs, newmp, refwwid,
 			   conf->force_reload, cmd);
 	r = rc == CP_RETRY ? RTVL_RETRY : rc == CP_OK ? RTVL_OK : RTVL_FAIL;
 
 out:
+	if (r == RTVL_OK &&
+	    (cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG ||
+	     cmd == CMD_CREATE) &&
+	    (VECTOR_SIZE(curmp) > 0 || VECTOR_SIZE(newmp) > 0) &&
+	    !check_daemon())
+		condlog(2, "Warning: multipath devices exist, but multipathd service is not running");
+
 	if (refwwid)
 		FREE(refwwid);
 
 	free_multipathvec(curmp, KEEP_PATHS);
 	vecs.mpvec = NULL;
+	free_multipathvec(newmp, KEEP_PATHS);
 	free_pathvec(pathvec, FREE_PATHS);
 	vecs.pathvec = NULL;
 
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dm-devel] [PATCH v2 4/6] libmultipath: remove unneeded code in coalesce_paths
  2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
                   ` (2 preceding siblings ...)
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 3/6] multipath: print warning if multipathd is not running Benjamin Marzinski
@ 2021-09-02 21:57 ` Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 5/6] libmultipath: deal with dynamic PTHREAD_STACK_MIN Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map() Benjamin Marzinski
  5 siblings, 0 replies; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

The code at the end of coalesce_paths() removes a multipath device that
was just created/reloaded, if none of its path devices have pp->dev set.
This code is very old, and no longer has any actual effect. Multipath
devices no longer get placed in pathvec without having pp->dev set. Even
if they could, there's no point in creating/reloading the device and
then immediately removing it.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/configure.c | 46 ----------------------------------------
 1 file changed, 46 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 2f417914..3f241c5c 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -1060,28 +1060,6 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
 	return DOMAP_FAIL;
 }
 
-static int
-deadmap (struct multipath * mpp)
-{
-	int i, j;
-	struct pathgroup * pgp;
-	struct path * pp;
-
-	if (!mpp->pg)
-		return 1;
-
-	vector_foreach_slot (mpp->pg, pgp, i) {
-		if (!pgp->paths)
-			continue;
-
-		vector_foreach_slot (pgp->paths, pp, j)
-			if (strlen(pp->dev))
-				return 0; /* alive */
-	}
-
-	return 1; /* dead */
-}
-
 extern int
 check_daemon(void)
 {
@@ -1313,30 +1291,6 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 			remove_map(mpp, vecs->pathvec, vecs->mpvec,
 				   KEEP_VEC);
 	}
-	/*
-	 * Flush maps with only dead paths (ie not in sysfs)
-	 * Keep maps with only failed paths
-	 */
-	if (mpvec) {
-		vector_foreach_slot (newmp, mpp, i) {
-			char alias[WWID_SIZE];
-
-			if (!deadmap(mpp))
-				continue;
-
-			strlcpy(alias, mpp->alias, WWID_SIZE);
-
-			vector_del_slot(newmp, i);
-			i--;
-			remove_map(mpp, vecs->pathvec, vecs->mpvec, KEEP_VEC);
-
-			if (dm_flush_map(alias))
-				condlog(2, "%s: remove failed (dead)",
-					alias);
-			else
-				condlog(2, "%s: remove (dead)", alias);
-		}
-	}
 	ret = CP_OK;
 out:
 	free(size_mismatch_seen);
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dm-devel] [PATCH v2 5/6] libmultipath: deal with dynamic PTHREAD_STACK_MIN
  2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
                   ` (3 preceding siblings ...)
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 4/6] libmultipath: remove unneeded code in coalesce_paths Benjamin Marzinski
@ 2021-09-02 21:57 ` Benjamin Marzinski
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map() Benjamin Marzinski
  5 siblings, 0 replies; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

Starting in glibc-2.34 (commit 5d98a7da), PTHREAD_STACK_MIN is defined
as sysconf(_SC_THREAD_STACK_MIN) if _GNU_SOURCE is defined. sysconf()
returns a long and can, at least in theory, return -1.  This change
causes compilation to fail in setup_thread_attr() due to a comparision
with different signedness, since stacksize is a size_t.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libmultipath/util.c b/libmultipath/util.c
index e2fafe85..ea858409 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -223,8 +223,8 @@ setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
 
 	ret = pthread_attr_init(attr);
 	assert(ret == 0);
-	if (stacksize < PTHREAD_STACK_MIN)
-		stacksize = PTHREAD_STACK_MIN;
+	if (PTHREAD_STACK_MIN > 0 && stacksize < (size_t)PTHREAD_STACK_MIN)
+		stacksize = (size_t)PTHREAD_STACK_MIN;
 	ret = pthread_attr_setstacksize(attr, stacksize);
 	assert(ret == 0);
 	if (detached) {
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map()
  2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
                   ` (4 preceding siblings ...)
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 5/6] libmultipath: deal with dynamic PTHREAD_STACK_MIN Benjamin Marzinski
@ 2021-09-02 21:57 ` Benjamin Marzinski
  2021-09-03  9:28   ` Martin Wilck
  5 siblings, 1 reply; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-02 21:57 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: device-mapper development, Martin Wilck

When remove_map() is called, if the multipath device is in a mpvec, it
must be removed from it, because the device will be freed. Now that the
mpvec is passed as a separate parameter to remove_map(), the purge_vec
parameter is redundant.  It was only used by coalesce_paths(), since the
multipath device isn't on any vector when remove_map() is called there.
Instead, remove_map() can just be called with a NULL mpvec, when there
is no mpvec to remove the device from.

remove_map_by_alias() also has a redundant purge_vec parameter.  Since
it only removes a map if it finds in on vec->mpvec, calling it with
KEEP_VEC would be a bug, since it would leave a pointer to the freed
device in the vector.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmpathpersist/mpath_persist.c |  2 +-
 libmultipath/configure.c        | 13 ++++++-------
 libmultipath/structs_vec.c      | 12 ++++++------
 libmultipath/structs_vec.h      | 11 ++---------
 multipath/main.c                |  4 ++--
 multipathd/dmevents.c           |  2 +-
 multipathd/main.c               | 12 ++++++------
 7 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index 26710e79..803a2a28 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -410,7 +410,7 @@ get_mpvec (vector curmp, vector pathvec, char * refwwid)
 		if (update_multipath_table(mpp, pathvec, DI_CHECKER) != DMP_OK ||
 		    update_mpp_paths(mpp, pathvec)) {
 			condlog(1, "error parsing map %s", mpp->wwid);
-			remove_map(mpp, pathvec, curmp, PURGE_VEC);
+			remove_map(mpp, pathvec, curmp);
 			i--;
 		} else
 			extract_hwe_from_path(mpp);
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 3f241c5c..7edb355b 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -1198,7 +1198,7 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 
 		if (!mpp->paths) {
 			condlog(0, "%s: skip coalesce (no paths)", mpp->alias);
-			remove_map(mpp, vecs->pathvec, vecs->mpvec, KEEP_VEC);
+			remove_map(mpp, vecs->pathvec, NULL);
 			continue;
 		}
 
@@ -1226,7 +1226,7 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 		verify_paths(mpp);
 
 		if (setup_map(mpp, &params, vecs)) {
-			remove_map(mpp, vecs->pathvec, vecs->mpvec, KEEP_VEC);
+			remove_map(mpp, vecs->pathvec, NULL);
 			continue;
 		}
 
@@ -1248,7 +1248,7 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 				condlog(2, "%s: %s map",
 					mpp->alias, (mpp->action == ACT_CREATE)?
 					"ignoring" : "removing");
-				remove_map(mpp, vecs->pathvec, vecs->mpvec, KEEP_VEC);
+				remove_map(mpp, vecs->pathvec, NULL);
 				continue;
 			} else /* if (r == DOMAP_RETRY && !is_daemon) */ {
 				ret = CP_RETRY;
@@ -1257,7 +1257,7 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 		}
 		if (r == DOMAP_DRY) {
 			if (!vector_alloc_slot(newmp)) {
-				remove_map(mpp, vecs->pathvec, vecs->mpvec, KEEP_VEC);
+				remove_map(mpp, vecs->pathvec, NULL);
 				goto out;
 			}
 			vector_set_slot(newmp, mpp);
@@ -1282,14 +1282,13 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 
 		if (mpp->action != ACT_REJECT) {
 			if (!vector_alloc_slot(newmp)) {
-				remove_map(mpp, vecs->pathvec, vecs->mpvec, KEEP_VEC);
+				remove_map(mpp, vecs->pathvec, NULL);
 				goto out;
 			}
 			vector_set_slot(newmp, mpp);
 		}
 		else
-			remove_map(mpp, vecs->pathvec, vecs->mpvec,
-				   KEEP_VEC);
+			remove_map(mpp, vecs->pathvec, NULL);
 	}
 	ret = CP_OK;
 out:
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 24d6fd24..85d97ac1 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -334,7 +334,7 @@ void set_path_removed(struct path *pp)
 }
 
 void
-remove_map(struct multipath *mpp, vector pathvec, vector mpvec, int purge_vec)
+remove_map(struct multipath *mpp, vector pathvec, vector mpvec)
 {
 	int i;
 
@@ -343,7 +343,7 @@ remove_map(struct multipath *mpp, vector pathvec, vector mpvec, int purge_vec)
 	 */
 	orphan_paths(pathvec, mpp, "map removed internally");
 
-	if (purge_vec &&
+	if (mpvec &&
 	    (i = find_slot(mpvec, (void *)mpp)) != -1)
 		vector_del_slot(mpvec, i);
 
@@ -354,12 +354,12 @@ remove_map(struct multipath *mpp, vector pathvec, vector mpvec, int purge_vec)
 }
 
 void
-remove_map_by_alias(const char *alias, struct vectors * vecs, int purge_vec)
+remove_map_by_alias(const char *alias, struct vectors * vecs)
 {
 	struct multipath * mpp = find_mp_by_alias(vecs->mpvec, alias);
 	if (mpp) {
 		condlog(2, "%s: removing map by alias", alias);
-		remove_map(mpp, vecs->pathvec, vecs->mpvec, purge_vec);
+		remove_map(mpp, vecs->pathvec, vecs->mpvec);
 	}
 }
 
@@ -373,7 +373,7 @@ remove_maps(struct vectors * vecs)
 		return;
 
 	vector_foreach_slot (vecs->mpvec, mpp, i) {
-		remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+		remove_map(mpp, vecs->pathvec, vecs->mpvec);
 		i--;
 	}
 
@@ -704,7 +704,7 @@ struct multipath *add_map_with_path(struct vectors *vecs, struct path *pp,
 	return mpp;
 
 out:
-	remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+	remove_map(mpp, vecs->pathvec, vecs->mpvec);
 	return NULL;
 }
 
diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
index ee2b723b..29ede454 100644
--- a/libmultipath/structs_vec.h
+++ b/libmultipath/structs_vec.h
@@ -27,15 +27,8 @@ int update_mpp_paths(struct multipath * mpp, vector pathvec);
 int update_multipath_strings (struct multipath *mpp, vector pathvec);
 void extract_hwe_from_path(struct multipath * mpp);
 
-enum {
-	KEEP_VEC,
-	PURGE_VEC,
-};
-
-void remove_map (struct multipath *mpp, vector pathvec, vector mpvec,
-		 int purge_vec);
-void remove_map_by_alias(const char *alias, struct vectors * vecs,
-			 int purge_vec);
+void remove_map (struct multipath *mpp, vector pathvec, vector mpvec);
+void remove_map_by_alias(const char *alias, struct vectors * vecs);
 void remove_maps (struct vectors * vecs);
 
 void sync_map_state (struct multipath *);
diff --git a/multipath/main.c b/multipath/main.c
index 6c70760f..65ece830 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -191,14 +191,14 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)
 		if (refwwid && strlen(refwwid) &&
 		    strncmp(mpp->wwid, refwwid, WWID_SIZE)) {
 			condlog(3, "skip map %s: out of scope", mpp->alias);
-			remove_map(mpp, pathvec, curmp, PURGE_VEC);
+			remove_map(mpp, pathvec, curmp);
 			i--;
 			continue;
 		}
 
 		if (update_multipath_table(mpp, pathvec, flags) != DMP_OK) {
 			condlog(1, "error parsing map %s", mpp->wwid);
-			remove_map(mpp, pathvec, curmp, PURGE_VEC);
+			remove_map(mpp, pathvec, curmp);
 			i--;
 			continue;
 		}
diff --git a/multipathd/dmevents.c b/multipathd/dmevents.c
index f52f5970..f035ee7f 100644
--- a/multipathd/dmevents.c
+++ b/multipathd/dmevents.c
@@ -359,7 +359,7 @@ static int dmevent_loop (void)
 		pthread_testcancel();
 		r = 0;
 		if (curr_dev.action == EVENT_REMOVE)
-			remove_map_by_alias(curr_dev.name, waiter->vecs, PURGE_VEC);
+			remove_map_by_alias(curr_dev.name, waiter->vecs);
 		else
 			r = update_multipath(waiter->vecs, curr_dev.name, 1);
 		pthread_cleanup_pop(1);
diff --git a/multipathd/main.c b/multipathd/main.c
index ae8272e3..3aff241d 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -385,7 +385,7 @@ remove_map_and_stop_waiter(struct multipath *mpp, struct vectors *vecs)
 	condlog(3, "%s: removing map from internal tables", mpp->alias);
 	if (!poll_dmevents)
 		stop_waiter_thread(mpp);
-	remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+	remove_map(mpp, vecs->pathvec, vecs->mpvec);
 }
 
 static void
@@ -518,7 +518,7 @@ retry:
 fail:
 	if (new_map && (retries < 0 || wait_for_events(mpp, vecs))) {
 		condlog(0, "%s: failed to create new map", mpp->alias);
-		remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+		remove_map(mpp, vecs->pathvec, vecs->mpvec);
 		return 1;
 	}
 
@@ -572,7 +572,7 @@ add_map_without_path (struct vectors *vecs, const char *alias)
 
 	return mpp;
 out:
-	remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+	remove_map(mpp, vecs->pathvec, vecs->mpvec);
 	return NULL;
 }
 
@@ -1162,7 +1162,7 @@ rescan:
 		goto fail;
 
 fail_map:
-	remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+	remove_map(mpp, vecs->pathvec, vecs->mpvec);
 fail:
 	orphan_path(pp, "failed to add path");
 	return 1;
@@ -1469,7 +1469,7 @@ map_discovery (struct vectors * vecs)
 
 	vector_foreach_slot (vecs->mpvec, mpp, i)
 		if (update_multipath_table(mpp, vecs->pathvec, 0) != DMP_OK) {
-			remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+			remove_map(mpp, vecs->pathvec, vecs->mpvec);
 			i--;
 		}
 
@@ -2706,7 +2706,7 @@ configure (struct vectors * vecs)
 	 */
 	vector_foreach_slot(vecs->mpvec, mpp, i) {
 		if (wait_for_events(mpp, vecs)) {
-			remove_map(mpp, vecs->pathvec, vecs->mpvec, PURGE_VEC);
+			remove_map(mpp, vecs->pathvec, vecs->mpvec);
 			i--;
 			continue;
 		}
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dm-devel] [PATCH v2 3/6] multipath: print warning if multipathd is not running.
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 3/6] multipath: print warning if multipathd is not running Benjamin Marzinski
@ 2021-09-03  8:20   ` Martin Wilck
  0 siblings, 0 replies; 11+ messages in thread
From: Martin Wilck @ 2021-09-03  8:20 UTC (permalink / raw)
  To: bmarzins, christophe.varoqui; +Cc: dm-devel

On Thu, 2021-09-02 at 16:57 -0500, Benjamin Marzinski wrote:
> If multipath notices that multipath devices exist or were created, and
> multipathd is not running, it now prints a warning message, so users
> are
> notified of the issue.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>

Reviewed-by: Martin Wilck <mwilck@suse.com>


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map()
  2021-09-02 21:57 ` [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map() Benjamin Marzinski
@ 2021-09-03  9:28   ` Martin Wilck
  2021-09-03 15:22     ` Martin Wilck
  0 siblings, 1 reply; 11+ messages in thread
From: Martin Wilck @ 2021-09-03  9:28 UTC (permalink / raw)
  To: bmarzins, christophe.varoqui; +Cc: dm-devel

On Thu, 2021-09-02 at 16:57 -0500, Benjamin Marzinski wrote:
> When remove_map() is called, if the multipath device is in a mpvec,
> it
> must be removed from it, because the device will be freed. Now that
> the
> mpvec is passed as a separate parameter to remove_map(), the
> purge_vec
> parameter is redundant.  It was only used by coalesce_paths(), since
> the
> multipath device isn't on any vector when remove_map() is called
> there.
> Instead, remove_map() can just be called with a NULL mpvec, when
> there
> is no mpvec to remove the device from.
> 
> remove_map_by_alias() also has a redundant purge_vec parameter. 
> Since
> it only removes a map if it finds in on vec->mpvec, calling it with
> KEEP_VEC would be a bug, since it would leave a pointer to the freed
> device in the vector.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>

Good catch. But we need to adapt libmultipath.version. I'll send a fix
to be added on top.

Reviewed-by: Martin Wilck <mwilck@suse.com>



--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map()
  2021-09-03  9:28   ` Martin Wilck
@ 2021-09-03 15:22     ` Martin Wilck
  2021-09-03 17:17       ` Benjamin Marzinski
  0 siblings, 1 reply; 11+ messages in thread
From: Martin Wilck @ 2021-09-03 15:22 UTC (permalink / raw)
  To: bmarzins, christophe.varoqui; +Cc: dm-devel

On Fri, 2021-09-03 at 11:28 +0200, Martin Wilck wrote:
> On Thu, 2021-09-02 at 16:57 -0500, Benjamin Marzinski wrote:
> > When remove_map() is called, if the multipath device is in a mpvec,
> > it
> > must be removed from it, because the device will be freed. Now that
> > the
> > mpvec is passed as a separate parameter to remove_map(), the
> > purge_vec
> > parameter is redundant.  It was only used by coalesce_paths(),
> > since
> > the
> > multipath device isn't on any vector when remove_map() is called
> > there.
> > Instead, remove_map() can just be called with a NULL mpvec, when
> > there
> > is no mpvec to remove the device from.
> > 
> > remove_map_by_alias() also has a redundant purge_vec parameter. 
> > Since
> > it only removes a map if it finds in on vec->mpvec, calling it with
> > KEEP_VEC would be a bug, since it would leave a pointer to the
> > freed
> > device in the vector.
> > 
> > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> 
> Good catch. But we need to adapt libmultipath.version. I'll send a
> fix
> to be added on top.
> 
> Reviewed-by: Martin Wilck <mwilck@suse.com>

This breaks the directio test, too. We need a test patch on top.
I'm going to post it.

Martin


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map()
  2021-09-03 15:22     ` Martin Wilck
@ 2021-09-03 17:17       ` Benjamin Marzinski
  0 siblings, 0 replies; 11+ messages in thread
From: Benjamin Marzinski @ 2021-09-03 17:17 UTC (permalink / raw)
  To: Martin Wilck; +Cc: dm-devel

On Fri, Sep 03, 2021 at 03:22:45PM +0000, Martin Wilck wrote:
> On Fri, 2021-09-03 at 11:28 +0200, Martin Wilck wrote:
> > On Thu, 2021-09-02 at 16:57 -0500, Benjamin Marzinski wrote:
> > > When remove_map() is called, if the multipath device is in a mpvec,
> > > it
> > > must be removed from it, because the device will be freed. Now that
> > > the
> > > mpvec is passed as a separate parameter to remove_map(), the
> > > purge_vec
> > > parameter is redundant.  It was only used by coalesce_paths(),
> > > since
> > > the
> > > multipath device isn't on any vector when remove_map() is called
> > > there.
> > > Instead, remove_map() can just be called with a NULL mpvec, when
> > > there
> > > is no mpvec to remove the device from.
> > > 
> > > remove_map_by_alias() also has a redundant purge_vec parameter. 
> > > Since
> > > it only removes a map if it finds in on vec->mpvec, calling it with
> > > KEEP_VEC would be a bug, since it would leave a pointer to the
> > > freed
> > > device in the vector.
> > > 
> > > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> > 
> > Good catch. But we need to adapt libmultipath.version. I'll send a
> > fix
> > to be added on top.
> > 
> > Reviewed-by: Martin Wilck <mwilck@suse.com>
> 
> This breaks the directio test, too. We need a test patch on top.
> I'm going to post it.

Oops. Thanks.

-Ben

> 
> Martin

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-03 17:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 21:57 [dm-devel] [PATCH v2 0/6] Mulitpath: miscellaneous patches Benjamin Marzinski
2021-09-02 21:57 ` [dm-devel] [PATCH v2 1/6] multipath.conf: fix typo in ghost_delay description Benjamin Marzinski
2021-09-02 21:57 ` [dm-devel] [PATCH v2 2/6] mpathpersist: fail commands when no usable paths exist Benjamin Marzinski
2021-09-02 21:57 ` [dm-devel] [PATCH v2 3/6] multipath: print warning if multipathd is not running Benjamin Marzinski
2021-09-03  8:20   ` Martin Wilck
2021-09-02 21:57 ` [dm-devel] [PATCH v2 4/6] libmultipath: remove unneeded code in coalesce_paths Benjamin Marzinski
2021-09-02 21:57 ` [dm-devel] [PATCH v2 5/6] libmultipath: deal with dynamic PTHREAD_STACK_MIN Benjamin Marzinski
2021-09-02 21:57 ` [dm-devel] [PATCH v2 6/6] libmultipath: drop unnecessary parameter from remove_map() Benjamin Marzinski
2021-09-03  9:28   ` Martin Wilck
2021-09-03 15:22     ` Martin Wilck
2021-09-03 17:17       ` Benjamin Marzinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).