diff mbox series

[10/13] libmultipath: set need_reload when pp->serial gets set

Message ID 20250123031643.3017891-11-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: Benjamin Marzinski
Headers show
Series fix for GitHub issue #108 and misc cleanups | expand

Commit Message

Benjamin Marzinski Jan. 23, 2025, 3:16 a.m. UTC
If a multipath device has a path grouping policy of "group_by_serial"
and pp->serial wasn't previously set, set need_reload. If the multipath
device hasn't been created yet, need_reload will get cleared when the
device is created. If the multipath device already exists, the path
likely wasn't in the correct pathgroup, since it was unable to set
pp->serial before the paths were grouped.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/discovery.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 2015a32f..48e23d44 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -2317,6 +2317,7 @@  get_uid (struct path * pp, int path_state, struct udev_device *udev,
 int pathinfo(struct path *pp, struct config *conf, int mask)
 {
 	int path_state;
+	bool need_serial_recheck = false;
 
 	if (!pp || !conf)
 		return PATHINFO_FAILED;
@@ -2357,6 +2358,10 @@  int pathinfo(struct path *pp, struct config *conf, int mask)
 			   pp->dev) > 0)
 		return PATHINFO_SKIPPED;
 
+	if (pp->mpp && pp->mpp->pgpolicyfn == (pgpolicyfn *)group_by_serial &&
+	    pp->serial[0] == '\0')
+		need_serial_recheck = true;
+
 	condlog(4, "%s: mask = 0x%x", pp->dev, mask);
 
 	/*
@@ -2415,6 +2420,8 @@  int pathinfo(struct path *pp, struct config *conf, int mask)
 			    pp->state == PATH_UNCHECKED ||
 			    pp->state == PATH_WILD)
 				pp->chkrstate = pp->state = path_state;
+		if (need_serial_recheck && pp->serial[0] != '\0')
+			pp->mpp->need_reload = true;
 		return PATHINFO_OK;
 	}
 
@@ -2524,6 +2531,8 @@  int pathinfo(struct path *pp, struct config *conf, int mask)
 
 	if ((mask & DI_ALL) == DI_ALL)
 		pp->initialized = INIT_OK;
+	if (need_serial_recheck && pp->serial[0] != '\0')
+		pp->mpp->need_reload = true;
 	return PATHINFO_OK;
 
 blank: