]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes race condition in LVMVolumeDriver create_cloned_volume method
authorRongze Zhu <rongze@unitedstack.com>
Wed, 17 Jul 2013 10:15:04 +0000 (18:15 +0800)
committerRongze Zhu <rongze@unitedstack.com>
Wed, 17 Jul 2013 10:15:04 +0000 (18:15 +0800)
When we create a clone volume, LVMVolumeDriver will firstly create a temp
snapshot for copying, the temp snapshot name is
"clone-snap-%s" % source_volume['id']. When we create multiple clone volumes
of the same volume simultaneously, which would trigger the race issuse.

I changes the temp snapshot name template to "clone-snap-%s" % volume['id'],
so temp snapshot name will be unique.

Fixes bug #1202139

Change-Id: I3a4f2585ea9e6f70b6f6f9889e900f19559b8176

cinder/volume/drivers/lvm.py

index a905a15db710a5a7e8d1d8be16638ea8d00ee5cc..33fef0f8926ab3e76af5d4328dbcecd09f77bc1b 100644 (file)
@@ -300,11 +300,11 @@ class LVMVolumeDriver(driver.VolumeDriver):
         """Creates a clone of the specified volume."""
         LOG.info(_('Creating clone of volume: %s') % src_vref['id'])
         volume_name = CONF.volume_name_template % src_vref['id']
-        temp_id = 'tmp-snap-%s' % src_vref['id']
+        temp_id = 'tmp-snap-%s' % volume['id']
         temp_snapshot = {'volume_name': volume_name,
                          'size': src_vref['size'],
                          'volume_size': src_vref['size'],
-                         'name': 'clone-snap-%s' % src_vref['id'],
+                         'name': 'clone-snap-%s' % volume['id'],
                          'id': temp_id}
         self.create_snapshot(temp_snapshot)
         self._create_volume(volume['name'], self._sizestr(volume['size']))