forked from storaged-project/blivet
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put the LVM metadata size calculation into a separate property
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
Showing
1 changed file
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vpodzime
Author
Owner
|
||
|
||
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): | ||
|
This looks like a bit of a behavior change, but probably for the better.