示例#1
0
def deactivateVdi(sr_uuid, vdi_uuid, vhd_path):
    name_space = lvhdutil.NS_PREFIX_LVM + sr_uuid
    lock = Lock(vdi_uuid, name_space)
    lock.acquire()
    try:
        count = RefCounter.put(vdi_uuid, False, name_space)
        if count > 0:
            return
        try:
            lvutil.deactivateNoRefcount(vhd_path)
        except Exception as e:
            util.SMlog("  lv de-activate failed for %s with error %s" %
                       (vhd_path, str(e)))
            RefCounter.get(vdi_uuid, False, name_space)
    finally:
        lock.release()
示例#2
0
def deactivateVdi(sr_uuid, vdi_uuid, vhd_path):
    name_space = lvhdutil.NS_PREFIX_LVM + sr_uuid
    lock = Lock(vdi_uuid, name_space)
    lock.acquire()
    try:
        count = RefCounter.put(vdi_uuid, False, name_space)
        if count > 0:
            return
        try:
            lvutil.deactivateNoRefcount(vhd_path)
        except Exception, e:
            util.SMlog("  lv de-activate failed for %s with error %s" %
                       (vhd_path, str(e)))
            RefCounter.get(vdi_uuid, False, name_space)
    finally:
        lock.release()
示例#3
0
文件: lvmcache.py 项目: xcp-ng/sm
 def deactivate(self, ns, ref, lvName, binary):
     lock = Lock(ref, ns)
     lock.acquire()
     try:
         count = RefCounter.put(ref, binary, ns)
         if count > 0:
             return
         refreshed = False
         while True:
             lvInfo = self.getLVInfo(lvName)
             if len(lvInfo) != 1:
                 raise util.SMException("LV info not found for %s" % ref)
             info = lvInfo[lvName]
             if info.open:
                 if refreshed:
                     # should never happen in normal conditions but in some
                     # failure cases the recovery code may not be able to
                     # determine what the correct refcount should be, so it
                     # is not unthinkable that the value might be out of
                     # sync
                     util.SMlog("WARNING: deactivate: LV %s open" % lvName)
                     return
                 # check again in case the cached value is stale
                 self.refresh()
                 refreshed = True
             else:
                 break
         try:
             self.deactivateNoRefcount(lvName)
         except util.CommandException:
             self.refresh()
             if self.getLVInfo(lvName):
                 util.SMlog("LV %s could not be deactivated" % lvName)
                 if lvInfo[lvName].active:
                     util.SMlog("Reverting the refcount change")
                     RefCounter.get(ref, binary, ns)
                 raise
             else:
                 util.SMlog("LV %s not found" % lvName)
     finally:
         lock.release()
示例#4
0
文件: lvmcache.py 项目: BobBall/sm
 def deactivate(self, ns, ref, lvName, binary):
     lock = Lock(ref, ns)
     lock.acquire()
     try:
         count = RefCounter.put(ref, binary, ns)
         if count > 0:
             return
         refreshed = False
         while True:
             lvInfo = self.getLVInfo(lvName)
             if len(lvInfo) != 1:
                 raise util.SMException("LV info not found for %s" % ref)
             info = lvInfo[lvName]
             if info.open:
                 if refreshed:
                     # should never happen in normal conditions but in some 
                     # failure cases the recovery code may not be able to 
                     # determine what the correct refcount should be, so it 
                     # is not unthinkable that the value might be out of 
                     # sync
                     util.SMlog("WARNING: deactivate: LV %s open" % lvName)
                     return
                 # check again in case the cached value is stale
                 self.refresh()
                 refreshed = True
             else:
                 break
         try:
             self.deactivateNoRefcount(lvName)
         except util.CommandException:
             self.refresh()
             if self.getLVInfo(lvName):
                 util.SMlog("LV %s could not be deactivated" % lvName)
                 if lvInfo[lvName].active:
                     util.SMlog("Reverting the refcount change")
                     RefCounter.get(ref, binary, ns)
                 raise
             else:
                 util.SMlog("LV %s not found" % lvName)
     finally:
         lock.release()
示例#5
0
文件: lvmcache.py 项目: xcp-ng/sm
 def activate(self, ns, ref, lvName, binary):
     lock = Lock(ref, ns)
     lock.acquire()
     try:
         count = RefCounter.get(ref, binary, ns)
         if count == 1:
             try:
                 self.activateNoRefcount(lvName)
             except util.CommandException:
                 RefCounter.put(ref, binary, ns)
                 raise
     finally:
         lock.release()
示例#6
0
文件: lvmcache.py 项目: BobBall/sm
 def activate(self, ns, ref, lvName, binary):
     lock = Lock(ref, ns)
     lock.acquire()
     try:
         count = RefCounter.get(ref, binary, ns)
         if count == 1:
             try:
                 self.activateNoRefcount(lvName)
             except util.CommandException:
                 RefCounter.put(ref, binary, ns)
                 raise
     finally:
         lock.release()