multipath-tools: fixes for systemd watchdog
cover multipath-tools: fixes for systemd watchdog
A set of small fixes to make multipathd better adhere to the conventions for systemd's WatchdogSec= setting.
Martin Wilck (3):
libmultipath: don't print error message if WATCHDOG_USEC is 0
libmultipath: honor WATCHDOG_PID setting
libmultipath: cut watchdog interval in half
libmultipath/config.c | 21 ++++++++++++++++++--- libmultipath/config.h | 2 ++ libmultipath/libmultipath.version | 1 + 3 files changed, 21 insertions(+), 3 deletions(-)
Signature · 1 line
2.47.0
PATCH 1/3 libmultipath: don't print error message if WATCHDOG_USEC is 0
WATCHDOG_USEC may be set to 0, which means that the watchdog is disabled in systemd.
--- libmultipath/config.c | 3 +++ 1 file changed, 3 insertions(+)
libmultipath/config.c +3 -0
@@ -865,6 +865,9 @@ static void set_max_checkint_from_watchdog(struct config *conf)unsigned long checkint;if (envp &&sscanf (envp,"%lu" , &checkint) ==1 ) { +if (checkint ==0 ) +/* watchdog disabled */ +return ;/* Value is in microseconds */ checkint /=1000000 ;if (checkint <1 || checkint >UINT_MAX ) {
Signature · 1 line
2.47.0
PATCH 2/3 libmultipath: honor WATCHDOG_PID setting
In reply to Martin WilckWATCHDOG_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
--- libmultipath/config.c | 11 ++++++++++- libmultipath/config.h | 2 ++ libmultipath/libmultipath.version | 1 + 3 files changed, 13 insertions(+), 1 deletion(-)
libmultipath/config.c +10 -1
@@ -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 */
libmultipath/config.h +2 -0
@@ -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
libmultipath/libmultipath.version +1 -0
@@ -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;
Signature · 1 line
2.47.0
PATCH 3/3 libmultipath: cut watchdog interval in half
In reply to Martin WilckAccording to [1], a daemon should trigger the watchdog every half of the time that is communicated via WATCHDOG_USEC.
[1] https://www.freedesktop.org/software/systemd/man/latest/sd_watchdog_enabled.html
--- libmultipath/config.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
libmultipath/config.c +5 -2
@@ -877,8 +877,11 @@ static void set_max_checkint_from_watchdog(struct config *conf)if (checkint ==0 )/* watchdog disabled */ return ; -/* Value is in microseconds */ - checkint /=1000000 ; +/* +* Value is in microseconds, and we should trigger the watchdog +* twice per interval. +*/ + checkint /=2000000 ;if (checkint <1 || checkint >UINT_MAX ) {condlog (1 ,"invalid value for WatchdogSec: \"%s\"" , envp);return ;
Signature · 1 line
2.47.0
Quoted 1 line · Martin Wilck
A set of small fixes to make multipathd better adhere to the conventions
I'm a little confused by this. Your patches make sense, but why do we bother limiting max_checkint to the Watchdog timer? We send a notify every loop in checkerloop() regardless. Changing max_checkint won't make us any less likely to hang for too long if we're using a synchronous chacker, and I can't figure out why the Watchdog time should have anything to do with how frequently we check working paths.
Your code changes looks fine, so assuming there's a use for this code:
But possibly we should be removing set_max_checkint_from_watchdog(), or replacing max_checkint with something like checker_timeout, but only for synchronous checkers. Or possibly I'm just missing something here.
-Ben
Quoted 14 lines
for systemd's WatchdogSec= setting.
Martin Wilck (3):
libmultipath: don't print error message ifWATCHDOG_USECis 0
libmultipath: honorWATCHDOG_PIDsetting
libmultipath: cut watchdog interval in halflibmultipath/config.c | 21 ++++++++++++++++++--- libmultipath/config.h | 2 ++ libmultipath/libmultipath.version | 1 + 3 files changed, 21 insertions(+), 3 deletions(-)Signature · 1 line
2.47.0