shutdown: readd explicit sync() when shutting down

As it turns out reboot() doesn't actually imply a file system sync, but
only a disk sync. Accordingly, readd explicit sync() invocations
immediately before we invoke reboot().

This is much less dramatic than it might sounds as we umount all
disks/read-only remount them anyway before going down.
This commit is contained in:
Lennart Poettering 2012-11-16 01:30:29 +01:00
parent f553b3b107
commit 0049f05a8b
2 changed files with 8 additions and 0 deletions

View File

@ -2485,6 +2485,7 @@ static int service_start_limit_test(Service *s) {
case SERVICE_START_LIMIT_REBOOT_IMMEDIATE:
log_warning("%s start request repeated too quickly, rebooting immediately.", UNIT(s)->id);
sync();
reboot(RB_AUTOBOOT);
break;

View File

@ -273,6 +273,13 @@ int main(int argc, char *argv[]) {
}
}
/* 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
* needlessly slow down containers. */
if (!in_container)
sync();
if (cmd == LINUX_REBOOT_CMD_KEXEC) {
if (!in_container) {