From a36fdce0c321ae073e52d14c2f963010859197fb Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Mon, 8 Jun 2015 12:45:28 +0200 Subject: [PATCH] Implement the support for resizing internal metadata LVs of thin pools Internal metadata LVs of thin pools can be resized so our representation should also allow it. This needs a change in the LVMLogicalVolumeDevice.resize() method so that it doesn't blindly rely on having self.format and self.originalFormat set to non-None values because that's exactly what internal LVs do/have. --- blivet/devices/lvm.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py index a7c8eb041..a80f2b934 100644 --- a/blivet/devices/lvm.py +++ b/blivet/devices/lvm.py @@ -730,9 +730,9 @@ def resize(self): # Setup VG parents (in case they are dmraid partitions for example) self.vg.setupParents(orig=True) - if self.originalFormat.exists: + if self.originalFormat and self.originalFormat.exists: self.originalFormat.teardown() - if self.format.exists: + if self.format and self.format.exists: self.format.teardown() udev.settle() @@ -1033,12 +1033,33 @@ class LVMDataLogicalVolumeDevice(LVMInternalLogicalVolumeDevice): class LVMMetadataLogicalVolumeDevice(LVMInternalLogicalVolumeDevice): """Internal metadata LV (used by thin/cache pools, RAIDs, etc.)""" + # thin pool metadata LVs can be resized directly + _resizable = True + attr_letters = ["e"] # RAIDs can have multiple (numbered) metadata LVs name_suffix = r"_[trc]meta(_[0-9]+)?" takes_extra_space = True - # TODO: override and allow resize() + # (only) thin pool metadata LVs can be resized directly + @property + def resizable(self): + if self._parent_lv: + return isinstance(self._parent_lv, LVMThinPoolDevice) + else: + # hard to say at this point, just use the name + return not re.search(r'_[rc]meta', self.lvname) + + # (only) thin pool metadata LVs can be resized directly + def resize(self): + if ((self._parent_lv and not isinstance(self._parent_lv, LVMThinPoolDevice)) or + re.search(r'_[rc]meta', self.lvname)): + raise errors.DeviceError("RAID and cache pool metadata LVs cannot be resized directly") + + # skip the generic LVMInternalLogicalVolumeDevice class and call the + # resize() method of the LVMLogicalVolumeDevice + super(LVMInternalLogicalVolumeDevice, self).resize() + _INTERNAL_LV_CLASSES.append(LVMMetadataLogicalVolumeDevice) class LVMLogLogicalVolumeDevice(LVMInternalLogicalVolumeDevice):