dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0180-ppc64le-sync-mkconfig-to-disk-1212114.patch

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