|
|
adddbf |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
adddbf |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
adddbf |
Date: Mon, 17 Jan 2022 14:45:38 -0600
|
|
|
adddbf |
Subject: [PATCH] libmultipath: make helper function to trigger path uevents
|
|
|
adddbf |
|
|
|
adddbf |
Pull the code that checks if a path needs to trigger a uevent, and
|
|
|
adddbf |
triggers, out of trigger_paths_udev_change() and into a new function,
|
|
|
adddbf |
trigger_path_udev_change(). This function will be used separately by
|
|
|
adddbf |
a future patch. No functional changes.
|
|
|
adddbf |
|
|
|
adddbf |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
adddbf |
---
|
|
|
adddbf |
libmultipath/configure.c | 79 +++++++++++++++++++++-------------------
|
|
|
adddbf |
libmultipath/configure.h | 1 +
|
|
|
adddbf |
2 files changed, 43 insertions(+), 37 deletions(-)
|
|
|
adddbf |
|
|
|
adddbf |
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
|
|
|
adddbf |
index 9c8d3e34..9a9890f5 100644
|
|
|
adddbf |
--- a/libmultipath/configure.c
|
|
|
adddbf |
+++ b/libmultipath/configure.c
|
|
|
adddbf |
@@ -545,11 +545,8 @@ unref:
|
|
|
adddbf |
}
|
|
|
adddbf |
|
|
|
adddbf |
void
|
|
|
adddbf |
-trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
|
|
|
adddbf |
+trigger_path_udev_change(struct path *pp, bool is_mpath)
|
|
|
adddbf |
{
|
|
|
adddbf |
- struct pathgroup *pgp;
|
|
|
adddbf |
- struct path *pp;
|
|
|
adddbf |
- int i, j;
|
|
|
adddbf |
/*
|
|
|
adddbf |
* If a path changes from multipath to non-multipath, we must
|
|
|
adddbf |
* synthesize an artificial "add" event, otherwise the LVM2 rules
|
|
|
adddbf |
@@ -557,6 +554,45 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
|
|
|
adddbf |
* irritate ourselves with an "add", so use "change".
|
|
|
adddbf |
*/
|
|
|
adddbf |
const char *action = is_mpath ? "change" : "add";
|
|
|
adddbf |
+ const char *env;
|
|
|
adddbf |
+
|
|
|
adddbf |
+ if (!pp->udev)
|
|
|
adddbf |
+ return;
|
|
|
adddbf |
+ /*
|
|
|
adddbf |
+ * Paths that are already classified as multipath
|
|
|
adddbf |
+ * members don't need another uevent.
|
|
|
adddbf |
+ */
|
|
|
adddbf |
+ env = udev_device_get_property_value(
|
|
|
adddbf |
+ pp->udev, "DM_MULTIPATH_DEVICE_PATH");
|
|
|
adddbf |
+
|
|
|
adddbf |
+ if (is_mpath && env != NULL && !strcmp(env, "1")) {
|
|
|
adddbf |
+ /*
|
|
|
adddbf |
+ * If FIND_MULTIPATHS_WAIT_UNTIL is not "0",
|
|
|
adddbf |
+ * path is in "maybe" state and timer is running
|
|
|
adddbf |
+ * Send uevent now (see multipath.rules).
|
|
|
adddbf |
+ */
|
|
|
adddbf |
+ env = udev_device_get_property_value(
|
|
|
adddbf |
+ pp->udev, "FIND_MULTIPATHS_WAIT_UNTIL");
|
|
|
adddbf |
+ if (env == NULL || !strcmp(env, "0"))
|
|
|
adddbf |
+ return;
|
|
|
adddbf |
+ } else if (!is_mpath &&
|
|
|
adddbf |
+ (env == NULL || !strcmp(env, "0")))
|
|
|
adddbf |
+ return;
|
|
|
adddbf |
+
|
|
|
adddbf |
+ condlog(3, "triggering %s uevent for %s (is %smultipath member)",
|
|
|
adddbf |
+ action, pp->dev, is_mpath ? "" : "no ");
|
|
|
adddbf |
+ sysfs_attr_set_value(pp->udev, "uevent",
|
|
|
adddbf |
+ action, strlen(action));
|
|
|
adddbf |
+ trigger_partitions_udev_change(pp->udev, action,
|
|
|
adddbf |
+ strlen(action));
|
|
|
adddbf |
+}
|
|
|
adddbf |
+
|
|
|
adddbf |
+void
|
|
|
adddbf |
+trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
|
|
|
adddbf |
+{
|
|
|
adddbf |
+ struct pathgroup *pgp;
|
|
|
adddbf |
+ struct path *pp;
|
|
|
adddbf |
+ int i, j;
|
|
|
adddbf |
|
|
|
adddbf |
if (!mpp || !mpp->pg)
|
|
|
adddbf |
return;
|
|
|
adddbf |
@@ -564,39 +600,8 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath)
|
|
|
adddbf |
vector_foreach_slot (mpp->pg, pgp, i) {
|
|
|
adddbf |
if (!pgp->paths)
|
|
|
adddbf |
continue;
|
|
|
adddbf |
- vector_foreach_slot(pgp->paths, pp, j) {
|
|
|
adddbf |
- const char *env;
|
|
|
adddbf |
-
|
|
|
adddbf |
- if (!pp->udev)
|
|
|
adddbf |
- continue;
|
|
|
adddbf |
- /*
|
|
|
adddbf |
- * Paths that are already classified as multipath
|
|
|
adddbf |
- * members don't need another uevent.
|
|
|
adddbf |
- */
|
|
|
adddbf |
- env = udev_device_get_property_value(
|
|
|
adddbf |
- pp->udev, "DM_MULTIPATH_DEVICE_PATH");
|
|
|
adddbf |
-
|
|
|
adddbf |
- if (is_mpath && env != NULL && !strcmp(env, "1")) {
|
|
|
adddbf |
- /*
|
|
|
adddbf |
- * If FIND_MULTIPATHS_WAIT_UNTIL is not "0",
|
|
|
adddbf |
- * path is in "maybe" state and timer is running
|
|
|
adddbf |
- * Send uevent now (see multipath.rules).
|
|
|
adddbf |
- */
|
|
|
adddbf |
- env = udev_device_get_property_value(
|
|
|
adddbf |
- pp->udev, "FIND_MULTIPATHS_WAIT_UNTIL");
|
|
|
adddbf |
- if (env == NULL || !strcmp(env, "0"))
|
|
|
adddbf |
- continue;
|
|
|
adddbf |
- } else if (!is_mpath &&
|
|
|
adddbf |
- (env == NULL || !strcmp(env, "0")))
|
|
|
adddbf |
- continue;
|
|
|
adddbf |
-
|
|
|
adddbf |
- condlog(3, "triggering %s uevent for %s (is %smultipath member)",
|
|
|
adddbf |
- action, pp->dev, is_mpath ? "" : "no ");
|
|
|
adddbf |
- sysfs_attr_set_value(pp->udev, "uevent",
|
|
|
adddbf |
- action, strlen(action));
|
|
|
adddbf |
- trigger_partitions_udev_change(pp->udev, action,
|
|
|
adddbf |
- strlen(action));
|
|
|
adddbf |
- }
|
|
|
adddbf |
+ vector_foreach_slot(pgp->paths, pp, j)
|
|
|
adddbf |
+ trigger_path_udev_change(pp, is_mpath);
|
|
|
adddbf |
}
|
|
|
adddbf |
|
|
|
adddbf |
mpp->needs_paths_uevent = 0;
|
|
|
adddbf |
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
|
|
|
adddbf |
index 8a266d31..5cf08d45 100644
|
|
|
adddbf |
--- a/libmultipath/configure.h
|
|
|
adddbf |
+++ b/libmultipath/configure.h
|
|
|
adddbf |
@@ -56,6 +56,7 @@ int get_refwwid (enum mpath_cmds cmd, char * dev, enum devtypes dev_type,
|
|
|
adddbf |
vector pathvec, char **wwid);
|
|
|
adddbf |
int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh, int is_daemon);
|
|
|
adddbf |
struct udev_device *get_udev_device(const char *dev, enum devtypes dev_type);
|
|
|
adddbf |
+void trigger_path_udev_change(struct path *pp, bool is_mpath);
|
|
|
adddbf |
void trigger_paths_udev_change(struct multipath *mpp, bool is_mpath);
|
|
|
adddbf |
void trigger_partitions_udev_change(struct udev_device *dev, const char *action,
|
|
|
adddbf |
int len);
|