aed857
From b4f506932592b991363b8be11e40b62f861bd032 Mon Sep 17 00:00:00 2001
d16f06
From: Michael Olbrich <m.olbrich@pengutronix.de>
d16f06
Date: Fri, 24 Jul 2015 22:25:28 +0200
d16f06
Subject: [PATCH] automount: handle state changes of the corresponding mount
d16f06
 unit correctly
d16f06
d16f06
The expire timeout must be started/stopped if the corresponding mount unit
d16f06
changes its state, e.g. it is started via local-fs.target or stopped by a
d16f06
manual umount.
d16f06
d16f06
(cherry picked from commit 3dbadf9ef96e76f1bc472660ba5435dc0fa27a66)
d16f06
d16f06
Resolves: #1596241
d16f06
---
d16f06
 src/core/automount.c | 9 +++++----
d16f06
 1 file changed, 5 insertions(+), 4 deletions(-)
d16f06
d16f06
diff --git a/src/core/automount.c b/src/core/automount.c
Pablo Greco 48fc63
index 08519e49ca..f57782b9b8 100644
d16f06
--- a/src/core/automount.c
d16f06
+++ b/src/core/automount.c
d16f06
@@ -499,6 +499,7 @@ static int automount_send_ready(Automount *a, Set *tokens, int status) {
d16f06
 
d16f06
 int automount_update_mount(Automount *a, MountState old_state, MountState state) {
d16f06
         _cleanup_close_ int ioctl_fd = -1;
d16f06
+        int r;
d16f06
 
d16f06
         assert(a);
d16f06
 
d16f06
@@ -506,6 +507,9 @@ int automount_update_mount(Automount *a, MountState old_state, MountState state)
d16f06
         case MOUNT_MOUNTED:
d16f06
         case MOUNT_REMOUNTING:
d16f06
                 automount_send_ready(a, a->tokens, 0);
d16f06
+                r = automount_start_expire(a);
d16f06
+                if (r < 0)
d16f06
+                        log_unit_warning_errno(UNIT(a)->id, r, "Failed to start expiration timer, ignoring: %m");
d16f06
                 break;
d16f06
          case MOUNT_DEAD:
d16f06
          case MOUNT_UNMOUNTING:
d16f06
@@ -518,6 +522,7 @@ int automount_update_mount(Automount *a, MountState old_state, MountState state)
d16f06
          case MOUNT_FAILED:
d16f06
                 if (old_state != state)
d16f06
                         automount_send_ready(a, a->tokens, -ENODEV);
d16f06
+                (void) sd_event_source_set_enabled(a->expire_event_source, SD_EVENT_OFF);
d16f06
                 break;
d16f06
         default:
d16f06
                 break;
d16f06
@@ -768,10 +773,6 @@ static void automount_enter_running(Automount *a) {
d16f06
                 goto fail;
d16f06
         }
d16f06
 
d16f06
-        r = automount_start_expire(a);
d16f06
-        if (r < 0)
d16f06
-                log_unit_warning_errno(UNIT(a)->id, r, "Failed to start expiration timer, ignoring: %m");
d16f06
-
d16f06
         automount_set_state(a, AUTOMOUNT_RUNNING);
d16f06
         return;
d16f06