From 5804e1b6ff2d871500f9bc205e6fa28d4e984961 Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Sat, 13 Jan 2018 12:30:43 +0000 Subject: [PATCH 1/2] core: fix output (logging) for mount units (#7603) Documentation - systemd.exec - strongly implies mount units get logging. It is safe for mounts to depend on systemd-journald.socket. There is no cyclic dependency generated. This is because the root, -.mount, was already deliberately set to EXEC_OUTPUT_NULL. See comment in mount_load_root_mount(). And /run is excluded from being a mount unit. Nor does systemd-journald depend on /var. It starts earlier, initially logging to /run. Tested before/after using `systemctl stop tmp.mount`. --- src/core/mount.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/mount.c b/src/core/mount.c index 9367869f781..9b0b29bff9e 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -164,6 +164,10 @@ static void mount_init(Unit *u) { assert(u->load_state == UNIT_STUB); m->timeout_usec = u->manager->default_timeout_start_usec; + + m->exec_context.std_output = u->manager->default_std_output; + m->exec_context.std_error = u->manager->default_std_error; + m->directory_mode = 0755; /* We need to make sure that /usr/bin/mount is always called From 3cc9685649000b9f840976d98396f55624f2329b Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Sat, 13 Jan 2018 17:22:46 +0000 Subject: [PATCH 2/2] core: prevent spurious retries of umount Testing the previous commit with `systemctl stop tmp.mount` logged the reason for failure as expected, but unexpectedly the message was repeated 32 times. The retry is a special case for umount; it is only supposed to cover the case where the umount command was _successful_, but there was still some remaining mount(s) underneath. Fix it by making sure to test the first condition :). Re-tested with and without a preceding `mount --bind /mnt /tmp`, and using `findmnt` to check the end result. --- src/core/mount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index 9b0b29bff9e..d424e5a3a85 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1309,7 +1309,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) { case MOUNT_UNMOUNTING_SIGKILL: case MOUNT_UNMOUNTING_SIGTERM: - if (m->from_proc_self_mountinfo) { + if (f == MOUNT_SUCCESS && m->from_proc_self_mountinfo) { /* Still a mount point? If so, let's try again. Most likely there were multiple mount points * stacked on top of each other. Note that due to the io event priority logic we can be sure @@ -1324,7 +1324,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) { mount_enter_mounted(m, f); } } else - mount_enter_dead(m, f); + mount_enter_dead_or_mounted(m, f); break;