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 committed Nov 4, 2015
1 parent 9c96ab1 commit ca1ea15
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions blivet/devices/lvm.py
Expand Up @@ -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.
Expand All @@ -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)

This comment has been minimized.

Copy link
@dwlehman

dwlehman Nov 4, 2015

This looks like a bit of a behavior change, but probably for the better.

This comment has been minimized.

Copy link
@vpodzime

vpodzime Nov 5, 2015

Author Owner

Now that I think about it, we shouldn't change this behavior. I'll submit an updated version of this patch. (both actually, because they need a rebase)


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):
Expand Down

0 comments on commit ca1ea15

Please sign in to comment.