]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add strip size support to rbd driver
authorHaomai Wang <haomai@unitedstack.com>
Tue, 27 May 2014 06:15:21 +0000 (14:15 +0800)
committerHaomai Wang <haomai@unitedstack.com>
Wed, 11 Jun 2014 07:56:42 +0000 (15:56 +0800)
Rbd support strip size for volume, in general, we would like to think the
default value 4M is a proper for most of users.

In the ceph side, the proper value of rbd strip size can improve performance for
the special OSD backend.

Implements blueprint add-rbd-strip-size

Change-Id: I44d89681a78bd70d8c185e3da7d58f59e6076899
Signed-off-by: Haomai Wang <haomai@unitedstack.com>
cinder/tests/test_rbd.py
cinder/volume/drivers/rbd.py
etc/cinder/cinder.conf.sample

index c2c572c3b5be9346b4d51218afc42b32df31b959..5c5a77dd806f9db44584842b258cfd7aac0cfa1d 100644 (file)
@@ -16,6 +16,7 @@
 #    under the License.
 
 
+import math
 import mock
 import os
 import tempfile
@@ -144,6 +145,7 @@ class RBDTestCase(test.TestCase):
         self.cfg.rbd_secret_uuid = None
         self.cfg.rbd_user = None
         self.cfg.volume_dd_blocksize = '1M'
+        self.cfg.rbd_store_chunk_size = 4
 
         mock_exec = mock.Mock()
         mock_exec.return_value = ('', '')
@@ -171,8 +173,10 @@ class RBDTestCase(test.TestCase):
 
             self.driver.create_volume(self.volume)
 
+            chunk_size = self.cfg.rbd_store_chunk_size * units.MiB
+            order = int(math.log(chunk_size, 2))
             args = [client.ioctx, str(self.volume_name),
-                    self.volume_size * units.GiB]
+                    self.volume_size * units.GiB, order]
             kwargs = {'old_format': False,
                       'features': self.mock_rbd.RBD_FEATURE_LAYERING}
             self.mock_rbd.RBD.create.assert_called_once_with(*args, **kwargs)
@@ -192,8 +196,10 @@ class RBDTestCase(test.TestCase):
 
             self.driver.create_volume(self.volume)
 
+            chunk_size = self.cfg.rbd_store_chunk_size * units.MiB
+            order = int(math.log(chunk_size, 2))
             args = [client.ioctx, str(self.volume_name),
-                    self.volume_size * units.GiB]
+                    self.volume_size * units.GiB, order]
             kwargs = {'old_format': True,
                       'features': 0}
             self.mock_rbd.RBD.create.assert_called_once_with(*args, **kwargs)
index ee7ddce95119855a993271be1a3ef45157726a02..0160c84a78ce7b9d80585a7230fc22933e43ba40 100644 (file)
@@ -16,6 +16,7 @@
 from __future__ import absolute_import
 import io
 import json
+import math
 import os
 import tempfile
 import urllib
@@ -68,7 +69,11 @@ rbd_opts = [
                default=5,
                help='Maximum number of nested volume clones that are '
                     'taken before a flatten occurs. Set to 0 to disable '
-                    'cloning.')]
+                    'cloning.'),
+    cfg.IntOpt('rbd_store_chunk_size', default=4,
+               help=_('Volumes will be chunked into objects of this size '
+                      '(in megabytes).')),
+]
 
 CONF = cfg.CONF
 CONF.register_opts(rbd_opts)
@@ -471,6 +476,8 @@ class RBDDriver(driver.VolumeDriver):
 
         old_format = True
         features = 0
+        chunk_size = CONF.rbd_store_chunk_size * units.MiB
+        order = int(math.log(chunk_size, 2))
         if self._supports_layering():
             old_format = False
             features = self.rbd.RBD_FEATURE_LAYERING
@@ -479,6 +486,7 @@ class RBDDriver(driver.VolumeDriver):
             self.rbd.RBD().create(client.ioctx,
                                   str(volume['name']),
                                   size,
+                                  order,
                                   old_format=old_format,
                                   features=features)
 
@@ -782,10 +790,13 @@ class RBDDriver(driver.VolumeDriver):
 
             self.delete_volume(volume)
 
+            chunk_size = CONF.rbd_store_chunk_size * units.MiB
+            order = int(math.log(chunk_size, 2))
             # keep using the command line import instead of librbd since it
             # detects zeroes to preserve sparseness in the image
             args = ['rbd', 'import',
                     '--pool', self.configuration.rbd_pool,
+                    '--order', order,
                     tmp.name, volume['name']]
             if self._supports_layering():
                 args.append('--new-format')
index 11603c73a675a6c621c7529bb8c99b61934f9ae7..687d2ed6f83086b7d28a2bd181aa0f7281f868a6 100644 (file)
 # value)
 #rbd_max_clone_depth=5
 
+# Volumes will be chunked into objects of this size (in
+# megabytes). (integer value)
+#rbd_store_chunk_size=4
+
 
 #
 # Options defined in cinder.volume.drivers.san.hp.hp_3par_common