Federico Simoncelli has uploaded a new change for review.

Change subject: upgrade: reallocate the metadata slots when needed
......................................................................

upgrade: reallocate the metadata slots when needed

Change-Id: I15b6a85969a10b5e2b852031fc510aabcc2d5276
Signed-off-by: Federico Simoncelli <[email protected]>
---
M vdsm/storage/imageRepository/formatConverter.py
1 file changed, 28 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/9660/1

diff --git a/vdsm/storage/imageRepository/formatConverter.py 
b/vdsm/storage/imageRepository/formatConverter.py
index cd32a62..175f943 100644
--- a/vdsm/storage/imageRepository/formatConverter.py
+++ b/vdsm/storage/imageRepository/formatConverter.py
@@ -29,6 +29,9 @@
 from storage import volume
 
 
+BLKVOL_MAX_OFFSET = sd.LEASES_SIZE - blockVolume.RESERVED_LEASES - 1
+
+
 def __convertDomainMetadataToTags(domain, targetVersion):
     log = logging.getLogger('Storage.DomainMetadataToTags')
 
@@ -131,11 +134,31 @@
         # see volume.setrw for more details.
         vol._setrw(True)
 
+    def v3ReallocateMetadataSlot(domain, vol):
+        metaOffset = vol.getMetaOffset()
+
+        if metaOffset < BLKVOL_MAX_OFFSET:
+            return
+
+        log.debug("Reallocating metadata slot for volume %s", vol.volUUID)
+        newMetaOffset = domain.getFreeMetadataSlot()
+
+        metaContent = vol.getMetadata()
+        log.debug("Copying the metadata for volume %s to the new slot %s",
+                  vol.volUUID, newMetaOffset)
+        vol.createMetadata((domain.sdUUID, newMetaOffset), metaContent)
+
+        log.debug("Switching the metadata slot for volume %s to %s",
+                  vol.volUUID, newMetaOffset)
+        vol.changeVolumeTag(TAG_PREFIX_MD, newMetaOffset);
+
     try:
         if isMsd:
             log.debug("Acquiring the cluster lock for domain %s with "
                       "host id: %s", domain.sdUUID, hostId)
             newClusterLock.acquire(hostId)
+
+        isBlockDomain = domain.getStorageType() in sd.BLOCK_DOMAIN_TYPES
 
         allVolumes = domain.getAllVolumes()
         allImages = set()
@@ -149,6 +172,10 @@
             # The first imgUUID is the imgUUID of the template or the
             # only imgUUID where the volUUID appears.
             vol = domain.produceVolume(imgUUIDs[0], volUUID)
+
+            if isBlockDomain:
+                v3ReallocateMetadataSlot(domain, vol)
+
             v3UpgradeVolumePermissions(vol)
 
             log.debug("Creating the volume lease for %s", volUUID)
@@ -214,8 +241,7 @@
                   "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):
+        if (isBlockDomain and currentVersion not in blockSD.VERS_METADATA_TAG):
             __convertDomainMetadataToTags(domain, targetVersion)
         else:
             domain.setMetaParam(sd.DMDK_VERSION, targetVersion)


--
To view, visit http://gerrit.ovirt.org/9660
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I15b6a85969a10b5e2b852031fc510aabcc2d5276
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to