[NEW PATCH] Related to BZ#732416 - Unify criteria for active LV in lvm cache. (via gerrit-bot)

Eduardo Warszawski ewarszaw at redhat.com
Wed Sep 7 20:36:17 UTC 2011


New patch submitted by Eduardo Warszawski (ewarszaw at redhat.com)

You can review this change at: http://gerrit.usersys.redhat.com/873

commit f6626fcb892e617668d4d09759eb6a4ee03f51d3
Author: Eduardo Warszawski <ewarszaw at redhat.com>
Date:   Wed Aug 24 21:38:39 2011 +0300

    Related to BZ#732416 - Unify criteria for active LV in lvm cache.
    
    Change-Id: I91506ed397512e51ba5560fbb617e853668ebc0e

diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 921cf3b..da86a17 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -981,11 +981,10 @@ def createLV(vgName, lvName, size, activate=True, contiguous=False, initialTag=N
 
 def removeLV(vgName, lvName):
     #Assert that the LV is inactive before remove.
-    lv = _lvminfo._lvs.get((vgName, lvName), None)
-    if lv and not isinstance(lv, Stub) and lv.active:
+    if _isLVActive(vgName, lvName):
         #Fix me
         #Should not remove active LVs
-        #raise se.CannotRemoveLogicalVolume(vg, lv)
+        #raise se.CannotRemoveLogicalVolume(vgName, lvName)
         log.warning("Removing active volume %s/%s" % (vgName, lvName))
 
     #LV exists or not in cache, attempting to remove it.
@@ -1036,14 +1035,14 @@ def extendLV(vgName, lvName, size):
 
 def activateLVs(vgName, lvNames):
     lvNames = _normalizeargs(lvNames)
-    toActivate = [lvName for lvName in lvNames if not os.path.exists(lvPath(vgName, lvName))]
+    toActivate = [lvName for lvName in lvNames if not _isLVActive(vgName, lvName)]
     if toActivate:
         _setLVAvailability(vgName, toActivate, "y")
 
 
 def deactivateLVs(vgName, lvNames):
     lvNames = _normalizeargs(lvNames)
-    toDeactivate = [lvName for lvName in lvNames if os.path.exists(lvPath(vgName, lvName))]
+    toDeactivate = [lvName for lvName in lvNames if _isLVActive(vgName, lvName)]
     if toDeactivate:
         _setLVAvailability(vgName, toDeactivate, "n")
 
@@ -1115,6 +1114,14 @@ def lvPath(vgName, lvName):
     return os.path.join("/dev", vgName, lvName)
 
 
+def _isLVActive(vgName, lvName):
+    """Active volumes have a mp link.
+
+    This function should not be used out of this module.
+    """
+    return os.path.exists(lvPath(vgName, lvName))
+
+
 def changeVGTags(vgName, delTags=[], addTags=[]):
     delTags = set(delTags)
     addTags = set(addTags)




More information about the vdsm-patches mailing list