diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-28 20:01:24 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-12-07 17:35:32 +0100 |
commit | 7eba1463dedcae252a75b5aaddf9fb66d9fd8a38 (patch) | |
tree | 50d19098c94f8f514976404fc5709aa91c4a079f /src/core/mount.c | |
parent | mount: replace three closely related mount flags into a proper flags enum (diff) | |
download | systemd-7eba1463dedcae252a75b5aaddf9fb66d9fd8a38.tar.xz systemd-7eba1463dedcae252a75b5aaddf9fb66d9fd8a38.zip |
mount: flush out cycle state on DEAD→MOUNTED only, not the other way round
For services (and other units) we generally follow the rule that at the
beginning of each cycle, i.e. when the INACTIVE/FAILED state is left for
ACTIVATING/ACTIVE we flush out various state variables. Mount units
handled this differently so far when the unit state change was effected
outside of systemd: in that case these variables would be flushed out
when going back to INACTIVE/FAILED already.
Let's fix that, and flush out this state always during the activating
transition, not during the deactivating transition.
Diffstat (limited to '')
-rw-r--r-- | src/core/mount.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/mount.c b/src/core/mount.c index ccc0559def..ead9bc1f44 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1057,6 +1057,17 @@ fail: mount_enter_dead_or_mounted(m, MOUNT_SUCCESS); } +static void mount_cycle_clear(Mount *m) { + assert(m); + + /* Clear all state we shall forget for this new cycle */ + + m->result = MOUNT_SUCCESS; + m->reload_result = MOUNT_SUCCESS; + exec_command_reset_status_array(m->exec_command, _MOUNT_EXEC_COMMAND_MAX); + UNIT(m)->reset_accounting = true; +} + static int mount_start(Unit *u) { Mount *m = MOUNT(u); int r; @@ -1087,13 +1098,9 @@ static int mount_start(Unit *u) { if (r < 0) return r; - m->result = MOUNT_SUCCESS; - m->reload_result = MOUNT_SUCCESS; - exec_command_reset_status_array(m->exec_command, _MOUNT_EXEC_COMMAND_MAX); - - u->reset_accounting = true; - + mount_cycle_clear(m); mount_enter_mounting(m); + return 1; } @@ -1841,10 +1848,7 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, switch (mount->state) { case MOUNT_MOUNTED: - /* This has just been unmounted by - * somebody else, follow the state - * change. */ - mount->result = MOUNT_SUCCESS; /* make sure we forget any earlier umount failures */ + /* This has just been unmounted by somebody else, follow the state change. */ mount_enter_dead(mount, MOUNT_SUCCESS); break; @@ -1863,7 +1867,8 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, /* This has just been mounted by somebody else, follow the state change, but let's * generate a new invocation ID for this implicitly and automatically. */ - (void) unit_acquire_invocation_id(UNIT(mount)); + (void) unit_acquire_invocation_id(u); + mount_cycle_clear(mount); mount_enter_mounted(mount, MOUNT_SUCCESS); break; |