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