]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
3PAR drivers volume size conversion is incorrect
authorKurt Martin <kurt.f.martin@hpe.com>
Fri, 6 Nov 2015 16:42:50 +0000 (08:42 -0800)
committerKurt Martin <kurt.f.martin@hpe.com>
Fri, 6 Nov 2015 16:43:25 +0000 (08:43 -0800)
The 3PAR drivers conversion of the volume size to gibibytes (GiBs) is
incorrect, resulting in slightly smaller volumes than expected. The
drivers were assuming the input was gigabytes (GBs) when in fact the
input was gibibytes (GiBs) as documented by the cinder API.

Change-Id: I5c86f506790723195f8f9433c9e5eedddd53a4ab
Closes-bug: 1513158

cinder/tests/unit/test_hp3par.py
cinder/volume/drivers/san/hp/hp_3par_common.py

index 1b3bdb09c39e6d261ffe7f30689439067fcd6048..c80d8b8072964ae1a62e0ce3e06cd7c35c1d6114 100644 (file)
@@ -669,7 +669,7 @@ class HP3PARBaseDriver(object):
                 mock.call.createVolume(
                     self.VOLUME_3PAR_NAME,
                     HP3PAR_CPG,
-                    1907, {
+                    2048, {
                         'comment': comment,
                         'tpvv': True,
                         'tdvv': False,
@@ -698,7 +698,7 @@ class HP3PARBaseDriver(object):
                 mock.call.createVolume(
                     self.VOLUME_3PAR_NAME,
                     HP3PAR_CPG2,
-                    1907, {
+                    2048, {
                         'comment': comment,
                         'tpvv': True,
                         'tdvv': False,
@@ -854,7 +854,7 @@ class HP3PARBaseDriver(object):
                 mock.call.createVolume(
                     self.VOLUME_3PAR_NAME,
                     HP3PAR_CPG,
-                    1907, {
+                    2048, {
                         'comment': comment,
                         'tpvv': True,
                         'tdvv': False,
@@ -899,7 +899,7 @@ class HP3PARBaseDriver(object):
                 mock.call.createVolume(
                     self.VOLUME_3PAR_NAME,
                     HP3PAR_CPG,
-                    1907, {
+                    2048, {
                         'comment': comment,
                         'tpvv': False,
                         'tdvv': True,
@@ -949,7 +949,7 @@ class HP3PARBaseDriver(object):
                 mock.call.createVolume(
                     self.VOLUME_3PAR_NAME,
                     HP3PAR_CPG,
-                    1907, {
+                    2048, {
                         'comment': comment,
                         'tpvv': True,
                         'tdvv': False,
index 32d51e097f5700e599383d97b5efc3a6ad9254c6..5e791f97c685e8cd3d8e590baa11d4bae7d5d213 100644 (file)
@@ -201,11 +201,12 @@ class HP3PARCommon(object):
         2.0.49 - Added client CPG stats to driver volume stats. bug #1482741
         2.0.50 - Add over subscription support
         2.0.51 - Adds consistency group support
-        2.0.52 - Added update_migrated_volume. bug # 1492023
+        2.0.52 - Added update_migrated_volume. bug #1492023
+        2.0.53 - Fix volume size conversion. bug #1513158
 
     """
 
-    VERSION = "2.0.52"
+    VERSION = "2.0.53"
 
     stats = {}
 
@@ -789,18 +790,13 @@ class HP3PARCommon(object):
         return vol_encoded
 
     def _capacity_from_size(self, vol_size):
-
-        # because 3PAR volume sizes are in
-        # Mebibytes, Gigibytes, not Megabytes.
-        MB = 1000
-        MiB = 1.048576
-
+        # because 3PAR volume sizes are in Mebibytes.
         if int(vol_size) == 0:
-            capacity = MB  # default: 1GB
+            capacity = units.Gi  # default: 1GiB
         else:
-            capacity = vol_size * MB
+            capacity = vol_size * units.Gi
 
-        capacity = int(round(capacity / MiB))
+        capacity = int(math.ceil(capacity / units.Mi))
         return capacity
 
     def _delete_3par_host(self, hostname):