Adam Litke has uploaded a new change for review.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Live Merge: Proactively extend merge target volume
Since libvirt is not yet providing the write watermark information for all volumes, we need to employ a workaround to support live merge on block-based storage. When starting a merge, we can request the base volume (merge target) to be extended to the size of the top volume (merge source) plus one chunk to accomodate active writing. This may cause some over-extension of the merge target volume but the upside is that the merge should complete without active monitoring. Future versions of oVirt will take advantage of an upcoming libvirt enhancement to report write watermarks for all volumes which will allow on-demand volume extension.
Change-Id: I3d483f9dfe6e19a9f9fec84950bf2ea0c7ed7946 Signed-off-by: Adam Litke alitke@redhat.com --- M vdsm/virt/vm.py 1 file changed, 29 insertions(+), 73 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/35573/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 15d4620..82cb0f1 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -1356,8 +1356,9 @@ to be extended. For the leaf volume curSize == self.apparentsize. For internal volumes it is discovered by calling irs.getVolumeSize(). """ - return (self.volExtensionChunk + - ((curSize + constants.MEGAB - 1) / constants.MEGAB)) + nextSize = (self.volExtensionChunk + + ((curSize + constants.MEGAB - 1) / constants.MEGAB)) + return min(nextSize, self.truesize)
@property def networkDev(self): @@ -2468,69 +2469,12 @@ with self._confLock: self.conf['timeOffset'] = newTimeOffset
- def _getMergeWriteWatermarks(self): - drives = [drive for drive in self.getDiskDevices() - if isVdsmImage(drive) and drive.blockDev] - allChains = self._driveGetActualVolumeChain(drives).values() - return dict((entry.uuid, entry.allocation) - for chain in allChains - for entry in chain) - - def _getLiveMergeExtendCandidates(self): - ret = {} - - # The common case is that there are no active jobs. - if not self.conf['_blockJobs'].values(): - return ret - - try: - watermarks = self._getMergeWriteWatermarks() - except LookupError: - self.log.warning("Failed to look up watermark information") - return ret - - for job in self.conf['_blockJobs'].values(): - try: - drive = self._findDriveByUUIDs(job['disk']) - except LookupError: - # After an active layer merge completes the vdsm metadata will - # be out of sync for a brief period. If we cannot find the old - # disk then it's safe to skip it. - continue - if not drive.blockDev or drive.format != 'cow': - continue - - if job['strategy'] == 'commit': - volumeID = job['baseVolume'] - else: - self.log.debug("Unrecognized merge strategy '%s'", - job['strategy']) - continue - volSize = self.cif.irs.getVolumeSize(drive.domainID, drive.poolID, - drive.imageID, volumeID) - if volSize['status']['code'] != 0: - self.log.error("Unable to get the size of volume %s (domain: " - "%s image: %s)", volumeID, drive.domainID, - drive.imageID) - continue - - if volumeID in watermarks: - self.log.debug("Adding live merge extension candidate: " - "volume=%s", volumeID) - ret[drive.imageID] = { - 'alloc': watermarks[volumeID], - 'physical': int(volSize['truesize']), - 'capacity': drive.apparentsize, - 'volumeID': volumeID} - else: - self.log.warning("No watermark info available for %s", - volumeID) - return ret - def _getExtendCandidates(self): ret = []
- mergeCandidates = self._getLiveMergeExtendCandidates() + # FIXME: mergeCandidates should be a dictionary of candidate volumes + # once libvirt starts reporting watermark information for all volumes. + mergeCandidates = {} for drive in self._devices[DISK_DEVICES]: if not drive.blockDev or drive.format != 'cow': continue @@ -5870,7 +5814,6 @@ if res['info']['voltype'] == 'SHARED': self.log.error("merge: Refusing to merge into a shared volume") return errCode['mergeErr'] - baseSize = int(res['info']['apparentsize'])
# Indicate that we expect libvirt to maintain the relative paths of # backing files. This is necessary to ensure that a volume chain is @@ -5884,6 +5827,19 @@ # 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 + + # If top is the active layer, it's allocated size is stored in + # drive.apparantsize. + topSize = drive.apparentsize + else: + # If top is an internal volume, we must call getVolumeInfo + res = self.cif.irs.getVolumeInfo(drive.domainID, drive.poolID, + drive.imageID, topVolUUID) + if res['status']['code'] != 0: + self.log.error("Unable to get volume info for '%s'", + topVolUUID) + return errCode['mergeErr'] + topSize = int(res['info']['apparentsize'])
# 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 @@ -5908,9 +5864,13 @@
# blockCommit will cause data to be written into the base volume. # Perform an initial extension to ensure there is enough space to - # start copying. The normal monitoring code will take care of any - # future internal volume extensions that may be necessary - self.extendDriveVolume(drive, baseVolUUID, baseSize) + # copy all the required data. Normally we'd use monitoring to extend + # the volume on-demand but internal watermark information is not being + # reported by libvirt so we must do the full extension up front. In + # the worst case, we'll need to extend 'base' to the same size as 'top' + # plus a bit more to accomodate additional writes to 'top' during the + # live merge operation. + self.extendDriveVolume(drive, baseVolUUID, topSize)
# Trigger the collection of stats before returning so that callers # of getVmStats after this returns will see the new job @@ -5938,14 +5898,10 @@ break sourceAttr = ('file', 'dev')[drive.blockDev] path = sourceXML.getAttribute(sourceAttr) + + # TODO: Allocation information is not available in the XML. Switch + # to the new interface once it becomes available in libvirt. alloc = None - if drive.blockDev: - allocXML = find_element_by_name(diskXML, 'allocation') - if not allocXML: - self.log.debug("<allocation/> missing from backing " - "chain for block device %s", drive.name) - break - alloc = int(allocXML.firstChild.nodeValue) bsXML = find_element_by_name(diskXML, 'backingStore') if not bsXML: self.log.warning("<backingStore/> missing from backing "
Adam Litke has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 2: Verified+1
Allon Mureinik has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 2: Code-Review+1
(1 comment)
http://gerrit.ovirt.org/#/c/35573/2/vdsm/virt/vm.py File vdsm/virt/vm.py:
Line 1357: For internal volumes it is discovered by calling irs.getVolumeSize(). Line 1358: """ Line 1359: nextSize = (self.volExtensionChunk + Line 1360: ((curSize + constants.MEGAB - 1) / constants.MEGAB)) Line 1361: return min(nextSize, self.truesize) This seems generally true, regardless of live-merge scenarios. IIUC, any call extendDrivesIfNeeded will hit this caveat, so perhaps is worth having this change in a different patch that can easily be merges/reverted on its own right. Line 1362: Line 1363: @property Line 1364: def networkDev(self): Line 1365: try:
Dan Kenigsberg has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 2:
(1 comment)
http://gerrit.ovirt.org/#/c/35573/2//COMMIT_MSG Commit Message:
Line 14: cause some over-extension of the merge target volume but the upside is Line 15: that the merge should complete without active monitoring. Future Line 16: versions of oVirt will take advantage of an upcoming libvirt enhancement Line 17: to report write watermarks for all volumes which will allow on-demand Line 18: volume extension. Please use
Label: ovirt-3.5-only
and explain why we don't need this in master. (e.g. is it ok with libvirt upstream?) Line 19: Line 20: Change-Id: I3d483f9dfe6e19a9f9fec84950bf2ea0c7ed7946 Line 21: Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1155583
Yaniv Bronhaim has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 2: Code-Review-1
get blocker ack and consider dan's comment
Adam Litke has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 2:
After talking with Nir, we're going to submit this to master too.
Allon Mureinik has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 2:
(1 comment)
There's a patch on the master branch too now: http://gerrit.ovirt.org/#/c/35614/
Let's continue the discussion there, and once that patch is finilized, we can backport here.
Also note that the bug (https://bugzilla.redhat.com/show_bug.cgi?id=1155583) now has all the appropriate flags.
http://gerrit.ovirt.org/#/c/35573/2//COMMIT_MSG Commit Message:
Line 14: cause some over-extension of the merge target volume but the upside is Line 15: that the merge should complete without active monitoring. Future Line 16: versions of oVirt will take advantage of an upcoming libvirt enhancement Line 17: to report write watermarks for all volumes which will allow on-demand Line 18: volume extension.
Please use
This decision was reverted - there's also a patch upstream http://gerrit.ovirt.org/#/c/35614/ Line 19: Line 20: Change-Id: I3d483f9dfe6e19a9f9fec84950bf2ea0c7ed7946 Line 21: Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1155583
Adam Litke has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 3: Verified+1
Allon Mureinik has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 3: Code-Review+1
Federico Simoncelli has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 3: Code-Review+1
Dan Kenigsberg has submitted this change and it was merged.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Live Merge: Proactively extend merge target volume
Since libvirt is not yet providing the write watermark information for all volumes, we need to employ a workaround to support live merge on block-based storage. When starting a merge, we can request the base volume (merge target) to be extended to the size of the top volume (merge source) plus one chunk to accomodate active writing. This may cause some over-extension of the merge target volume but the upside is that the merge should complete without active monitoring. Future versions of oVirt will take advantage of an upcoming libvirt enhancement to report write watermarks for all volumes which will allow on-demand volume extension.
Change-Id: I3d483f9dfe6e19a9f9fec84950bf2ea0c7ed7946 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1155583 Signed-off-by: Adam Litke alitke@redhat.com Reviewed-on: http://gerrit.ovirt.org/35614 Reviewed-by: Allon Mureinik amureini@redhat.com Reviewed-by: Francesco Romani fromani@redhat.com Reviewed-by: Federico Simoncelli fsimonce@redhat.com Reviewed-on: http://gerrit.ovirt.org/35573 Reviewed-by: Dan Kenigsberg danken@redhat.com --- M vdsm/virt/vm.py 1 file changed, 26 insertions(+), 71 deletions(-)
Approvals: Adam Litke: Verified Federico Simoncelli: Looks good to me, but someone else must approve Allon Mureinik: Looks good to me, but someone else must approve Dan Kenigsberg: Looks good to me, approved
Dan Kenigsberg has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 3: Code-Review+2
Yaniv is away, merging.
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Live Merge: Proactively extend merge target volume ......................................................................
Patch Set 4:
Build Failed
http://jenkins.ovirt.org/job/vdsm_3.5_create-rpms-fc19-x86_64_merged/126/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_3.5_create-rpms-fc20-x86_64_merged/126/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_3.5_create-rpms-el7-x86_64_merged/126/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_3.5_create-rpms-el6-x86_64_merged/129/ : SUCCESS
vdsm-patches@lists.fedorahosted.org