Accompanying anaconda version.
mulhern (3):
Add some comments to _resizable and resizable attributes.
Revert "Make space for LUKS metadata if creating encrypted device
(#1038847)"
Calculate some derived quantities from raw device (#1076055)
blivet/devicefactory.py | 12 +-----------
blivet/devices.py | 42 +++++++++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 14 deletions(-)
--
1.9.3
Show replies by date
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devices.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index 4496ad9..9da51d8 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -503,6 +503,8 @@ class StorageDevice(Device):
"""
_resizable = False
"""Whether this type of device is inherently
resizable."""
+ # _resizable == True is equivalent to the existence of an implemented
+ # resize() method.
_type = "blivet"
_devDir = "/dev"
@@ -763,7 +765,13 @@ class StorageDevice(Device):
@property
def resizable(self):
- """ Can this device be resized? """
+ """ True if this device can be resized, i.e., if it is reasonable
+ to invoke resize() on this device, otherwise False. Since
+ the purpose of resize() is to change the size of an actual
+ device by means of appropriate device specific commands, a
+ non-existant device can not be resized. The format-related
+ restrictions arise from the same consideration.
+ """
return (self._resizable and self.exists and
(self.format.type is None or self.format.resizable or
not self.format.exists))
--
1.9.3
Related: rhbz#1076055
This reverts commit 391dc86b1290172bcc1bd3d02aec07e6869f3a60 except for the
definition of _minSize, which seems like the correct definition and may
come in handy later.
The idea is to handle LUKS space requirements in device instead of device
factory methods.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devicefactory.py | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/blivet/devicefactory.py b/blivet/devicefactory.py
index 8782a8a..61e8aa1 100644
--- a/blivet/devicefactory.py
+++ b/blivet/devicefactory.py
@@ -263,11 +263,6 @@ class DeviceFactory(object):
:type min_luks_entropy: int
"""
-
- if encrypted and size:
- # encrypted, bump size up with LUKS metadata size
- size += getFormat("luks").minSize
-
self.storage = storage # a Blivet instance
self.size = size # the requested size for this device
self.disks = disks # the set of disks to allocate from
@@ -841,12 +836,7 @@ class PartitionFactory(DeviceFactory):
else:
min_format_size = getFormat(self.fstype).minSize
- # min_format_size may be None here, make sure it is a number
- min_format_size = min_format_size or 0
- if self.encrypted:
- min_format_size += getFormat("luks").minSize
-
- return max(Size("1MiB"), min_format_size)
+ return max(Size("1MiB"), min_format_size or 0)
def _get_device_size(self):
""" Return the factory device size including container
limitations. """
--
1.9.3
Related: rhbz#1076055
For LUKSDevice, calculate more than size from raw device.
Use the device format's minSize to find the difference between the raw
device's size quantity and the LUKS devices size quantity instead of using
crypto.LUKS_METADATA_SIZE.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devices.py | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index 9da51d8..3757b79 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -34,7 +34,6 @@ from .devicelibs import lvm
from .devicelibs import dm
from .devicelibs import loop
from .devicelibs import btrfs
-from .devicelibs import crypto
from .devicelibs import raid
import parted
import _ped
@@ -2344,13 +2343,42 @@ class LUKSDevice(DMCryptDevice):
return self.slave
@property
+ def maxSize(self):
+ max_size = self.slave.maxSize
+ if not max_size:
+ return max_size
+
+ max_size = max_size - self.format.minSize
+ if max_size < 0:
+ return 0
+
+ return max_size
+
+ @property
+ def minSize(self):
+ return self.slave.minSize + self.format.minSize
+
+ @property
def size(self):
if not self.exists or not self.partedDevice:
- size = self.slave.size - crypto.LUKS_METADATA_SIZE
+ size = self.slave.size - self.format.minSize
else:
size = Size(self.partedDevice.getLength(unit="B"))
return size
+ def _setSize(self, size):
+ self.slave.size = size + self.format.minSize
+
+ def _setTargetSize(self, newsize):
+ self.slave._setTargetSize(newsize + self.format.minSize)
+
+ def _getTargetSize(self):
+ return self.slave._getTargetSize() - self.format.minSize
+
+ @property
+ def currentSize(self):
+ return self.slave.currentSize + self.format.minSize
+
def _postCreate(self):
self.name = self.slave.format.mapName
StorageDevice._postCreate(self)
--
1.9.3