Adam Litke has uploaded a new change for review. 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. Change-Id: Ic351d694ddeed5b4bf92a211c5d64fa6673b3221 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1251958 Signed-off-by: Adam Litke <ali...@redhat.com> --- M vdsm/virt/vm.py 1 file changed, 25 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/45107/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 6d8cccb..62f40e4 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -5741,7 +5741,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 @@ -6087,11 +6087,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 @@ -6115,7 +6115,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) @@ -6125,22 +6125,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/45107 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic351d694ddeed5b4bf92a211c5d64fa6673b3221 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Adam Litke <ali...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches