[master 6/6] Reserve space for the 'pmspare' LV in a VG
vpodzime
installerbot-noreply at redhat.com
Wed Aug 19 12:38:54 UTC 2015
From: Vratislav Podzimek <vpodzime at redhat.com>
The 'pmspare' LV is created by LVM behind our back and it serves as a temporary
space for some metadata reorganizations/cleanup/... so its size is equal to the
size of the biggest metadata LV in the VG. If we ignore it, we lack free space
in the VG later when creating LVs.
---
blivet/devices/lvm.py | 13 +++++++++++++
tests/devices_test/device_properties_test.py | 5 +++--
tests/partitioning_test.py | 13 ++++++++-----
3 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index ada2db8..d090eb7 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -347,6 +347,9 @@ def reservedSpace(self):
elif self.reserved_space > Size(0):
reserved = self.reserved_space
+ # reserve space for the pmspare LV LVM creates behind our back
+ reserved += self.pmSpareSize
+
return self.align(reserved, roundup=True)
@property
@@ -422,6 +425,16 @@ def cachedLVs(self):
return [l for l in self._lvs if l.cached]
@property
+ def pmSpareSize(self):
+ """Size of the pmspare LV LVM creates in every VG that contains some metadata
+ (even internal) LV. The size of such LV is equal to the size of the
+ biggest metadata LV in the VG.
+
+ """
+ # TODO: report correctly/better for existing VGs
+ return max([lv.metaDataSize for lv in self.lvs] + [Size(0)])
+
+ @property
def complete(self):
"""Check if the vg has all its pvs in the system
Return True if complete.
diff --git a/tests/devices_test/device_properties_test.py b/tests/devices_test/device_properties_test.py
index a99deb1..d07f7e5 100644
--- a/tests/devices_test/device_properties_test.py
+++ b/tests/devices_test/device_properties_test.py
@@ -791,8 +791,9 @@ def testLVMLogicalVolumeDeviceInit(self):
def testLVMLogicalVolumeDeviceInitCached(self):
self.stateCheck(self.cached_lv,
- # 2 * (1 GiB - one extent) - 512 MiB
- maxSize=xform(lambda x, m: self.assertEqual(x, Size("1528 MiB"), m) and
+ # 2 * (1 GiB - one extent) - 512 MiB - 8 MiB
+ # PVfree cache pmspare
+ maxSize=xform(lambda x, m: self.assertEqual(x, Size("1520 MiB"), m) and
self.assertIsInstance(x, Size, m)),
snapshots=xform(lambda x, m: self.assertEqual(x, [], m)),
segType=xform(lambda x, m: self.assertEqual(x, "linear", m)),
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
index 5f94e25..63f6dce 100644
--- a/tests/partitioning_test.py
+++ b/tests/partitioning_test.py
@@ -508,8 +508,10 @@ def testVGChunk(self):
def testVGChunkWithCache(self):
pv = StorageDevice("pv1", size=Size("40 GiB"),
fmt=getFormat("lvmpv"))
- # 1025 MiB so that the PV provides 1024 MiB of free space (see LVMVolumeGroupDevice.extents)
- pv2 = StorageDevice("pv2", size=Size("1025 MiB"),
+ # 1033 MiB so that the PV provides 1032 MiB of free space (see
+ # LVMVolumeGroupDevice.extents) -- 1024 MiB for caches, 8 MiB for the
+ # pmspare LV
+ pv2 = StorageDevice("pv2", size=Size("1033 MiB"),
fmt=getFormat("lvmpv"))
vg = LVMVolumeGroupDevice("vg", parents=[pv, pv2])
@@ -550,10 +552,11 @@ def testVGChunkWithCache(self):
def testVGChunkWithCachePVfree(self):
pv = StorageDevice("pv1", size=Size("40 GiB"),
fmt=getFormat("lvmpv"))
- # 1069 MiB so that the PV provides 1068 MiB of free space (see
+ # 1077 MiB so that the PV provides 1076 MiB of free space (see
# LVMVolumeGroupDevice.extents) which is 44 MiB more than the caches
- # need and which should thus be split into the LVs
- pv2 = StorageDevice("pv2", size=Size("1069 MiB"),
+ # need (including the 8MiB pmspare LV) and which should thus be split
+ # into the LVs
+ pv2 = StorageDevice("pv2", size=Size("1077 MiB"),
fmt=getFormat("lvmpv"))
vg = LVMVolumeGroupDevice("vg", parents=[pv, pv2])
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/dba2a8c489b198969999f5d656a6f1ba66d8b91f
More information about the anaconda-patches
mailing list