From c4dd1046cac78a95bfaa55889c70ab7397fb58be Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Tue, 27 May 2014 14:15:21 +0800 Subject: [PATCH] Add strip size support to rbd driver 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 --- cinder/tests/test_rbd.py | 10 ++++++++-- cinder/volume/drivers/rbd.py | 13 ++++++++++++- etc/cinder/cinder.conf.sample | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cinder/tests/test_rbd.py b/cinder/tests/test_rbd.py index c2c572c3b..5c5a77dd8 100644 --- a/cinder/tests/test_rbd.py +++ b/cinder/tests/test_rbd.py @@ -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) diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index ee7ddce95..0160c84a7 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -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') diff --git a/etc/cinder/cinder.conf.sample b/etc/cinder/cinder.conf.sample index 11603c73a..687d2ed6f 100644 --- a/etc/cinder/cinder.conf.sample +++ b/etc/cinder/cinder.conf.sample @@ -1544,6 +1544,10 @@ # 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 -- 2.45.2