f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Don Zickus <dzickus@redhat.com>
f725e3
Date: Wed, 22 Jul 2015 13:59:55 -0400
f725e3
Subject: [PATCH] ppc64le sync mkconfig to disk (#1212114)
f725e3
f725e3
If creating a new grub2 entry using grub2-mkconfig, the entry is not
f725e3
immediately sync'd to disk.  If a crash happens before the writeback,
f725e3
the subsequent reboot fails because the grub2.cfg is corrupted.
f725e3
f725e3
Address this by forcing all the changes (mainly the fs meta data) to disk
f725e3
before finishing the grub2 conf changes.
f725e3
f725e3
Tested by 'grub2-mkconfig -o /etc/grub22.cfg; echo c > /proc/sysrq-trigger'.
f725e3
f725e3
Before, the machine would panic and on reboot be stuck without a grub.cfg
f725e3
to read.  After, works as expected.
f725e3
f725e3
Resolves: rhbz#1212114
f725e3
---
f725e3
 util/grub-mkconfig.in | 9 +++++++++
f725e3
 1 file changed, 9 insertions(+)
f725e3
f725e3
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
f725e3
index e029d0d5ea9..cf315e241f6 100644
f725e3
--- a/util/grub-mkconfig.in
f725e3
+++ b/util/grub-mkconfig.in
f725e3
@@ -290,3 +290,12 @@ fi
f725e3
 
f725e3
 gettext "done" >&2
f725e3
 echo >&2
f725e3
+
f725e3
+# make sure changes make it to the disk.
f725e3
+# if /boot is a mountpoint, force the meta data on disk
f725e3
+# to by-pass writeback delay.
f725e3
+# PPC64LE-only to deal with Petitboot issues
f725e3
+ARCH=$(uname -m)
f725e3
+if [ "${ARCH}" = "ppc64le" ]; then
f725e3
+    sync && mountpoint -q /boot &&fsfreeze -f /boot && fsfreeze -u /boot
f725e3
+fi