From bdeb98c736df11e54d576c23d3e0f2625bee2135 Mon Sep 17 00:00:00 2001 From: khromenokroman Date: Fri, 30 Oct 2026 09:47:35 +0200 Subject: [PATCH] mountfsd: stop when the worker binary cannot be executed If systemd-mountwork cannot be executed, every worker fails immediately, and on_worker_exit() spawns a new one each time, until the rate limit is hit. Let the worker exit with EXIT_EXEC in that case, and exit the manager instead of respawning workers that fail the same way. Resource exhaustion (ENOMEM, EMFILE, ENFILE) is likely transient, so in that case the worker still exits with EXIT_FAILURE and is respawned as before. (cherry picked from commit e4b7e3763d9e0a4f4e7a81589826866a3b22e80a) (cherry picked from commit c47263b5a6c8cb6a2e273e67e5ce5544e09dfd6e) --- src/mountfsd/mountfsd-manager.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mountfsd/mountfsd-manager.c b/src/mountfsd/mountfsd-manager.c index 993dda95010..b7f321239f4 100644 --- a/src/mountfsd/mountfsd-manager.c +++ b/src/mountfsd/mountfsd-manager.c @@ -9,7 +9,9 @@ #include "build-path.h" #include "common-signal.h" #include "env-util.h" +#include "errno-util.h" #include "event-util.h" +#include "exit-status.h" #include "fd-util.h" #include "format-util.h" #include "log.h" @@ -43,6 +45,14 @@ static int on_worker_exit(sd_event_source *s, const siginfo_t *si, void *userdat sd_event_source_disable_unref(s); if (si->si_code == CLD_EXITED) { + if (si->si_status == EXIT_EXEC) { + /* The worker binary cannot be executed, respawning it would just fail the same way + * over and over again. Let's give up. */ + log_error("Worker " PID_FMT " failed to execute worker binary, exiting.", si->si_pid); + sd_event_exit(m->event, EXIT_FAILURE); + return 0; + } + if (si->si_status == EXIT_SUCCESS) log_debug("Worker " PID_FMT " exited successfully.", si->si_pid); else @@ -194,7 +204,7 @@ static int start_one_worker(Manager *m) { r = invoke_callout_binary(SYSTEMD_MOUNTWORK_PATH, STRV_MAKE("systemd-mountwork", "xxxxxxxxxxxxxxxx")); /* With some extra space rename_process() can make use of */ log_error_errno(r, "Failed to start worker process: %m"); - _exit(EXIT_FAILURE); + _exit(ERRNO_IS_NEG_RESOURCE(r) ? EXIT_FAILURE : EXIT_EXEC); } r = event_add_child_pidref(m->event, &source, &pidref, WEXITED, on_worker_exit, m);