chiark / gitweb /
shutdown: readd explicit sync() when shutting down
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2012 00:30:29 +0000 (01:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2012 00:35:11 +0000 (01:35 +0100)
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.

src/core/service.c
src/core/shutdown.c

index cf084853743550244ae88e711ecf2d35c67bc086..df72abab01cb31d49f1336efe484a54cab98db22 100644 (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;
 
index cc8c57bd2d89e86f0ad0fa4a563d2221d3be06e7..b59aef174f14f1fd82e2069a0f406ebd43d46551 100644 (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) {