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