diff mbox

[RFC,16/16] libmultipath: trigger path uevent only when necessary

Message ID 20180119002916.10323-17-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Martin Wilck Jan. 19, 2018, 12:29 a.m. UTC
Paths that are already classified as DM_MULTIPATH_DEVICE_PATH don't
need to be retriggered. As an exception, trigger events for paths in
"maybe" state that are waiting to be updated.
---
 libmultipath/configure.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox

Patch

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index c08ea5b8decc..f8d1fa452014 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -447,8 +447,28 @@  trigger_paths_udev_change(const struct multipath *mpp)
 		if (!pgp->paths)
 			continue;
 		vector_foreach_slot(pgp->paths, pp, j) {
+			const char *env;
+
 			if (!pp->udev)
 				continue;
+			/*
+			 * Paths that are already classified as multipath
+			 * members don't need another uevent.
+			 */
+			env = udev_device_get_property_value(
+				pp->udev, "DM_MULTIPATH_DEVICE_PATH");
+			if (env != NULL && !strcmp(env, "1")) {
+				/*
+				 * Nonempty DM_MULTIPATH_SAVED_FS_TYPE means
+				 * path is in "maybe" state and timer is running
+				 * Send uevent now (see multipath.rules).
+				 */
+				env = udev_device_get_property_value(
+					pp->udev, "DM_MULTIPATH_SAVED_FS_TYPE");
+				if (env == NULL)
+					continue;
+			}
+			condlog(4, "triggering change uevent for %s", pp->dev);
 			sysfs_attr_set_value(pp->udev, "uevent", "change",
 					     strlen("change"));
 		}