core: prevent spurious retries of umount
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Sat, 13 Jan 2018 17:22:46 +0000 (17:22 +0000)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Sat, 13 Jan 2018 17:22:46 +0000 (17:22 +0000)
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

index 9b0b29b..d424e5a 100644 (file)
@@ -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;