[master 3/3] Account for bigger LVM meta data due to alignment on MD RAID

vpodzime installerbot-noreply at redhat.com
Tue Sep 1 09:29:20 UTC 2015


From: Vratislav Podzimek <vpodzime at redhat.com>

As explained in the inline comment LVM aligns data and meta data according to
the underlying block device. In case of a MD RAID device where typically a
512KiB chunks are used, this may result in twice as big space allocated for meta
data as if a plain partition was used. Since the default size is 1 MiB, we can
safely just use a double size in case an MD RAID device is used as a PV because
we can be at most 1 MiB and thus one extent off in the end which is okay.
---
 blivet/devices/lvm.py | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 8047aec..3396a8a 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -354,8 +354,25 @@ def size(self):
         """ The size of this VG """
         # TODO: just ask lvm if isModified returns False
 
-        # sum up the sizes of the PVs and align to pesize
-        return sum((max(Size(0), self.align(pv.size - pv.format.peStart)) for pv in self.pvs), Size(0))
+        # sum up the sizes of the PVs, subtract the unusable (meta data) space
+        # and align to pesize
+        # 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.
+        #       for an MD RAID device, it tries to align everything also to chunk
+        #       size and alignment offset of such device which may result in up
+        #       to a twice as big non-data area
+        # 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)
+        for pv in self.pvs:
+            if isinstance(pv, MDRaidArrayDevice):
+                avail += self.align(pv.size - 2 * pv.format.peStart)
+            else:
+                avail += self.align(pv.size - pv.format.peStart)
+
+        return avail
 
     @property
     def extents(self):


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/4239cb86014264a52f7055f8a6fee7b9c3c831cc


More information about the anaconda-patches mailing list