From 201890c17e0f29d1ec8e5040206ecd1be09e22f7 Mon Sep 17 00:00:00 2001 From: Rongze Zhu Date: Wed, 17 Jul 2013 18:15:04 +0800 Subject: [PATCH] Fixes race condition in LVMVolumeDriver create_cloned_volume method 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index a905a15db..33fef0f89 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -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'])) -- 2.45.2