Bug 1466036 - Close file descriptor, flush buffers on grub.cfg and directory before exiting
Close file descriptor, flush buffers on grub.cfg and directory before exiting
Status: NEW
Product: Fedora
Classification: Fedora
Component: grubby (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Peter Jones
Fedora Extras Quality Assurance
Depends On: 1464611
  Show dependency treegraph
Reported: 2017-06-28 16:00 EDT by François Cami
Modified: 2017-08-15 02:47 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1464611
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description François Cami 2017-06-28 16:00:49 EDT
+++ This bug was initially created as a clone of Bug #1464611 +++

Description of problem:
Running grubby even to add kernel parameters to the command-line and then rebooting "hard" (power outage or open file descriptor in /boot) often results in boot issues.
Booting manually, or mounting (and playing the journal) of the /boot filesystem repairs the issue most of the time.

Version-Release number of selected component (if applicable):

Looking at upstream ( https://github.com/rhboot/grubby ) all versions up to and including 34b1436ccbd56eab8024314cab48f2fc880eef08 seem problematic as they do not fflush(fileno(out)) + fclose(out), nor fsync() the destination directory after rename.

How reproducible:
Nearly always.

Steps to Reproduce:
1. Create a VM with IP=
  NB: using XFS for /boot makes the bug more prone to appear
2. Run "ssh root@$ grubby --args elevator=deadline --update-kernel DEFAULT && virsh destroy vm"
3. Run "virsh start vm"

Actual results:
VM is stopped at grub prompt due to a missing grub.cfg configuration file: this is typically repaired by a filesystem journal replay.

Expected results:
VM boots.

Additional info:
writeConfig() doesn't close its configuration file before rename() is called, nor when/before the process exits successfully. 

fsync() is not called on the configuration file nor on the configuration directory.
Comment 1 François Cami 2017-06-28 16:01:12 EDT
Upstream PR: https://github.com/rhboot/grubby/pull/24
Comment 2 Jan Kurik 2017-08-15 02:47:49 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Note You need to log in before you can comment on or make changes to this bug.