diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py index 39d245c2e..bc4cef376 100644 --- a/blivet/devices/lvm.py +++ b/blivet/devices/lvm.py @@ -351,12 +351,8 @@ def reservedSpace(self): return self.align(reserved, roundup=True) @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 - # and align to pesize + def lvm_metadata_size(self): + """The amount of the space reserved for LVM metadata 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.peStart, but LVM takes into # account also the underlying block device which means that e.g. @@ -366,14 +362,25 @@ def size(self): # TODO: move this to either LVMPhysicalVolume's peStart 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.peStart) + diff += self.align(pv.size) - self.align(pv.size - 2 * pv.format.peStart) else: - avail += self.align(pv.size - pv.format.peStart) + diff += self.align(pv.size) - self.align(pv.size - pv.format.peStart) + + return diff + + @property + def size(self): + """ The size of this VG """ + # TODO: just ask lvm if isModified returns False - return avail + # 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_size + + return size @property def extents(self):