Hello Federico Simoncelli, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/31050
to review the following change.
Change subject: Live Merge: support active layer commit
......................................................................
Live Merge: support active layer commit
Libvirt is currently adding support for merging the active layer. This
operation works similar to a block copy job since it has two phases. In
the first phase, data is merged from the active layer into base. During
this phase mirroring ensures that active IO is also directed to the base
snapshot. Phase 1 is complete when 'cur' == 'end' in the block job
info. Vdsm triggers the second phase of the job by calling the
blockJobAbort function with a special PIVOT flag which instructs libvirt
to pivot the disk from the active layer to the base. Once this is
complete, libvirt will stop reporting the job and vdsm will handle
post-job cleanup as usual.
This patch depends on currently unreleased libvirt and qemu features
that are targeted for a near term release.
Change-Id: Idab76081c2d004bc4f9e5bc9cb72e86845640f6a
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1109918
Signed-off-by: Adam Litke <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/28598
Reviewed-by: Dan Kenigsberg <[email protected]>
Reviewed-by: Federico Simoncelli <[email protected]>
---
M vdsm/virt/vm.py
1 file changed, 31 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/31050/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index f9a78bb..b33ed0c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2444,6 +2444,9 @@
ret = {}
watermarks = self._getMergeWriteWatermarks()
for job in self.conf['_blockJobs'].values():
+ if 'done' in job:
+ # Skip active layer commits that are in the cleanup phase
+ continue
drive = self._findDriveByUUIDs(job['disk'])
if not drive.blockDev or drive.format != 'cow':
continue
@@ -5487,6 +5490,15 @@
self.saveState()
return True
+ def _activeLayerCommitReady(self, jobInfo):
+ try:
+ pivot = libvirt.VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT
+ except AttributeError:
+ return False
+ if (jobInfo['cur'] == jobInfo['end'] and jobInfo['type'] == pivot):
+ return True
+ return False
+
def queryBlockJobs(self):
def startCleanup(job, drive):
t = LiveMergeCleanupThread(self, job['jobID'], drive)
@@ -5527,6 +5539,12 @@
entry['bandwidth'] = liveInfo['bandwidth']
entry['cur'] = str(liveInfo['cur'])
entry['end'] = str(liveInfo['end'])
+ if self._activeLayerCommitReady(liveInfo):
+ try:
+ self.handleBlockJobEvent(jobID, drive, 'pivot')
+ except Exception:
+ # Just log it. We will retry next time
+ self.log.error("Pivot failed for job %s", jobID)
else:
# Libvirt has stopped reporting this job so we know it will
# never report it again.
@@ -5595,6 +5613,14 @@
# backing files. This is necessary to ensure that a volume chain is
# visible from any host even if the mountpoint is different.
flags = libvirt.VIR_DOMAIN_BLOCK_COMMIT_RELATIVE
+
+ if topVolUUID == drive.volumeID:
+ # Pass a flag to libvirt to indicate that we expect a two phase
+ # block job. In the first phase, data is copied to base. Once
+ # completed, an event is raised to indicate that the job has
+ # transitioned to the second phase. We must then tell libvirt to
+ # pivot to the new active layer (baseVolUUID).
+ flags |= libvirt.VIR_DOMAIN_BLOCK_COMMIT_ACTIVE
# Take the jobs lock here to protect the new job we are tracking from
# being cleaned up by queryBlockJobs() since it won't exist right away
@@ -5724,6 +5750,11 @@
if mode == 'finished':
self.log.info("Live merge job completed (job %s)", jobID)
self._syncVolumeChain(drive)
+ elif mode == 'pivot':
+ self.log.info("Requesting pivot to complete active layer commit "
+ "(job %s)", jobID)
+ flags = libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT
+ self._dom.blockJobAbort(drive.name, flags)
else:
raise RuntimeError("Invalid mode: '%s'" % mode)
--
To view, visit http://gerrit.ovirt.org/31050
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idab76081c2d004bc4f9e5bc9cb72e86845640f6a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Adam Litke <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches