[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 1/2] Add sync method to force data onto disk and/or journal.



This is for xfs bootloader installation issues.

Related: rhbz#117968
---
 pyanaconda/storage/formats/fs.py |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py
index 5b1b814..83bfdc1 100644
--- a/pyanaconda/storage/formats/fs.py
+++ b/pyanaconda/storage/formats/fs.py
@@ -865,6 +865,9 @@ class FS(DeviceFormat):
             return False
         return self._mountpoint is not None
 
+    def sync(self, root="/"):
+        pass
+
     def writeKS(self, f):
         f.write("%s --fstype=%s" % (self.mountpoint, self.type))
 
@@ -1263,6 +1266,29 @@ class XFS(FS):
         argv.extend([label, self.device])
         return argv
 
+    def sync(self, root='/'):
+        """ Ensure that data we've written is at least in the journal.
+
+            This is a little odd because xfs_freeze will only be
+            available under the install root.
+        """
+        if not self.status or not self._mountpoint.startswith(root):
+            return
+
+        try:
+            iutil.execWithRedirect("xfs_freeze", ["-f", self.mountpoint],
+                                   stdout="/dev/tty5", stderr="/dev/tty5",
+                                   root=root)
+        except (RuntimeError, OSError) as e:
+            log.error("failed to run xfs_freeze: %s" % e)
+
+        try:
+            iutil.execWithRedirect("xfs_freeze", ["-u", self.mountpoint],
+                                   stdout="/dev/tty5", stderr="/dev/tty5",
+                                   root=root)
+        except (RuntimeError, OSError) as e:
+            log.error("failed to run xfs_freeze: %s" % e)
+
 register_device_format(XFS)
 
 
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]