[blivet:master 15/17] Destrengthen self._size_option field.
mulhern
amulhern at redhat.com
Tue Jan 6 20:38:17 UTC 2015
It becomes a bool instead of the precise size option string required.
Calculate the actual string only when needed.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/formats/fs.py | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 7dd0e2d..a3bd768 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -1578,14 +1578,8 @@ class TmpFS(NoDevFS):
# if no size is specified, tmpfs will by default
# be limited to half of the system RAM
# (sizes of all tmpfs mounts are independent)
- self._size_option = ""
- if self._size:
- # absolute size for the tmpfs mount has been specified
- self._size_option = self._sizeOption(self._size)
- else:
- # if no size option is specified, the tmpfs mount size will be 50%
- # of system RAM by default
- self._size = util.total_memory()/2
+ self._accept_default_size = not(self._size)
+ self._size = self._size or util.total_memory() / 2
def create(self, **kwargs):
""" A filesystem is created automatically once tmpfs is mounted. """
@@ -1619,7 +1613,11 @@ class TmpFS(NoDevFS):
# replacing the size option in the otherwise free-form
# options string would get messy fast)
opts = super(TmpFS, self)._getOptions()
- return ",".join(o for o in (opts, self._size_option) if o)
+ if self._accept_default_size:
+ size_opt = None
+ else:
+ size_opt = self._sizeOption(self._size)
+ return ",".join(o for o in (opts, size_opt) if o)
@property
def size(self):
@@ -1664,20 +1662,11 @@ class TmpFS(NoDevFS):
return ['-o', ",".join(options), self._type, self._mountpoint]
def doResize(self):
- # we need to override doResize, because the
- # self._size_option string needs to be updated in case
- # the tmpfs mount is successfully resized, using the new
- # self._size value
+ # Override superclass method to record whether mount options
+ # should include an explicit size specification.
original_size = self._size
FS.doResize(self)
- # after a successful resize, self._size
- # is set to be equal to self.targetSize,
- # so it can be used to check if resize took place
- if original_size != self._size:
- # update the size option string
- # -> please note that resizing always sets the
- # size of this tmpfs mount to an absolute value
- self._size_option = self._sizeOption(self._size)
+ self._accept_default_size = original_size == self._size and self._accept_default_size
register_device_format(TmpFS)
--
1.9.3
More information about the anaconda-patches
mailing list