From 33480cbc90a4810aa99e3fc7b36e879cdb0c19d4 Mon Sep 17 00:00:00 2001 From: Federico Simoncelli Date: Wed, 9 Jan 2013 09:57:52 +0200 Subject: [PATCH 19/22] upgrade: force upgrade to v2 before upgrading to v3 During the upgrade of a domain to version 3 vdsm reallocates the metadata slots that are higher than 1947 (given a leases LV of 2Gb) in order to use the same offsets for the volume leases (BZ#882276 and git commit hash 2ba76e3). This has no effect when the domain is version 0 since the metadata slots offsets are fixed (the first physical extent of the LV) and they can't be reallocated. In such case the domain must be upgraded to version 2 first. Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=893184 Change-Id: I2bd424ad29e76d1368ff2959bb8fe45afc595cdb Signed-off-by: Federico Simoncelli Reviewed-on: http://gerrit.ovirt.org/10792 Reviewed-by: Ayal Baron Tested-by: Haim Ateya Reviewed-on: http://gerrit.ovirt.org/11462 --- vdsm/storage/imageRepository/formatConverter.py | 26 +++++++++++++++++-------- vdsm/storage/volume.py | 4 +++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/vdsm/storage/imageRepository/formatConverter.py b/vdsm/storage/imageRepository/formatConverter.py index 0d7dd6d..88b053d 100644 --- a/vdsm/storage/imageRepository/formatConverter.py +++ b/vdsm/storage/imageRepository/formatConverter.py @@ -93,6 +93,23 @@ def v3DomainConverter(repoPath, hostId, domain, isMsd): log = logging.getLogger('Storage.v3DomainConverter') log.debug("Starting conversion for domain %s", domain.sdUUID) + targetVersion = 3 + currentVersion = domain.getVersion() + + # For block domains if we're upgrading from version 0 we need to first + # upgrade to version 2 and then proceed to upgrade to version 3. + if domain.getStorageType() in sd.BLOCK_DOMAIN_TYPES: + if currentVersion == 0: + log.debug("Upgrading domain %s from version %s to version 2", + domain.sdUUID, currentVersion) + v2DomainConverter(repoPath, hostId, domain, isMsd) + currentVersion = domain.getVersion() + + if currentVersion != 2: + log.debug("Unsupported conversion from version %s to version %s", + currentVersion, targetVersion) + raise se.UnsupportedDomainVersion(currentVersion) + if domain.getStorageType() in sd.FILE_DOMAIN_TYPES: log.debug("Setting permissions for domain %s", domain.sdUUID) domain.setMetadataPermissions() @@ -268,17 +285,10 @@ def v3DomainConverter(repoPath, hostId, domain, isMsd): "not critical since the volume might be in use", imgUUID, exc_info=True) - targetVersion = 3 - currentVersion = domain.getVersion() log.debug("Finalizing the storage domain upgrade from version %s to " "version %s for domain %s", currentVersion, targetVersion, domain.sdUUID) - - if (currentVersion not in blockSD.VERS_METADATA_TAG - and domain.getStorageType() in sd.BLOCK_DOMAIN_TYPES): - __convertDomainMetadataToTags(domain, targetVersion) - else: - domain.setMetaParam(sd.DMDK_VERSION, targetVersion) + domain.setMetaParam(sd.DMDK_VERSION, targetVersion) except: if isMsd: diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index cde612a..12dd188 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -503,7 +503,9 @@ class Volume(object): cls.newMetadata(metaId, sdUUID, imgUUID, srcVolUUID, size, type2name(volFormat), type2name(preallocate), volType, diskType, desc, LEGAL_VOL) - cls.newVolumeLease(metaId, sdUUID, volUUID) + + if dom.hasVolumeLeases(): + cls.newVolumeLease(metaId, sdUUID, volUUID) except se.StorageException: cls.log.error("Unexpected error", exc_info=True) -- 1.8.1