[PATCH 2/3] libmultipath: honor WATCHDOG_PID setting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



WATCHDOG_USEC should only be evaluated if WATCHDOG_PID is either
unset (systemd <= 208) or set to the main daemon's pid [1].

Passing the daemon's PID to set_max_checkint_from_watchdog() requires
a mechanism similar to what we've been using for get_multipath_config().

[1] https://www.freedesktop.org/software/systemd/man/latest/sd_watchdog_enabled.html

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/config.c             | 11 ++++++++++-
 libmultipath/config.h             |  2 ++
 libmultipath/libmultipath.version |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 226ddec..bd199fa 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -858,12 +858,21 @@ process_config_dir(struct config *conf, char *dir)
 	pthread_cleanup_pop(1);
 }
 
+__attribute__((weak)) pid_t daemon_pid = -1;
+
 #ifdef USE_SYSTEMD
 static void set_max_checkint_from_watchdog(struct config *conf)
 {
-	char *envp = getenv("WATCHDOG_USEC");
+	const char *envp;
 	unsigned long checkint;
+	long pid;
 
+	envp = getenv("WATCHDOG_PID");
+	/* See sd_watchdog_enabled(3) */
+	if (envp && sscanf(envp, "%lu", &pid) == 1 && pid != daemon_pid)
+		return;
+
+	envp = getenv("WATCHDOG_USEC");
 	if (envp && sscanf(envp, "%lu", &checkint) == 1) {
 		if (checkint == 0)
 			/* watchdog disabled */
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 94cdf25..d12f63e 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -315,4 +315,6 @@ int parse_uid_attrs(char *uid_attrs, struct config *conf);
 const char *get_uid_attribute_by_attrs(const struct config *conf,
 				       const char *path_dev);
 
+/* Weak dummy function, meant to be overridden by multipathd */
+extern pid_t daemon_pid;
 #endif
diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version
index 6bdf694..a898f7a 100644
--- a/libmultipath/libmultipath.version
+++ b/libmultipath/libmultipath.version
@@ -70,6 +70,7 @@ global:
 	cleanup_multipath_and_paths;
 	coalesce_paths;
 	count_active_paths;
+	daemon_pid;
 	delete_all_foreign;
 	delete_foreign;
 	dm_cancel_deferred_remove;
-- 
2.47.0





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux