[NEW PATCH] BZ#719255 - Release lock if prepare volume failed (via gerrit-bot)
Igor Lvovsky
ilvovsky at redhat.com
Thu Jul 7 16:06:48 UTC 2011
New patch submitted by Igor Lvovsky (ilvovsky at redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/665
commit 03c28923ea2866df84db866c90efd8a0768bdcba
Author: Igor Lvovsky <ilvovsky at 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..b0d5d21 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:
+ 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):
More information about the vdsm-patches
mailing list