core/automount: log when pending requests cannot be released

When an automount goes away, answering the requests the kernel already
queued is the only thing that unblocks the processes waiting on them, and
nothing retries it later. If the `EHOSTDOWN` calls fail, it leaves the
requesting processes hung with no trace in the journal.

Log the failures to make this easier to debug. Also move that teardown into
a helper function, the next commit needs it as well.

Signed-off-by: Martin Pitt <martin@amutable.com>
This commit is contained in:
Martin Pitt
2026-09-11 08:18:43 +02:00
parent e2e536224d
commit 4558062cad
+18 -2
View File
@@ -59,6 +59,23 @@ static void automount_init(Unit *u) {
UNIT(a)->ignore_on_isolate = true;
}
/* Nothing else can answer the requests the kernel already queued for us, and it keeps their processes
* blocked until we do. Make a failure to do so at least visible. The status is what the mount requests get:
* an expire request can only ever fail. */
static void automount_release_requests(Automount *a, int status) {
int r;
assert(a);
r = automount_send_ready(a, a->tokens, status);
if (r < 0)
log_unit_warning_errno(UNIT(a), r, "Failed to release pending automount requests, ignoring: %m");
r = automount_send_ready(a, a->expire_tokens, -EHOSTDOWN);
if (r < 0)
log_unit_warning_errno(UNIT(a), r, "Failed to release pending automount expire requests, ignoring: %m");
}
static void unmount_autofs(Automount *a) {
int r;
@@ -73,8 +90,7 @@ static void unmount_autofs(Automount *a) {
/* If we reload/reexecute things we keep the mount point around */
if (!IN_SET(UNIT(a)->manager->objective, MANAGER_RELOAD, MANAGER_REEXECUTE)) {
automount_send_ready(a, a->tokens, -EHOSTDOWN);
automount_send_ready(a, a->expire_tokens, -EHOSTDOWN);
automount_release_requests(a, -EHOSTDOWN);
if (a->where) {
r = repeat_unmount(a->where, MNT_DETACH|UMOUNT_NOFOLLOW);