Skip to content

Commit

Permalink
Sync our one filesytem that syncs via syncfs task.
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Mar 25, 2015
1 parent 1f3390f commit 139e62d
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions blivet/formats/fs.py
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 139e62d

Please sign in to comment.