[master 16/30] Sync our one filesytem that syncs via syncfs task.

mulkieran installerbot-noreply at redhat.com
Wed Mar 25 22:47:54 UTC 2015


From: mulhern <amulhern at redhat.com>

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/formats/fs.py | 43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 3a6c179..917d08c 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -28,6 +28,7 @@
 
 from ..tasks import fslabeling
 from ..tasks import fsreadlabel
+from ..tasks import fssync
 from ..errors import FormatCreateError, FSError, FSReadLabelError, FSResizeError
 from . import DeviceFormat, register_device_format
 from .. import util
@@ -60,6 +61,7 @@ class FS(DeviceFormat):
     _fsckErrors = {}                     # fs check command error codes & msgs
     _infofs = ""                         # fs info utility
     _readlabelClass = None               # read label
+    _syncClass = None                    # sync the filesystem
     _defaultFormatOptions = []           # default options passed to mkfs
     _defaultMountOptions = ["defaults"]  # default options passed to mount
     _defaultCheckOptions = []
@@ -101,6 +103,7 @@ def getTaskObject(klass):
 
         # Create task objects
         self._readlabel = getTaskObject(self._readlabelClass)
+        self._sync = getTaskObject(self._syncClass)
 
         self.mountpoint = kwargs.get("mountpoint")
         self.mountopts = kwargs.get("mountopts")
@@ -891,8 +894,22 @@ def status(self):
             return False
         return self.systemMountpoint is not None
 
-    def sync(self, root="/"):
-        pass
+    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 self._sync is None:
+            return
+
+        if not self._mountpoint.startswith(root):
+            return
+
+        try:
+            self._sync.doTask(root)
+        except FSError as e:
+            log.error(e)
 
     def populateKSData(self, data):
         super(FS, self).populateKSData(data)
@@ -1241,34 +1258,14 @@ class XFS(FS):
     _packages = ["xfsprogs"]
     _infofs = "xfs_db"
     _readlabelClass = fsreadlabel.XFSReadLabel
+    _syncClass = fssync.XFSSync
     _defaultInfoOptions = ["-c", "sb 0", "-c", "p dblocks",
                            "-c", "p blocksize"]
     _existingSizeFields = ["dblocks =", "blocksize ="]
     partedSystem = fileSystemType["xfs"]
 
-    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.systemMountpoint or \
-            not self.systemMountpoint.startswith(root):
-            return
-
-        try:
-            util.run_program(["xfs_freeze", "-f", self.systemMountpoint], root=root)
-        except OSError as e:
-            log.error("failed to run xfs_freeze: %s", e)
-
-        try:
-            util.run_program(["xfs_freeze", "-u", self.systemMountpoint], root=root)
-        except OSError as e:
-            log.error("failed to run xfs_freeze: %s", e)
-
 register_device_format(XFS)
 
-
 class HFS(FS):
     _type = "hfs"
     _mkfs = "hformat"


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/139e62d67617a5ed48cd0eab2e25c4f2eb28c55c


More information about the anaconda-patches mailing list