New patch submitted by Igor Lvovsky (ilvovsky(a)redhat.com)
You can review this change at:
http://gerrit.usersys.redhat.com/665
commit 700bc5898fa71ae91b8e7ac2cfdd4804d40cdab4
Author: Igor Lvovsky <ilvovsky(a)redhat.com>
Date: Wed Jul 6 13:52:45 2011 +0300
BZ#719255 - Release lock if prepare volume failed
Change-Id: I57a78ff800f0b8f006ca9c4fed3bb6ac185a55ed
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 7081558..14c281e 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1663,12 +1663,17 @@ class HSM:
imageResourcesNamespace = sd.getNamespace(sdUUID, IMAGE_NAMESPACE)
imgResource = rmanager.acquireResource(imageResourcesNamespace, imgUUID,
rm.LockType.exclusive)
imgResource.autoRelease = False
- vol = SDF.produce(sdUUID=sdUUID).produceVolume(imgUUID=imgUUID, volUUID=volUUID)
- # NB We want to be sure that at this point HSM does not use stale LVM
- # cache info, so we call refresh explicitely. We may want to remove
- # this refresh later, when we come up with something better.
- vol.refreshVolume()
- vol.prepare(rw=rw)
+ try:
+ vol = SDF.produce(sdUUID=sdUUID).produceVolume(imgUUID=imgUUID,
volUUID=volUUID)
+ # NB We want to be sure that at this point HSM does not use stale LVM
+ # cache info, so we call refresh explicitely. We may want to remove
+ # this refresh later, when we come up with something better.
+ vol.refreshVolume()
+ vol.prepare(rw=rw)
+ except Exception:
+ imgResource.autoRelease = True
+ self.log.error("Prepare volume %s in domain %s failed", volUUID,
sdUUID, exc_info=True)
+ raise
def public_teardownVolume(self, sdUUID, spUUID, imgUUID, volUUID, rw=False, options =
None):