From f1372d3063a9c3dd878a612cd262694ad1997b10 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 11 May 2017 16:52:49 +0300 Subject: [PATCH] SMBFS: switch to distributed locks This change replaces the SMBFS driver locks with distributed locks. This is a step further in supporting HA A-A deployments. Change-Id: I9fe77d41e5a87a38e7a94e5b8c8e9adbc99a1d82 Closes-Bug: #1607074 --- cinder/tests/unit/windows/test_smbfs.py | 8 +++++--- cinder/volume/drivers/windows/smbfs.py | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cinder/tests/unit/windows/test_smbfs.py b/cinder/tests/unit/windows/test_smbfs.py index 4837e6b95fb..eba1e02b86d 100644 --- a/cinder/tests/unit/windows/test_smbfs.py +++ b/cinder/tests/unit/windows/test_smbfs.py @@ -99,7 +99,7 @@ class WindowsSmbFsTestCase(test.TestCase): return snapshot @mock.patch.object(smbfs.WindowsSmbfsDriver, '_check_os_platform') - @mock.patch.object(remotefs.RemoteFSSnapDriver, 'do_setup') + @mock.patch.object(remotefs.RemoteFSSnapDriverDistributed, 'do_setup') @mock.patch('os.path.exists') @mock.patch('os.path.isabs') @mock.patch.object(image_utils, 'check_qemu_img_version') @@ -422,7 +422,8 @@ class WindowsSmbFsTestCase(test.TestCase): self.assertEqual(expected_fmt, resulted_fmt) - @mock.patch.object(remotefs.RemoteFSSnapDriver, 'create_volume') + @mock.patch.object(remotefs.RemoteFSSnapDriverDistributed, + 'create_volume') def test_create_volume_base(self, mock_create_volume): self._smbfs_driver.create_volume(self.volume) mock_create_volume.assert_called_once_with(self.volume) @@ -541,7 +542,8 @@ class WindowsSmbFsTestCase(test.TestCase): {'volume_status': 'available'}, {'snap_info_contains_snap_id': False}) @ddt.unpack - @mock.patch.object(remotefs.RemoteFSSnapDriver, '_delete_snapshot') + @mock.patch.object(remotefs.RemoteFSSnapDriverDistributed, + '_delete_snapshot') @mock.patch.object(smbfs.WindowsSmbfsDriver, '_local_volume_dir') @mock.patch.object(smbfs.WindowsSmbfsDriver, '_local_path_volume_info') @mock.patch.object(smbfs.WindowsSmbfsDriver, '_write_info_file') diff --git a/cinder/volume/drivers/windows/smbfs.py b/cinder/volume/drivers/windows/smbfs.py index 3da2f020d5a..e2f8cb4ceb1 100644 --- a/cinder/volume/drivers/windows/smbfs.py +++ b/cinder/volume/drivers/windows/smbfs.py @@ -24,6 +24,7 @@ from oslo_utils import fileutils from oslo_utils import units from cinder import context +from cinder import coordination from cinder import exception from cinder.i18n import _ from cinder.image import image_utils @@ -82,7 +83,7 @@ CONF.register_opts(volume_opts) @interface.volumedriver class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, - remotefs_drv.RemoteFSSnapDriver): + remotefs_drv.RemoteFSSnapDriverDistributed): VERSION = VERSION driver_volume_type = 'smbfs' @@ -180,7 +181,7 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, self._pool_mappings[share] = self._get_share_name(share) - @remotefs_drv.locked_volume_id_operation + @coordination.synchronized('{self.driver_prefix}-{volume.id}') def initialize_connection(self, volume, connector): """Allow connection to connector and return connection info. @@ -324,7 +325,7 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, extra_specs.get('smbfs:volume_format') or self.configuration.smbfs_default_volume_format) - @remotefs_drv.locked_volume_id_operation + @coordination.synchronized('{self.driver_prefix}-{volume.id}') def create_volume(self, volume): return super(WindowsSmbfsDriver, self).create_volume(volume) @@ -349,7 +350,7 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, mnt_flags = self.shares[smbfs_share] self._remotefsclient.mount(smbfs_share, mnt_flags) - @remotefs_drv.locked_volume_id_operation + @coordination.synchronized('{self.driver_prefix}-{volume.id}') def delete_volume(self, volume): """Deletes a logical volume.""" if not volume.provider_location: @@ -431,7 +432,7 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, self._vhdutils.create_differencing_vhd(new_snap_path, backing_file_full_path) - @remotefs_drv.locked_volume_id_operation + @coordination.synchronized('{self.driver_prefix}-{volume.id}') def extend_volume(self, volume, size_gb): LOG.info('Extending volume %s.', volume.id) @@ -504,7 +505,7 @@ class WindowsSmbfsDriver(remotefs_drv.RemoteFSPoolMixin, 'extend volume %s to %sG.' % (volume.id, size_gb)) - @remotefs_drv.locked_volume_id_operation + @coordination.synchronized('{self.driver_prefix}-{volume.id}') def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image."""