Skip to contentSkip to conversation

Mulitpath: miscellaneous patches

PATCH Superseded Benjamin Marzinski 2 participants 12 messages Jul 29, 2021 – Aug 30, 2021 Device mapper

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

cover Mulitpath: miscellaneous patches

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

Benjamin Marzinski (5):
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

 libmpathpersist/mpath_persist.c   |  8 ++++-
 libmultipath/configure.c          | 57 ++++++-------------------------
 libmultipath/configure.h          |  1 +
 libmultipath/libmultipath.version |  5 +++
 libmultipath/util.c               |  4 +--
 multipath/main.c                  |  5 +++
 multipath/multipath.conf.5        |  2 +-
 7 files changed, 31 insertions(+), 51 deletions(-)
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#1 lore raw

PATCH 1/5 multipath.conf: fix typo in ghost_delay description

---
 multipath/multipath.conf.5 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/multipath.conf.5 +1 -1
index 064e4826..d6b8c7f6 100644
@@ -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
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
author maintainer
#3 lore raw

PATCH 2/5 mpathpersist: fail commands when no usable paths exist

In reply to Benjamin Marzinski

"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.

---
 libmpathpersist/mpath_persist.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
libmpathpersist/mpath_persist.c +7 -1
index 190e9707..26710e79 100644
@@ -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++){
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Reviewed-by on v1 2/5
#4 lore raw

Re: [dm-devel] [PATCH 2/5] mpathpersist: fail commands when no usable paths exist

Quoted 7 lines · Benjamin Marzinski

"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.

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

author maintainer
#5 lore raw

PATCH 3/5 multipath: print warning if multipathd is not running.

In reply to Benjamin Marzinski

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.

---
 libmultipath/configure.c          | 13 +++++++++++--
 libmultipath/configure.h          |  1 +
 libmultipath/libmultipath.version |  5 +++++
 multipath/main.c                  |  5 +++++
 4 files changed, 22 insertions(+), 2 deletions(-)
libmultipath/configure.c +11 -2
index 12278640..0c00bf50 100644
@@ -1082,7 +1082,8 @@ deadmap (struct multipath * mpp)
 	return 1; /* dead */
 }
 
-int check_daemon(void)
+extern int
+check_daemon(void)
 {
 	int fd;
 	char *reply;
@@ -1137,6 +1138,8 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 	struct config *conf = NULL;
 	int allow_queueing;
 	struct bitfield *size_mismatch_seen;
+	bool map_processed = false;
+	bool no_daemon = false;
 
 	/* ignore refwwid if it's empty */
 	if (refwwid && !strlen(refwwid))
@@ -1288,7 +1291,9 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 		conf = get_multipath_config();
 		allow_queueing = conf->allow_queueing;
 		put_multipath_config(conf);
-		if (!is_daemon && !allow_queueing && !check_daemon()) {
+		if (!is_daemon && !allow_queueing &&
+		    (no_daemon || !check_daemon())) {
+			no_daemon = true;
 			if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF &&
 			    mpp->no_path_retry != NO_PATH_RETRY_FAIL)
 				condlog(3, "%s: multipathd not running, unset "
@@ -1311,6 +1316,7 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 		else
 			remove_map(mpp, vecs->pathvec, vecs->mpvec,
 				   KEEP_VEC);
+		map_processed = true;
 	}
 	/*
 	 * Flush maps with only dead paths (ie not in sysfs)
@@ -1336,6 +1342,9 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 				condlog(2, "%s: remove (dead)", alias);
 		}
 	}
+	if (map_processed && !is_daemon && (no_daemon || !check_daemon()))
+		condlog(2, "multipath devices exist, but multipathd service is not running");
+
 	ret = CP_OK;
 out:
 	free(size_mismatch_seen);
libmultipath/configure.h +1 -0
index 92a5aba6..efe18b7d 100644
@@ -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);
libmultipath/libmultipath.version +5 -0
index 1d84d97c..7b48265f 100644
@@ -285,3 +285,8 @@ global:
 	print_strbuf;
 	truncate_strbuf;
 } LIBMULTIPATH_8.0.0;
+
+LIBMULTIPATH_8.2.0 {
+global:
+	check_daemon;
+} LIBMULTIPATH_8.1.0;
multipath/main.c +5 -0
index 8fc0e15f..33377147 100644
@@ -180,6 +180,7 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)
 	int i;
 	struct multipath * mpp;
 	int flags = (cmd == CMD_LIST_SHORT ? DI_NOIO : DI_ALL);
+	bool maps_present = false;
 
 	if (dm_get_maps(curmp))
 		return 1;
@@ -212,11 +213,15 @@ get_dm_mpvec (enum mpath_cmds cmd, vector curmp, vector pathvec, char * refwwid)
 
 		if (cmd == CMD_CREATE)
 			reinstate_paths(mpp);
+
+		maps_present = true;
 	}
 
 	if (cmd == CMD_LIST_SHORT || cmd == CMD_LIST_LONG)
 		print_foreign_topology(libmp_verbosity);
 
+	if (maps_present && !check_daemon())
+		condlog(2, "multipath devices exist, but multipathd service is not running");
 	return 0;
 }
 
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#6 lore raw

Re: [dm-devel] [PATCH 3/5] multipath: print warning if multipathd is not running.

Quoted 7 lines · Benjamin Marzinski

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.

I'm not sure about this. Are there zero valid use cases for using multipath without multipathd? On production systems, I agree, multipathd should always be running. Personally wouldn't want to see this warning every time I run "multipath" while multipathd is (temporarily) disabled. Have you got user requests for this feature?

In particular, I dislike the idea of putting this code into libmultipath. I would love to get rid of the "is_daemon" logic some day. If at all, the detection of the situation and the warning should be implemented in multipath, IMO.

The message should be prefixed with the word "Warning: " to make sure the admin understands that he's supposed to take action.

Regards,
Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

author maintainer
#7 lore raw

Re: [dm-devel] [PATCH 3/5] multipath: print warning if multipathd is not running.

Quoted 11 lines · Martin Wilck
Quoted 7 lines · Benjamin Marzinski

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.

I'm not sure about this. Are there zero valid use cases for using multipath without multipathd?

There certainly are. That's why I tried to limit the warning to only cases where the user was creating, reloading, or listing devices and found/created some. In testing, sure, you might want multipathd disabled, but in general, if you have multipath devices, you want multipathd running. If you have it temporarily disabled for some reason, I don't see much harm in having multipath remind you of that.

Quoted 4 lines

On production systems, I agree,
multipathd should always be running. Personally wouldn't want to see this warning every time I run "multipath" while multipathd is (temporarily) disabled. Have you got user requests for this feature?

Well, Support has requested this. Apparently they have repeatedly seen cases where people don't have any multipath devices present, because multipathd is not running. They run multipath, the devices appear, and they move on, unaware that multipathd isn't running for whatever reason.

Quoted 4 lines

In particular, I dislike the idea of putting this code into libmultipath. I would love to get rid of the "is_daemon" logic some day. If at all, the detection of the situation and the warning should be implemented in multipath, IMO.

Sure. I can rework this to keep the logic inside multipath,

Quoted 2 lines

The message should be prefixed with the word "Warning: " to make sure the admin understands that he's supposed to take action.

Makes sense.

-Ben

Quoted 2 lines

Regards,
Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

author maintainer
#8 lore raw

PATCH 4/5 libmultipath: remove unneeded code in coalesce_paths

In reply to Benjamin Marzinski

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.

---
 libmultipath/configure.c | 46 ----------------------------------------
 1 file changed, 46 deletions(-)
libmultipath/configure.c +0 -46
index 0c00bf50..e64eb7bc 100644
@@ -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)
 {
@@ -1318,30 +1296,6 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 				   KEEP_VEC);
 		map_processed = true;
 	}
-	/*
-	 * 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);
-		}
-	}
 	if (map_processed && !is_daemon && (no_daemon || !check_daemon()))
 		condlog(2, "multipath devices exist, but multipathd service is not running");
 
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Reviewed-by on v1 4/5
#9 lore raw

Re: [dm-devel] [PATCH 4/5] libmultipath: remove unneeded code in coalesce_paths

Quoted 10 lines · Benjamin Marzinski

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.

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

author maintainer
#10 lore raw

PATCH 5/5 libmultipath: deal with dynamic PTHREAD_STACK_MIN

In reply to Benjamin Marzinski

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.

---
 libmultipath/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libmultipath/util.c +2 -2
index e2fafe85..ea858409 100644
@@ -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) {
Signature · 6 lines
2.17.2

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
Reviewed-by on v1 5/5
#11 lore raw

Re: [dm-devel] [PATCH 5/5] libmultipath: deal with dynamic PTHREAD_STACK_MIN

Quoted 7 lines · Benjamin Marzinski

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.

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel