Skip to content

Commit

Permalink
Merge pull request #1309 from vojtechtrefny/main_luks-grow-lvm-fix
Browse files Browse the repository at this point in the history
Align sizes up for growable LVs
  • Loading branch information
vojtechtrefny authored Oct 29, 2024
2 parents cd86ced + 8fa1872 commit 5162f0c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions blivet/devices/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def _get_size(self):

def _set_size(self, newsize):
if not self.exists and not self.raw_device.exists:
log.debug("adjusting size of %s to %s to accommodate LUKS metadata",
self.raw_device.name,
newsize + self.raw_device.format._header_size)
self.raw_device.size = newsize + self.raw_device.format._header_size

# just run the StorageDevice._set_size to make sure we are in the format limits
Expand Down
2 changes: 1 addition & 1 deletion blivet/devices/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,7 @@ def _set_size(self, newsize):
if not isinstance(newsize, Size):
raise AttributeError("new size must be of type Size")

newsize = self.vg.align(newsize)
newsize = self.vg.align(newsize, roundup=self.growable)
log.debug("trying to set lv %s size to %s", self.name, newsize)
# 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
Expand Down
8 changes: 4 additions & 4 deletions blivet/devices/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,11 @@ def _set_size(self, newsize):
max_size = self.format.max_size
min_size = self.format.min_size
if max_size and newsize > max_size:
raise errors.DeviceError("device cannot be larger than %s" %
max_size, self.name)
raise errors.DeviceError("device %s cannot be larger than %s" %
(self.name, max_size))
elif min_size and newsize < min_size:
raise errors.DeviceError("device cannot be smaller than %s" %
min_size, self.name)
raise errors.DeviceError("device %s cannot be smaller than %s" %
(self.name, min_size))

self._size = newsize

Expand Down

0 comments on commit 5162f0c

Please sign in to comment.