[master 8/9] Implement the support for resizing internal metadata LVs of thin pools

vpodzime installerbot-noreply at redhat.com
Thu Jun 18 20:00:37 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

Internal metadata LVs of thin pools can be resized so our representation should
also allow it.
---
 blivet/devices/lvm.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 6c929c2..e56873c 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -1030,12 +1030,34 @@ 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
+        # pylint: disable=bad-super-call
+        super(LVMInternalLogicalVolumeDevice, self).resize()
+
 _INTERNAL_LV_CLASSES.append(LVMMetadataLogicalVolumeDevice)
 
 class LVMLogLogicalVolumeDevice(LVMInternalLogicalVolumeDevice):


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/86748b36c2c15597b3dda9307080b27793dba54e


More information about the anaconda-patches mailing list