Skip to content

Commit

Permalink
Implement the support for resizing internal metadata LVs of thin pools
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vpodzime committed Jun 12, 2015
1 parent a06fa1a commit a36fdce
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions blivet/devices/lvm.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit a36fdce

Please sign in to comment.