[PATCH 2/2] Limit the LV size to VG's free space size
Vratislav Podzimek
vpodzime at redhat.com
Wed Mar 5 17:12:55 UTC 2014
When creating the LV we should check its VG free space size and shrink the LV if
it exceeds the biggest possible size.
Related: rhbz#1072999
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
blivet/devices.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/blivet/devices.py b/blivet/devices.py
index 0903110..3aeef28 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -2714,6 +2714,22 @@ class LVMLogicalVolumeDevice(DMDevice):
else:
raise
+ def _preCreate(self):
+ try:
+ vg_info = vginfo(self.vg.name)
+ except LVMError as lvmerr:
+ msg = "Failed to get free space for the %s VG: %s" % self.vg.name, lvmerr
+ log.error(msg)
+ # nothing more can be done, we don't know the VG's free space
+ return
+
+ vg_free = Size(spec=vg_info[2])
+ if self.size > vg_free:
+ msg = "%s LV's size (%s) exceeds the %s VG's free space (%s), shrinking the LV" \
+ % (self.name, self.size, self.vg.name, vg_free)
+ log.warning(msg)
+ self.size = vg_free
+
def _create(self):
""" Create the device. """
log_method_call(self, self.name, status=self.status)
--
1.8.5.3
More information about the anaconda-patches
mailing list