From 3ead8d9c6d06e275c3193a6042d05143831057dc Mon Sep 17 00:00:00 2001 From: Mark Syms Date: Mon, 5 Feb 2024 10:46:40 +0000 Subject: [PATCH] CA-385069: Remove unnecessary LvmContext wrap This was resulting in a deadlock condition being detected and is no longer required after the chnages for CP-39600 in 125aa9e. Signed-off-by: Mark Syms --- drivers/LVHDSR.py | 84 +++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/drivers/LVHDSR.py b/drivers/LVHDSR.py index 847e138cf..21441e365 100755 --- a/drivers/LVHDSR.py +++ b/drivers/LVHDSR.py @@ -1762,51 +1762,49 @@ def _snapshot(self, snapType, cloneOp=False, cbtlog=None, cbt_consistency=None): util.fistpoint.activate("LVHDRT_clone_vdi_after_create_journal", self.sr.uuid) try: - with lvutil.LvmLockContext(): - # self becomes the "base vdi" - origOldLV = self.lvname - baseLV = lvhdutil.LV_PREFIX[self.vdi_type] + baseUuid - self.sr.lvmCache.rename(self.lvname, baseLV) - self.sr.lvActivator.replace(self.uuid, baseUuid, baseLV, False) - RefCounter.set(baseUuid, 1, 0, lvhdutil.NS_PREFIX_LVM + self.sr.uuid) - self.uuid = baseUuid - self.lvname = baseLV - self.path = os.path.join(self.sr.path, baseLV) - self.label = "base copy" - self.read_only = True - self.location = self.uuid - self.managed = False - - # shrink the base copy to the minimum - we do it before creating - # the snapshot volumes to avoid requiring double the space - if self.vdi_type == vhdutil.VDI_TYPE_VHD: - lvhdutil.deflate(self.sr.lvmCache, self.lvname, lvSizeBase) - self.utilisation = lvSizeBase - util.fistpoint.activate("LVHDRT_clone_vdi_after_shrink_parent", self.sr.uuid) - - snapVDI = self._createSnap(origUuid, lvSizeOrig, False) - util.fistpoint.activate("LVHDRT_clone_vdi_after_first_snap", self.sr.uuid) - snapVDI2 = None - if snapType == VDI.SNAPSHOT_DOUBLE: - snapVDI2 = self._createSnap(clonUuid, lvSizeClon, True) - # If we have CBT enabled on the VDI, - # set CBT status for the new snapshot disk - if cbtlog: - snapVDI2.cbt_enabled = True - util.fistpoint.activate("LVHDRT_clone_vdi_after_second_snap", self.sr.uuid) - - # note: it is important to mark the parent hidden only AFTER the - # new VHD children have been created, which are referencing it; - # otherwise we would introduce a race with GC that could reclaim - # the parent before we snapshot it - if self.vdi_type == vhdutil.VDI_TYPE_RAW: - self.sr.lvmCache.setHidden(self.lvname) - else: - vhdutil.setHidden(self.path) - util.fistpoint.activate("LVHDRT_clone_vdi_after_parent_hidden", self.sr.uuid) + # self becomes the "base vdi" + origOldLV = self.lvname + baseLV = lvhdutil.LV_PREFIX[self.vdi_type] + baseUuid + self.sr.lvmCache.rename(self.lvname, baseLV) + self.sr.lvActivator.replace(self.uuid, baseUuid, baseLV, False) + RefCounter.set(baseUuid, 1, 0, lvhdutil.NS_PREFIX_LVM + self.sr.uuid) + self.uuid = baseUuid + self.lvname = baseLV + self.path = os.path.join(self.sr.path, baseLV) + self.label = "base copy" + self.read_only = True + self.location = self.uuid + self.managed = False + + # shrink the base copy to the minimum - we do it before creating + # the snapshot volumes to avoid requiring double the space + if self.vdi_type == vhdutil.VDI_TYPE_VHD: + lvhdutil.deflate(self.sr.lvmCache, self.lvname, lvSizeBase) + self.utilisation = lvSizeBase + util.fistpoint.activate("LVHDRT_clone_vdi_after_shrink_parent", self.sr.uuid) + + snapVDI = self._createSnap(origUuid, lvSizeOrig, False) + util.fistpoint.activate("LVHDRT_clone_vdi_after_first_snap", self.sr.uuid) + snapVDI2 = None + if snapType == VDI.SNAPSHOT_DOUBLE: + snapVDI2 = self._createSnap(clonUuid, lvSizeClon, True) + # If we have CBT enabled on the VDI, + # set CBT status for the new snapshot disk + if cbtlog: + snapVDI2.cbt_enabled = True + util.fistpoint.activate("LVHDRT_clone_vdi_after_second_snap", self.sr.uuid) + + # note: it is important to mark the parent hidden only AFTER the + # new VHD children have been created, which are referencing it; + # otherwise we would introduce a race with GC that could reclaim + # the parent before we snapshot it + if self.vdi_type == vhdutil.VDI_TYPE_RAW: + self.sr.lvmCache.setHidden(self.lvname) + else: + vhdutil.setHidden(self.path) + util.fistpoint.activate("LVHDRT_clone_vdi_after_parent_hidden", self.sr.uuid) # set the base copy to ReadOnly - # Do this outside the LvmLockContext to avoid deadlock self.sr.lvmCache.setReadonly(self.lvname, True) util.fistpoint.activate("LVHDRT_clone_vdi_after_parent_ro", self.sr.uuid)