diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-09-25 18:56:19 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-09-26 16:17:22 +0200 |
commit | 850b741084fd58573f5f804a434e2fa9ee7bd1c8 (patch) | |
tree | 75265254e66261739b2e59d0acd07b82b008a69f /src | |
parent | service: rework service_kill_control_processes() (diff) | |
download | systemd-850b741084fd58573f5f804a434e2fa9ee7bd1c8.tar.xz systemd-850b741084fd58573f5f804a434e2fa9ee7bd1c8.zip |
mount: clean up reload_result management a bit
Let's only collect the first failure in the load result, and let's clear
it explicitly when we are about to enter a new reload operation. This
makes it more alike the handling of the main result value (which also
only stores the first failure), and also the handling of service.c's
reload state.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/mount.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/mount.c b/src/core/mount.c index 46bcf37ae0..780e050daf 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -653,7 +653,6 @@ static void mount_set_state(Mount *m, MountState state) { log_unit_debug(UNIT(m), "Changed %s -> %s", mount_state_to_string(old_state), mount_state_to_string(state)); unit_notify(UNIT(m), state_translation_table[old_state], state_translation_table[state], m->reload_result == MOUNT_SUCCESS); - m->reload_result = MOUNT_SUCCESS; } static int mount_coldplug(Unit *u) { @@ -964,12 +963,25 @@ fail: mount_enter_dead(m, MOUNT_FAILURE_RESOURCES); } +static void mount_set_reload_result(Mount *m, MountResult result) { + assert(m); + + /* Only store the first error we encounter */ + if (m->reload_result != MOUNT_SUCCESS) + return; + + m->reload_result = result; +} + static void mount_enter_remounting(Mount *m) { int r; MountParameters *p; assert(m); + /* Reset reload result when we are about to start a new remount operation */ + m->reload_result = MOUNT_SUCCESS; + m->control_command_id = MOUNT_EXEC_REMOUNT; m->control_command = m->exec_command + MOUNT_EXEC_REMOUNT; @@ -1007,7 +1019,7 @@ static void mount_enter_remounting(Mount *m) { fail: log_unit_warning_errno(UNIT(m), r, "Failed to run 'remount' task: %m"); - m->reload_result = MOUNT_FAILURE_RESOURCES; + mount_set_reload_result(m, MOUNT_FAILURE_RESOURCES); mount_enter_mounted(m, MOUNT_SUCCESS); } @@ -1210,7 +1222,9 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) { else assert_not_reached("Unknown code"); - if (m->result == MOUNT_SUCCESS) + if (IN_SET(m->state, MOUNT_REMOUNTING, MOUNT_REMOUNTING_SIGKILL, MOUNT_REMOUNTING_SIGTERM)) + mount_set_reload_result(m, f); + else if (m->result == MOUNT_SUCCESS) m->result = f; if (m->control_command) { |