Nir Soffer has uploaded a new change for review.

Change subject: virt: Allocate additonal space for cow internal data
......................................................................

virt: Allocate additonal space for cow internal data

In change I4098dfc07 (virt: Fix limit when calculating next volume size) we
fixed drive size limit so drive volume is limited by drive capacity. This
change introduced a regression where vm is paused when trying to fill up a
drive, and there is no way to resume it, since qemu cannot complete the write.

To allow a guest to use the entire drive capacity, we must allocate extra space
for cow internal data. Since it is tricky to compute the exact value, we use
the same estimate (1.1) used for converting raw volumes to cow and merging
volumes.

Change-Id: I14ae7647e459e35d6b6aea632ad4ad9a3cf7666e
Signed-off-by: Nir Soffer <nsof...@redhat.com>
---
M tests/vmStorageTests.py
M vdsm/virt/vmdevices/storage.py
2 files changed, 24 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/38178/1

diff --git a/tests/vmStorageTests.py b/tests/vmStorageTests.py
index 14b748f..0e7a557 100644
--- a/tests/vmStorageTests.py
+++ b/tests/vmStorageTests.py
@@ -244,7 +244,7 @@
 
 
 @expandPermutations
-class GetNextVolumeSizeTests(VdsmTestCase):
+class DriveVolumeSizeTests(VdsmTestCase):
 
     CAPACITY = 8192 * constants.MEGAB
 
@@ -256,11 +256,18 @@
                          cursize / constants.MEGAB + drive.volExtensionChunk)
 
     @permutations([[CAPACITY - 1], [CAPACITY], [CAPACITY + 1]])
-    def test_capacity_limit(self, cursize):
+    def test_next_size_limit(self, cursize):
         conf = drive_config(format='cow')
         drive = Drive({}, self.log, **conf)
         self.assertEqual(drive.getNextVolumeSize(cursize, self.CAPACITY),
-                         self.CAPACITY / constants.MEGAB)
+                         drive.getMaxVolumeSize(self.CAPACITY))
+
+    def test_max_size(self):
+        conf = drive_config(format='cow')
+        drive = Drive({}, self.log, **conf)
+        size = int(self.CAPACITY * drive.VOLWM_COW_OVERHEAD)
+        self.assertEqual(drive.getMaxVolumeSize(self.CAPACITY),
+                         size / constants.MEGAB + 1)
 
 
 def drive_config(**kw):
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index d8a1def..e92de47 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -51,6 +51,9 @@
     VOLWM_FREE_PCT = 100 - config.getint('irs', 'volume_utilization_percent')
     VOLWM_CHUNK_REPLICATE_MULT = 2  # Chunk multiplier during replication
 
+    # Estimate of the additional space needed for qcow format internal data.
+    VOLWM_COW_OVERHEAD = 1.1
+
     def __init__(self, conf, log, **kwargs):
         if not kwargs.get('serial'):
             self.serial = kwargs.get('imageID'[-20:]) or ''
@@ -143,7 +146,17 @@
         """
         curSizeMB = (curSize + constants.MEGAB - 1) / constants.MEGAB
         nextSizeMB = curSizeMB + self.volExtensionChunk
-        return min(nextSizeMB, capacity / constants.MEGAB)
+        return min(nextSizeMB, self.getMaxVolumeSize(capacity))
+
+    def getMaxVolumeSize(self, capacity):
+        """
+        Returns the maximum volume size in megabytes. This value is larger than
+        drive capacity since we must allocate extra space for cow internal
+        data. The actual lv size may be larger due to rounding to next lvm
+        extent.
+        """
+        size = int(capacity * self.VOLWM_COW_OVERHEAD)
+        return (size + constants.MEGAB - 1) / constants.MEGAB
 
     @property
     def chunked(self):


-- 
To view, visit https://gerrit.ovirt.org/38178
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I14ae7647e459e35d6b6aea632ad4ad9a3cf7666e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsof...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to