Change in vdsm[master]: storage: Factor apparentsize adjustment into a reusable func...

alitke at redhat.com alitke at redhat.com
Mon Jul 27 20:39:06 UTC 2015


Adam Litke has uploaded a new change for review.

Change subject: storage: Factor apparentsize adjustment into a reusable function
......................................................................

storage: Factor apparentsize adjustment into a reusable function

When creating a new volume sometimes the actual size is larger than the
requested size due to underlying storage limitations (such as physical
extent granularity in LVM).  In these cases, the new volume's size must
be adjusted to match the actual size.  The SDM volume creation code
would also like to use this function so extract it into the
VolumeMetadata class.

Change-Id: I7395850e127b941fc50ae8d5659868a2499b5076
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M vdsm/storage/volume.py
1 file changed, 28 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/44/44044/1

diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index f7e5bc0..723b3d9 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -495,6 +495,31 @@
                                                               puuid)
         return None
 
+    @classmethod
+    def adjust_new_volume_size(cls, dom_manifest, img_id, vol_id, req_size,
+                               vol_format):
+        # When the volume format is raw what the guest sees is the apparent
+        # size of the file/device therefore if the requested size doesn't
+        # match the apparent size (eg: physical extent granularity in LVM)
+        # we need to update the size value so that the metadata reflects
+        # the correct state.
+        if vol_format == RAW_FORMAT:
+            apparentSize = int(dom_manifest.getVSize(img_id, vol_id) /
+                               BLOCK_SIZE)
+            if apparentSize < req_size:
+                cls.log.error("The volume %s apparent size %s is smaller "
+                              "than the requested size %s",
+                              vol_id, apparentSize, req_size)
+                raise se.VolumeCreationError()
+            if apparentSize > req_size:
+                cls.log.info("The requested size for volume %s doesn't "
+                             "match the granularity on domain %s, "
+                             "updating the volume size from %s to %s",
+                             vol_id, dom_manifest.sdUUID, req_size,
+                             apparentSize)
+                return apparentSize
+        return req_size
+
 
 class Volume(object):
     log = logging.getLogger('Storage.Volume')
@@ -850,24 +875,9 @@
                 cls.log.error("Failed to create volume %s: %s", volPath, e)
                 vars.task.popRecovery()
                 raise
-            # When the volume format is raw what the guest sees is the apparent
-            # size of the file/device therefore if the requested size doesn't
-            # match the apparent size (eg: physical extent granularity in LVM)
-            # we need to update the size value so that the metadata reflects
-            # the correct state.
-            if volFormat == RAW_FORMAT:
-                apparentSize = int(dom.getVSize(imgUUID, volUUID) / BLOCK_SIZE)
-                if apparentSize < size:
-                    cls.log.error("The volume %s apparent size %s is smaller "
-                                  "than the requested size %s",
-                                  volUUID, apparentSize, size)
-                    raise se.VolumeCreationError()
-                if apparentSize > size:
-                    cls.log.info("The requested size for volume %s doesn't "
-                                 "match the granularity on domain %s, "
-                                 "updating the volume size from %s to %s",
-                                 volUUID, sdUUID, size, apparentSize)
-                    size = apparentSize
+
+            size = VolumeMetadata.adjust_new_volume_size(dom, imgUUID, volUUID,
+                                                         size, volFormat)
 
             vars.task.pushRecovery(
                 task.Recovery("Create volume metadata rollback", clsModule,


-- 
To view, visit https://gerrit.ovirt.org/44044
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7395850e127b941fc50ae8d5659868a2499b5076
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>


More information about the vdsm-patches mailing list