teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 0001-shutdown-readd-explicit-sync-when-shutting-down.patch

Lennart Poettering 46f254
From 0049f05a8bb82c3e084bacc5945596761d706c55 Mon Sep 17 00:00:00 2001
Lennart Poettering 46f254
From: Lennart Poettering <lennart@poettering.net>
Lennart Poettering 46f254
Date: Fri, 16 Nov 2012 01:30:29 +0100
Lennart Poettering 46f254
Subject: [PATCH] shutdown: readd explicit sync() when shutting down
Lennart Poettering 46f254
Lennart Poettering 46f254
As it turns out reboot() doesn't actually imply a file system sync, but
Lennart Poettering 46f254
only a disk sync. Accordingly, readd explicit sync() invocations
Lennart Poettering 46f254
immediately before we invoke reboot().
Lennart Poettering 46f254
Lennart Poettering 46f254
This is much less dramatic than it might sounds as we umount all
Lennart Poettering 46f254
disks/read-only remount them anyway before going down.
Lennart Poettering 46f254
---
Lennart Poettering 46f254
 src/core/service.c  | 1 +
Lennart Poettering 46f254
 src/core/shutdown.c | 7 +++++++
Lennart Poettering 46f254
 2 files changed, 8 insertions(+)
Lennart Poettering 46f254
Lennart Poettering 46f254
diff --git a/src/core/service.c b/src/core/service.c
Lennart Poettering 46f254
index cf08485..df72aba 100644
Lennart Poettering 46f254
--- a/src/core/service.c
Lennart Poettering 46f254
+++ b/src/core/service.c
Lennart Poettering 46f254
@@ -2485,6 +2485,7 @@ static int service_start_limit_test(Service *s) {
Lennart Poettering 46f254
 
Lennart Poettering 46f254
         case SERVICE_START_LIMIT_REBOOT_IMMEDIATE:
Lennart Poettering 46f254
                 log_warning("%s start request repeated too quickly, rebooting immediately.", UNIT(s)->id);
Lennart Poettering 46f254
+                sync();
Lennart Poettering 46f254
                 reboot(RB_AUTOBOOT);
Lennart Poettering 46f254
                 break;
Lennart Poettering 46f254
 
Lennart Poettering 46f254
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
Lennart Poettering 46f254
index cc8c57b..b59aef1 100644
Lennart Poettering 46f254
--- a/src/core/shutdown.c
Lennart Poettering 46f254
+++ b/src/core/shutdown.c
Lennart Poettering 46f254
@@ -273,6 +273,13 @@ int main(int argc, char *argv[]) {
Lennart Poettering 46f254
                 }
Lennart Poettering 46f254
         }
Lennart Poettering 46f254
 
Lennart Poettering 46f254
+        /* The kernel will automaticall flush ATA disks and suchlike
Lennart Poettering 46f254
+         * on reboot(), but the file systems need to be synce'd
Lennart Poettering 46f254
+         * explicitly in advance. So let's do this here, but not
Lennart Poettering 46f254
+         * needlessly slow down containers. */
Lennart Poettering 46f254
+        if (!in_container)
Lennart Poettering 46f254
+                sync();
Lennart Poettering 46f254
+
Lennart Poettering 46f254
         if (cmd == LINUX_REBOOT_CMD_KEXEC) {
Lennart Poettering 46f254
 
Lennart Poettering 46f254
                 if (!in_container) {
Lennart Poettering 46f254
-- 
Lennart Poettering 46f254
1.7.12.1
Lennart Poettering 46f254