Skip to contentSkip to conversation

multipathd: Miscellaneous fixes

PATCH In review Benjamin Marzinski 2 participants 6 messages Jan 21 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

v2 cover multipathd: Miscellaneous fixes

These are a just collection of unrelated multipath fixes. The first one keeps new maps from adding non-discovered paths in configure(). The second one makes sure that paths that were offline when multipathd was started or reconfigured get the pathinfo checked and get the proper initialization state, when the come online. The third improves the "busy" state output in "multipathd show status". And the fourth one make sure that multipathd prints the "path offline" message for paths that are part of multipath devices but were offline when mutipathd was started or reconfigured.

Changes from v1 (as suggested by Martin Wilck):
2/4: Switched to using size-limiting string functions, and refactored
the code for rechecking the WWID
3/4: Stopped accessing servicing_uev as an atomic
4/4: switched from checking (pp->sysfs_state == PATH_DOWN) to

     (p->sysfs_state != PATH_UP)

Benjamin Marzinski (4):
multipathd: don't add removed/partial paths to new maps
multipathd: finish initalization of paths added while offline
multipathd: make "multipathd show status" busy checker better
multipathd: print path offline message even without a checker

 libmultipath/configure.c   | 12 +++++++-
 libmultipath/discovery.c   |  2 ++
 libmultipath/structs_vec.c |  3 +-
 libmultipath/uevent.c      |  9 ++++--
 multipathd/main.c          | 60 +++++++++++++++++++++++++++++++-------
 5 files changed, 71 insertions(+), 15 deletions(-)
Signature · 1 line
2.50.1
author maintainer
#1 lore raw

PATCH v2 1/4 multipathd: don't add removed/partial paths to new maps

During configure(), when the old multipath devices are added in map_discovery(), it's possible that they have paths in the INIT_PARTIAL or INIT_REMOVED state. These paths were not found during path_discovery(). Don't add them to the new multipath maps. coalesce_maps() will make sure that they point to the old maps, so they will get cleaned up when those maps are removed.

---
 libmultipath/configure.c   | 12 +++++++++++-
 libmultipath/structs_vec.c |  3 ++-
 2 files changed, 13 insertions(+), 2 deletions(-)
libmultipath/configure.c +11 -1
index 0bcec089..a713ddc4 100644
@@ -1113,7 +1113,17 @@ int coalesce_paths (struct vectors *vecs, vector mpvec, char *refwwid,
 			continue;
 		}
 
-		/* 4. path is out of scope */
+		/*
+		 * 4. The path wasn't found in path_discovery. It only exists
+		 *    in an old map.
+		 */
+		if (pp1->initialized == INIT_PARTIAL ||
+		    pp1->initialized == INIT_REMOVED) {
+			orphan_path(pp1, "path not found");
+			continue;
+		}
+
+		/* 5. path is out of scope */
 		if (refwwid && strncmp(pp1->wwid, refwwid, WWID_SIZE - 1))
 			continue;
 
libmultipath/structs_vec.c +2 -1
index 9384de01..3e63e9c3 100644
@@ -315,7 +315,8 @@ int adopt_paths(vector pathvec, struct multipath *mpp,
 					pp->dev, mpp->alias);
 				continue;
 			}
-			if (pp->initialized == INIT_REMOVED)
+			if (pp->initialized == INIT_REMOVED ||
+			    pp->initialized == INIT_PARTIAL)
 				continue;
 			if (mpp->queue_mode == QUEUE_MODE_RQ &&
 			    pp->bus == SYSFS_BUS_NVME &&
Signature · 1 line
2.50.1
author maintainer
#2 lore raw

PATCH v2 2/4 multipathd: finish initalization of paths added while offline

In reply to Benjamin Marzinski

If a path in a mulitpath device is offline while multipathd is reconfigured, it will get added to the updated multipath device, just like it was in the old multipath device. However the device will still be in the INIT_NEW state because it can't get initilized while offline. This is different than the INIT_PARTIAL state because the path was discovered in path_discovery(). INIT_PARTIAL is for paths that multipathd did not discover in path_discovery() or receive a uevent for, but are part of a multipath device that was added, and which should receive a uevent shortly. There is no reason to expect a uevent for these offline paths.

When the path comes back online, multipathd will run the checker and prioritizer on it. The only two pathinfo checks that won't happen are the DI_WWID and DI_IOCTL ones. Modify pathinfo() to make sure that if DI_IOCTL was skipped for offline paths, it gets called the next time pathinfo() is called after the fd can be opened. Also, make sure that when one of these offline paths becomes usable, its WWID is rechecked. With those changes, all the DI_ALL checks will be accounted for, and the path can be marked INIT_OK.

---
 libmultipath/discovery.c |  2 ++
 multipathd/main.c        | 53 ++++++++++++++++++++++++++++++++++------
 2 files changed, 48 insertions(+), 7 deletions(-)
libmultipath/discovery.c +2 -0
index 0c5e5ca6..0efb8213 100644
@@ -2585,6 +2585,8 @@ blank:
 	 * Recoverable error, for example faulty or offline path
 	 */
 	pp->chkrstate = pp->state = PATH_DOWN;
+	if (mask & DI_IOCTL && pp->ioctl_info == IOCTL_INFO_NOT_REQUESTED)
+		pp->ioctl_info = IOCTL_INFO_SKIPPED;
 	if (pp->initialized == INIT_NEW || pp->initialized == INIT_FAILED)
 		memset(pp->wwid, 0, WWID_SIZE);
 
multipathd/main.c +46 -7

66 lines not on this page · raw message

Signature · 1 line
2.50.1
author maintainer
#3 lore raw

PATCH v2 3/4 multipathd: make "multipathd show status" busy checker better

In reply to Benjamin Marzinski

while uevent_listen() was grabbing new uevents, "multipathd show status" would still show show busy as "False". Add a check there, to make catch multipathd's uevent processing earlier. Also, access servicing_uev (as well as the new variable, adding_uev) atomically, just to make sure that the compiler doesn't do stupid things trying to optimize them.

---
 libmultipath/uevent.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
libmultipath/uevent.c +7 -2
index be199af0..3409ec9c 100644
@@ -52,6 +52,7 @@ static pthread_cond_t *uev_condp = &uev_cond;
 static uev_trigger *my_uev_trigger;
 static void *my_trigger_data;
 static int servicing_uev;
+static int adding_uev;	  /* uatomic access only */
 
 struct uevent_filter_state {
 	struct list_head uevq;
@@ -70,13 +71,14 @@ static void reset_filter_state(struct uevent_filter_state *st)
 
 int is_uevent_busy(void)
 {
-	int empty, servicing;
+	int empty, servicing, adding;
 
 	pthread_mutex_lock(uevq_lockp);
 	empty = list_empty(&uevq);
 	servicing = servicing_uev;
+	adding = uatomic_read(&adding_uev);
 	pthread_mutex_unlock(uevq_lockp);
-	return (!empty || servicing);
+	return (!empty || servicing || adding);
 }
 
 struct uevent * alloc_uevent (void)
@@ -730,6 +732,7 @@ int uevent_listen(struct udev *udev)
 		int fdcount, events;
 		struct pollfd ev_poll = { .fd = fd, .events = POLLIN, };
 
+		uatomic_set(&adding_uev, 0);
 		fdcount = poll(&ev_poll, 1, -1);
 		if (fdcount < 0) {
 			if (errno == EINTR)
@@ -739,6 +742,8 @@ int uevent_listen(struct udev *udev)
 			err = -errno;
 			break;
 		}
+		uatomic_set(&adding_uev, 1);
+
 		events = uevent_receive_events(fd, &uevlisten_tmp, monitor);
 		if (events <= 0)
 			continue;
Signature · 1 line
2.50.1
author maintainer
#4 lore raw

PATCH v2 4/4 multipathd: print path offline message even without a checker

In reply to Benjamin Marzinski

If a path has a checker selected and is offline, multipathd will print a "path offline" message. However if the checker isn't selected, for instance because multipathd was started or reconfigured while the path was offline, multipathd was not printing the "path offline" message. Fix that.

---
 multipathd/main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
multipathd/main.c +3 -4
index 90472d69..05dd65e6 100644
@@ -96,12 +96,11 @@ mpath_pr_event_handle(struct path *pp, unsigned int nr_keys_needed,
 
 #define LOG_MSG(lvl, pp)					\
 do {								\
-	if (pp->mpp && checker_selected(&pp->checker) &&	\
-	    lvl <= libmp_verbosity) {					\
-		if (pp->sysfs_state == PATH_DOWN)		\
+	if (pp->mpp && lvl <= libmp_verbosity) {		\
+		if (pp->sysfs_state != PATH_UP)			\
 			condlog(lvl, "%s: %s - path offline",	\
 				pp->mpp->alias, pp->dev);	\
-		else  {						\
+		else if (checker_selected(&pp->checker)) {	\
 			const char *__m =			\
 				checker_message(&pp->checker);	\
 								\
Signature · 1 line
2.50.1
Reviewed-by on the v2 series
#5 lore raw
In reply to Benjamin Marzinski
Quoted 26 lines · Benjamin Marzinski

These are a just collection of unrelated multipath fixes. The first one
keeps new maps from adding non-discovered paths in configure(). The second one makes sure that paths that were offline when multipathd was
started or reconfigured get the pathinfo checked and get the proper initialization state, when the come online. The third improves the "busy" state output in "multipathd show status". And the fourth one make
sure that multipathd prints the "path offline" message for paths that are part of multipath devices but were offline when mutipathd was started or reconfigured.

Changes from v1 (as suggested by Martin Wilck):
2/4: Switched to using size-limiting string functions, and refactored the code for rechecking the WWID
3/4: Stopped accessing servicing_uev as an atomic
4/4: switched from checking (pp->sysfs_state == PATH_DOWN) to (p->sysfs_state != PATH_UP)

Benjamin Marzinski (4):
  multipathd: don't add removed/partial paths to new maps
  multipathd: finish initalization of paths added while offline
  multipathd: make "multipathd show status" busy checker better
  multipathd: print path offline message even without a checker

Quoted 7 lines

 libmultipath/configure.c   | 12 +++++++- libmultipath/discovery.c   |  2 ++ libmultipath/structs_vec.c |  3 +-
 libmultipath/uevent.c      |  9 ++++--
 multipathd/main.c          | 60 +++++++++++++++++++++++++++++++----- --

 5 files changed, 71 insertions(+), 15 deletions(-)

For the series: