[master 4/5] Device size checks do not apply to existing devices.
dwlehman
installerbot-noreply at redhat.com
Wed Jul 8 21:13:18 UTC 2015
From: David Lehman <dlehman at redhat.com>
We need to check new sizes for non-existent devices against the limits
of the device's format.
Calls to size setter for existing devices should only be to reflect
the current reality. Setting up a resize should be done by setting
the target size.
---
blivet/devices/lvm.py | 5 ++++-
blivet/devices/storage.py | 22 +++++++++++++---------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 605165e..ab1108f 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -606,7 +606,10 @@ def _setSize(self, size):
size = self.vg.align(size)
log.debug("trying to set lv %s size to %s", self.name, size)
- if size > self.vg.freeSpace + self.vgSpaceUsed:
+ # Don't refuse to set size if we think there's not enough space in the
+ # VG for an existing LV, since it's existence proves there is enough
+ # space for it.
+ if not self.exists and size > self.vg.freeSpace + self.vgSpaceUsed:
log.error("failed to set size: %s short", size - (self.vg.freeSpace + self.vgSpaceUsed))
raise ValueError("not enough free space in volume group")
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 54d79fc..98b0f1e 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -552,15 +552,19 @@ def _setSize(self, newsize):
if not isinstance(newsize, Size):
raise ValueError("new size must of type Size")
- # only calculate these once
- max_size = self.maxSize
- min_size = self.minSize
- if max_size and newsize > max_size:
- raise errors.DeviceError("device cannot be larger than %s" %
- max_size, self.name)
- elif min_size and newsize < min_size:
- raise errors.DeviceError("device cannot be smaller than %s" %
- min_size, self.name)
+ # There's no point in checking limits here for existing devices since
+ # the only way to change their size is by setting target size. Any call
+ # to this setter for an existing device should be to reflect existing
+ # state.
+ if not self.exists:
+ max_size = self.format.maxSize
+ min_size = self.format.minSize
+ if max_size and newsize > max_size:
+ raise errors.DeviceError("device cannot be larger than %s" %
+ max_size, self.name)
+ elif min_size and newsize < min_size:
+ raise errors.DeviceError("device cannot be smaller than %s" %
+ min_size, self.name)
self._size = newsize
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/2bdafb0cab98612f28d9300772026563663c1604
More information about the anaconda-patches
mailing list