summaryrefslogtreecommitdiff
path: root/src/core/shutdown.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-06-26 01:41:04 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-06-26 01:41:04 -0400
commit8c9778383b2cf64c45323bb10b741aa3beae28ca (patch)
tree7277f83b2e3e8e011f7b2604613c3722681bd988 /src/core/shutdown.c
parent260ad50f5b4a9795032e3119c64f838a2d03370d (diff)
shutdown: rework messages during shutdown
When running in 'quiet' mode, the only message printed from shutdown binary would be 'Cannot finalize remaining file systems and devices, giving up.', the only log line at error level before switch back to initramfs. This is misleading, because in initramfs everything will be cleaned up properly. Avoid printing anything at error level before the attempt to switch back to initramfs. Rework the messages to contain a bit more information what is still remaining, to help people diagnose shutdown issues.
Diffstat (limited to 'src/core/shutdown.c')
-rw-r--r--src/core/shutdown.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 7ef671ad0..fde3ce9c2 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -220,7 +220,7 @@ static int pivot_to_new_root(void) {
}
int main(int argc, char *argv[]) {
- bool need_umount = true, need_swapoff = true, need_loop_detach = true, need_dm_detach = true;
+ bool need_umount, need_swapoff, need_loop_detach, need_dm_detach;
bool in_container, use_watchdog = false;
_cleanup_free_ char *cgroup = NULL;
char *arguments[3];
@@ -246,8 +246,6 @@ int main(int argc, char *argv[]) {
goto error;
}
- in_container = detect_container(NULL) > 0;
-
if (streq(arg_verb, "reboot"))
cmd = RB_AUTOBOOT;
else if (streq(arg_verb, "poweroff"))
@@ -275,11 +273,12 @@ int main(int argc, char *argv[]) {
log_info("Sending SIGKILL to remaining processes...");
broadcast_signal(SIGKILL, true, false);
- if (in_container) {
- need_swapoff = false;
- need_dm_detach = false;
- need_loop_detach = false;
- }
+ in_container = detect_container(NULL) > 0;
+
+ need_umount = true;
+ need_swapoff = !in_container;
+ need_loop_detach = !in_container;
+ need_dm_detach = !in_container;
/* Unmount all mountpoints, swaps, and loopback devices */
for (retries = 0; retries < FINALIZE_ATTEMPTS; retries++) {
@@ -347,23 +346,31 @@ int main(int argc, char *argv[]) {
if (retries > 0)
log_info("All filesystems, swaps, loop devices, DM devices detached.");
/* Yay, done */
- break;
+ goto initrd_jump;
}
/* If in this iteration we didn't manage to
* unmount/deactivate anything, we simply give up */
if (!changed) {
- log_error("Cannot finalize remaining file systems and devices, giving up.");
- break;
+ log_info("Cannot finalize remaining%s%s%s%s continuing.",
+ need_umount ? " file systems," : "",
+ need_swapoff ? " swap devices," : "",
+ need_loop_detach ? " loop devices," : "",
+ need_dm_detach ? " DM devices," : "");
+ goto initrd_jump;
}
- log_debug("Couldn't finalize remaining file systems and devices after %u retries, trying again.", retries+1);
+ log_debug("After %u retries, couldn't finalize remaining %s%s%s%s trying again.",
+ retries + 1,
+ need_umount ? " file systems," : "",
+ need_swapoff ? " swap devices," : "",
+ need_loop_detach ? " loop devices," : "",
+ need_dm_detach ? " DM devices," : "");
}
- if (retries >= FINALIZE_ATTEMPTS)
- log_error("Too many iterations, giving up.");
- else
- log_info("Storage is finalized.");
+ log_error("Too many iterations, giving up.");
+
+ initrd_jump:
arguments[0] = NULL;
arguments[1] = arg_verb;
@@ -384,6 +391,13 @@ int main(int argc, char *argv[]) {
}
}
+ if (need_umount || need_swapoff || need_loop_detach || need_dm_detach)
+ log_error("Failed to finalize %s%s%s%s ignoring",
+ need_umount ? " file systems," : "",
+ need_swapoff ? " swap devices," : "",
+ need_loop_detach ? " loop devices," : "",
+ need_dm_detach ? " DM devices," : "");
+
/* The kernel will automaticall flush ATA disks and suchlike
* on reboot(), but the file systems need to be synce'd
* explicitly in advance. So let's do this here, but not