Merge "Add strip size support to rbd driver"

This commit is contained in:
Jenkins 2014-06-18 07:56:37 +00:00 committed by Gerrit Code Review
commit 0d1ae8b126
3 changed files with 24 additions and 3 deletions
cinder
tests
volume/drivers
etc/cinder

@ -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)

@ -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)
@ -778,10 +786,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')

@ -1578,6 +1578,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