]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix creating volume by snapshot for GPFS driver
authorDigvijay Ukirde <digvijay.ukirde@in.ibm.com>
Tue, 22 Dec 2015 09:54:03 +0000 (15:24 +0530)
committerDigvijay Ukirde <digvijay.ukirde@in.ibm.com>
Thu, 24 Dec 2015 06:29:37 +0000 (06:29 +0000)
For a operation of creating volume from volume snapshot,
GPFS driver is currently doing a full copy instead of clone when
it is creating a new volume. This happens when the source volume
is not in any consistency group.

With this patch, a GPFS file clone is created when both the volumes
(snapshot parent volume and new volume being created) are not in
any consistency group.

Change-Id: I0aa550842fb16b7abb8765e4aa8dce61cd0994c3
Closes-bug: #1528305

cinder/tests/unit/test_gpfs.py
cinder/volume/drivers/ibm/gpfs.py

index 14d7dcc5a1d2921165da32e0398f58ca47dfc0a6..2bdecae42eee73053a0e85e7fcb60b7ba4d97435 100644 (file)
@@ -855,6 +855,9 @@ class GPFSDriverTestCase(test.TestCase):
         mock_resize_volume_file.return_value = 5 * units.Gi
         volume = self._fake_volume()
         volume['consistencygroup_id'] = None
+        self.driver.db = mock.Mock()
+        self.driver.db.volume_get = mock.Mock()
+        self.driver.db.volume_get.return_value = volume
         snapshot = self._fake_snapshot()
         mock_snapshot_path.return_value = "/tmp/fakepath"
         self.assertEqual({'size': 5.0},
@@ -885,6 +888,9 @@ class GPFSDriverTestCase(test.TestCase):
         mock_resize_volume_file.return_value = 5 * units.Gi
         volume = self._fake_volume()
         volume['consistencygroup_id'] = None
+        self.driver.db = mock.Mock()
+        self.driver.db.volume_get = mock.Mock()
+        self.driver.db.volume_get.return_value = volume
         snapshot = self._fake_snapshot()
         mock_snapshot_path.return_value = "/tmp/fakepath"
         mock_set_volume_attributes.return_value = True
index 5fbb70e2f8f2b52ca2ccde4363628fd6a0ffe7ed..656e6a9c4a0a8f94bf68c212ff1486713d548895 100644 (file)
@@ -542,12 +542,11 @@ class GPFSDriver(driver.ConsistencyGroupVD, driver.ExtendVD,
         # check if the snapshot lies in the same CG as the volume to be created
         # if yes, clone the volume from the snapshot, else perform full copy
         clone = False
-        if volume['consistencygroup_id'] is not None:
-            ctxt = context.get_admin_context()
-            snap_parent_vol = self.db.volume_get(ctxt, snapshot['volume_id'])
-            if (volume['consistencygroup_id'] ==
-                    snap_parent_vol['consistencygroup_id']):
-                clone = True
+        ctxt = context.get_admin_context()
+        snap_parent_vol = self.db.volume_get(ctxt, snapshot['volume_id'])
+        if (volume['consistencygroup_id'] ==
+                snap_parent_vol['consistencygroup_id']):
+            clone = True
         volume_path = self._get_volume_path(volume)
         if clone:
             self._create_gpfs_copy(src=snapshot_path, dest=volume_path)