Skip to content

Commit

Permalink
Account for LVM metadata in the LVMFactory
Browse files Browse the repository at this point in the history
If we want to have an e.g. 1020 MiB big container (VG), we actually need more
space for it because LVM puts its meta data to the PVs the VG consists of. We
need to account for this meta data otherwise we get less space then requested.
  • Loading branch information
vpodzime committed Nov 5, 2015
1 parent 58e6cb8 commit b4d6741
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blivet/devicefactory.py
Expand Up @@ -1244,6 +1244,12 @@ def _get_total_space(self):
if self.container:
space += sum([p.size for p in self.container.parents])
space -= self.container.freeSpace
# we need to account for the LVM metadata being placed somewhere
space += self.container.lvm_metadata_space

# we need to account for the LVM metadata being placed on each disk
# (and thus taking up to one extent from each disk)
space += len(self.disks) * lvm.LVM_PE_SIZE
elif self.container_size == SIZE_POLICY_MAX:
# grow the container as large as possible
if self.container:
Expand All @@ -1257,6 +1263,10 @@ def _get_total_space(self):
# XXX: should respect the real extent size
space += blockdev.lvm.get_lv_physical_size(self.container_size, lvm.LVM_PE_SIZE)

# we need to account for the LVM metadata being placed on each disk
# (and thus taking up to one extent from each disk)
space += len(self.disks) * lvm.LVM_PE_SIZE

# this does not apply if a specific container size was requested
if self.container_size in [SIZE_POLICY_AUTO, SIZE_POLICY_MAX]:
space += self._get_device_space()
Expand Down

0 comments on commit b4d6741

Please sign in to comment.