Hello Francesco Romani,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/45950

to review the following change.

Change subject: Live merge: Update base size after live merge
......................................................................

Live merge: Update base size after live merge

When performing a live merge, data is copied from a top volume into a
base volume.  If the top volume is larger than the base volume (which
can happen if the drive size was extended), libvirt will change the size
of the base volume to match that of the top volume.  When synchronizing
metadata after the merge, we need to update the 'capacity' field of the
base volume to reflect the new size.  We do this inside the
LiveMergeCleanupThread to ensure that it gets retried in the event of
storage connection problems or vdsm restarts.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1251958
Change-Id: Iae354de36db63ae3bf4b4fc7f72df5e306035784
Signed-off-by: Adam Litke <[email protected]>
Reviewed-on: https://gerrit.ovirt.org/42921
Reviewed-by: Francesco Romani <[email protected]>
Continuous-Integration: Jenkins CI
Reviewed-by: Nir Soffer <[email protected]>
---
M vdsm/virt/vm.py
1 file changed, 25 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/45950/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 4ec4930..4e8faab 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -5740,7 +5740,7 @@
 
     def queryBlockJobs(self):
         def startCleanup(job, drive, needPivot):
-            t = LiveMergeCleanupThread(self, job['jobID'], drive, needPivot)
+            t = LiveMergeCleanupThread(self, job, drive, needPivot)
             t.start()
             self._liveMergeCleanupThreads[job['jobID']] = t
 
@@ -6086,11 +6086,11 @@
 
 
 class LiveMergeCleanupThread(threading.Thread):
-    def __init__(self, vm, jobId, drive, doPivot):
+    def __init__(self, vm, job, drive, doPivot):
         threading.Thread.__init__(self)
         self.setDaemon(True)
         self.vm = vm
-        self.jobId = jobId
+        self.job = job
         self.drive = drive
         self.doPivot = doPivot
         self.success = False
@@ -6114,7 +6114,7 @@
         self.vm.stopDisksStatsCollection()
 
         self.vm.log.info("Requesting pivot to complete active layer commit "
-                         "(job %s)", self.jobId)
+                         "(job %s)", self.job['jobID'])
         try:
             flags = libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT
             ret = self.vm._dom.blockJobAbort(self.drive.name, flags)
@@ -6124,22 +6124,39 @@
         else:
             if ret != 0:
                 self.vm.log.error("Pivot failed for job %s (rc=%i)",
-                                  self.jobId, ret)
+                                  self.job['jobID'], ret)
                 raise RuntimeError("pivot failed")
             self._waitForXMLUpdate()
-        self.vm.log.info("Pivot completed (job %s)", self.jobId)
+        self.vm.log.info("Pivot completed (job %s)", self.job['jobID'])
+
+    def update_base_size(self):
+        # If the drive size was extended just after creating the snapshot which
+        # we are removing, the size of the top volume might be larger than the
+        # size of the base volume.  In that case libvirt has enlarged the base
+        # volume automatically as part of the blockCommit operation.  Update
+        # our metadata to reflect this change.
+        topVolUUID = self.job['topVolume']
+        baseVolUUID = self.job['baseVolume']
+        topVolInfo = self.vm._getVolumeInfo(self.drive.domainID,
+                                            self.drive.poolID,
+                                            self.drive.imageID, topVolUUID)
+        self.vm._setVolumeSize(self.drive.domainID, self.drive.poolID,
+                               self.drive.imageID, baseVolUUID,
+                               topVolInfo['capacity'])
 
     @utils.traceback()
     def run(self):
+        self.update_base_size()
         if self.doPivot:
             self.tryPivot()
         self.vm.log.info("Synchronizing volume chain after live merge "
-                         "(job %s)", self.jobId)
+                         "(job %s)", self.job['jobID'])
         self.vm._syncVolumeChain(self.drive)
         if self.doPivot:
             self.vm.startDisksStatsCollection()
         self.success = True
-        self.vm.log.info("Synchronization completed (job %s)", self.jobId)
+        self.vm.log.info("Synchronization completed (job %s)",
+                         self.job['jobID'])
 
     def isSuccessful(self):
         """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae354de36db63ae3bf4b4fc7f72df5e306035784
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Adam Litke <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to