Change in vdsm[master]: virt: Check if a drive is extendable before extending

nsoffer at redhat.com nsoffer at redhat.com
Sun Feb 8 09:31:23 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: virt: Check if a drive is extendable before extending
......................................................................

virt: Check if a drive is extendable before extending

Previously extendDriveVolume() was checking if a drive is a block device
and assumed that callers checked the drive format. The check was unneeded
when called from extendDrivesIfNeeded(), and spreading the logic between
different methods makes the code harder to understand.

Now extendDriveVolume() requires that callers are doing the required
checks and callers are using new Drive.extendable before calling it.

When we support LSM between mixed storage domain, Drive.extendable will
encapsulate the logic for handling replication of file-based drive to
block based storage domain.

In merge(), we are always dealing with cow volumes, so checking for
blockDev is enough. Using Drive.extendable for clarity.

Change-Id: I48416dde002272d45761296f176b97f4d870849d
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 13 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/37573/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6c78238..83a479d 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1474,9 +1474,11 @@
         return len(extend) > 0
 
     def extendDriveVolume(self, vmDrive, volumeID, curSize):
-        if not vmDrive.blockDev:
-            return
+        """
+        Extend drive volume and its replica volume during replication.
 
+        Must be called only when the drive or the replica are extendable.
+        """
         newSize = vmDrive.getNextVolumeSize(curSize)  # newSize is in megabytes
 
         if getattr(vmDrive, 'diskReplicate', None):
@@ -3489,12 +3491,13 @@
             self._delDiskReplica(srcDrive)
             return errCode['replicaErr']
 
-        try:
-            self.extendDriveVolume(srcDrive, srcDrive.volumeID,
-                                   srcDrive.apparentsize)
-        except Exception:
-            self.log.exception("Initial extension request failed for %s",
-                               srcDrive.name)
+        if srcDrive.extendable:
+            try:
+                self.extendDriveVolume(srcDrive, srcDrive.volumeID,
+                                       srcDrive.apparentsize)
+            except Exception:
+                self.log.exception("Initial extension request failed for %s",
+                                   srcDrive.name)
 
         return {'status': doneCode}
 
@@ -4772,7 +4775,8 @@
         # 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)
+        if drive.extendable:
+            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


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I48416dde002272d45761296f176b97f4d870849d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list