Eduardo has uploaded a new change for review.

Change subject: Marking del/zero volumes in blockSD class.
......................................................................

Marking del/zero volumes in blockSD class.

Related to: BZ#905938, BZ#910013, BZ#875708

Change-Id: I747bc2218e0b2cc256dd352ad890143c7d354bd8
Signed-off-by: Eduardo <[email protected]>
---
M vdsm/storage/blockSD.py
M vdsm/storage/sd.py
2 files changed, 24 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/45/12545/1

diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 9809bf4..35282e5 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -210,17 +210,6 @@
     # spent time.
     ZEROING_TIMEOUT = 60000  # [miliseconds]
     log.debug("sd: %s, LVs: %s, img: %s", sdUUID, volUUIDs, imgUUID)
-    # Prepare for zeroing
-    try:
-        lvm.changelv(sdUUID, volUUIDs, (("-a", "y"),
-                    ("--deltag", blockVolume.TAG_PREFIX_IMAGE + imgUUID),
-                    ("--addtag", blockVolume.TAG_PREFIX_IMAGE +
-                     sd.REMOVED_IMAGE_PREFIX + imgUUID)))
-    except se.StorageException as e:
-        log.error("Can't activate or change LV tags in SD %s. "
-                  "failing Image %s pre zeroing operation for vols: %s. %s",
-                  sdUUID, imgUUID, volUUIDs, e)
-        raise
     # Following call to changelv is separate since setting rw permission on an
     # LV fails if the LV is already set to the same value, hence we would not
     # be able to differentiate between a real failure of deltag/addtag and one
@@ -981,13 +970,36 @@
                           if v.imgs[0] == imgUUID)
         return exclusives
 
+    def __markForDelVols(self, sdUUID, imgUUID, volUUIDs, opTag):
+        """
+        Mark volumes that will be zeroed or removed.
+
+        Mark for delete just in case that lvremove [lvs] success partialy.
+        Mark for zero just in case that zero process is interrupted.
+
+        Tagging is preferably than rename since is can be done in one lvm
+        operation and is resilent to open LV's, etc.
+        """
+        try:
+            lvm.changelv(sdUUID, volUUIDs, (("-a", "y"),
+                        ("--deltag", blockVolume.TAG_PREFIX_IMAGE + imgUUID),
+                        ("--addtag", blockVolume.TAG_PREFIX_IMAGE +
+                         opTag + imgUUID)))
+        except se.StorageException as e:
+            log.error("Can't activate or change LV tags in SD %s. "
+                      "failing Image %s %s operation for vols: %s. %s",
+                      sdUUID, imgUUID, opTag, volUUIDs, e)
+            raise
+
     def deleteImage(self, sdUUID, imgUUID, volsImgs):
         toDel = self._getImgExclusiveVols(imgUUID, volsImgs)
+        self.__markForDelVols(sdUUID, imgUUID, toDel, sd.REMOVED_IMAGE_PREFIX)
         deleteVolumes(sdUUID, toDel)
         self.rmDCImgDir(imgUUID, volsImgs)
 
     def zeroImage(self, sdUUID, imgUUID, volsImgs):
         toZero = self._getImgExclusiveVols(imgUUID, volsImgs)
+        self.__markForDelVols(sdUUID, imgUUID, toZero, sd.ZEROED_IMAGE_PREFIX)
         zeroImgVolumes(sdUUID, imgUUID, toZero)
         self.rmDCImgDir(imgUUID, volsImgs)
 
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 9ce836b..cc06ce5 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -135,6 +135,7 @@
 ISO_IMAGE_UUID = '11111111-1111-1111-1111-111111111111'
 BLANK_UUID = '00000000-0000-0000-0000-000000000000'
 REMOVED_IMAGE_PREFIX = "_remove_me_"
+ZEROED_IMAGE_PREFIX = REMOVED_IMAGE_PREFIX + "ZERO_"
 
 # Blocks used for each lease (valid on all domain types)
 LEASE_BLOCKS = 2048


--
To view, visit http://gerrit.ovirt.org/12545
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I747bc2218e0b2cc256dd352ad890143c7d354bd8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to