summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 7ef671ad0f..fde3ce9c27 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