From 5ba26c8aa5b295a1202fbc6c01eb050ce3f3af3d Mon Sep 17 00:00:00 2001 From: Avishay Traeger Date: Sat, 8 Feb 2014 22:59:58 +0200 Subject: [PATCH] Storwize/SVC: Fix races in host-related functions In the Storwize/SVC driver, initialize_connection checks if a host object exists on the storage, and if not, creates one. Similarly, terminate_connection checks if there are any more mappings for this host, and deletes the host object if there are none. Consequently, there exist races between two initialize_connection calls, two terminate_connection calls, or one and one. The easy solution here is to use locks. Because locks are files on the local machine, this implies that all cinder-volume processes managing a given Storwize/SVC contoller run on the same machine. Change-Id: I62cd992e7150e7d16f1a2b2be6ef61c64b638858 Closes-Bug: #1274123 --- cinder/volume/drivers/ibm/storwize_svc/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py index 399258f0a..a6df1eced 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py +++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py @@ -41,6 +41,7 @@ from cinder import exception from cinder.openstack.common import excutils from cinder.openstack.common import log as logging from cinder import units +from cinder import utils from cinder.volume.drivers.ibm.storwize_svc import helpers as storwize_helpers from cinder.volume.drivers.san import san from cinder.volume import volume_types @@ -109,9 +110,10 @@ class StorwizeSVCDriver(san.SanDriver): get_volume_stats, minor bug fixes 1.2.0 - Added retype 1.2.1 - Code refactor, improved exception handling + 1.2.2 - Fix bug #1274123 (races in host-related functions) """ - VERSION = "1.2.1" + VERSION = "1.2.2" def __init__(self, *args, **kwargs): super(StorwizeSVCDriver, self).__init__(*args, **kwargs) @@ -260,6 +262,7 @@ class StorwizeSVCDriver(san.SanDriver): return self._helpers.get_vdisk_params(self.configuration, self._state, type_id, volume_type=volume_type) + @utils.synchronized('storwize-host', external=True) def initialize_connection(self, volume, connector): """Perform the necessary work so that an iSCSI/FC connection can be made. @@ -390,6 +393,7 @@ class StorwizeSVCDriver(san.SanDriver): return {'driver_volume_type': type_str, 'data': properties, } + @utils.synchronized('storwize-host', external=True) def terminate_connection(self, volume, connector, **kwargs): """Cleanup after an iSCSI connection has been terminated. -- 2.45.2