Skip to content

Commit

Permalink
Put the LVM metadata size calculation into a separate property
Browse files Browse the repository at this point in the history
By default LVM puts metadata on every PV a VG consists of. We need to account
for that space when calculating the size of the VG, but it's useful in other
cases too. Thus the value should be available as a separate property.
  • Loading branch information
vpodzime authored and vathpela committed Nov 6, 2015
1 parent d49704a commit 174ed82
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions blivet/devices/lvm.py
Expand Up @@ -354,12 +354,8 @@ def reserved_space(self):
return self.align(reserved, roundup=True)

@property
def size(self):
""" The size of this VG """
# TODO: just ask lvm if is_modified returns False

# sum up the sizes of the PVs, subtract the unusable (meta data) space
# and align to pesize
def lvm_metadata_space(self):
""" The amount of the space LVM metadata cost us in this VG's PVs """
# NOTE: we either specify data alignment in a PV or the default is used
# which is both handled by pv.format.pe_start, but LVM takes into
# account also the underlying block device which means that e.g.
Expand All @@ -369,14 +365,25 @@ def size(self):
# TODO: move this to either LVMPhysicalVolume's pe_start property once
# formats know about their devices or to a new LVMPhysicalVolumeDevice
# class once it exists
avail = Size(0)
diff = Size(0)
for pv in self.pvs:
if isinstance(pv, MDRaidArrayDevice):
avail += self.align(pv.size - 2 * pv.format.pe_start)
diff += pv.size - self.align(pv.size - 2 * pv.format.pe_start)
else:
avail += self.align(pv.size - pv.format.pe_start)
diff += pv.size - self.align(pv.size - pv.format.pe_start)

return diff

return avail
@property
def size(self):
""" The size of this VG """
# TODO: just ask lvm if isModified returns False

# sum up the sizes of the PVs, subtract the unusable (meta data) space
size = sum(pv.size for pv in self.pvs)
size -= self.lvm_metadata_space

return size

@property
def extents(self):
Expand Down

0 comments on commit 174ed82

Please sign in to comment.