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 e4b7e3763d)
(cherry picked from commit c47263b5a6)
This commit is contained in:
khromenokroman authored and Luca Boccassi committed 2026-11-05 14:48:09 +00:00
1 parent b7c8f5fd15
commit bdeb98c736
1 file changed
+11 -1
+11 -1
View File
@@ -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);