Adam Litke has uploaded a new change for review.
Change subject: storage: Add garbage indicator to BlockSDVol namedtuple
......................................................................
storage: Add garbage indicator to BlockSDVol namedtuple
Change-Id: I3e71b3d0ff7c76b815f84d895cd0cbddff251791
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/blockSD.py
1 file changed, 27 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/44568/1
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 8d571a6..77e162b 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -60,7 +60,7 @@
SPECIAL_LVS = (sd.METADATA, sd.LEASES, sd.IDS, sd.INBOX, sd.OUTBOX, MASTERLV)
MASTERLV_SIZE = "1024" # In MiB = 2 ** 20 = 1024 ** 2 => 1GiB
-BlockSDVol = namedtuple("BlockSDVol", "name, image, parent")
+BlockSDVol = namedtuple("BlockSDVol", "name, image, parent,
garbage_meta_id")
log = logging.getLogger("Storage.BlockSD")
@@ -144,6 +144,24 @@
return f.tell()
+def _get_garbage_vol_meta_id(sdUUID, volUUID, tags):
+ """
+ If the LV contains TAG_VOL_GARBAGE then treat this volume as garbage. In
+ order to garbage collect the LV metadata associated with this volume we
+ need the metadata ID. We cannot call getMetadataId when the LV contains
+ TAG_VOL_UNINIT so we handle this case specially.
+ """
+ if blockVolume.TAG_VOL_GARBAGE not in tags:
+ return None
+ for tag in tags:
+ if tag.startswith(blockVolume.TAG_PREFIX_MD):
+ meta_offset = tag[len(blockVolume.TAG_PREFIX_MD):]
+ return sdUUID, meta_offset
+ log.error("missing offset tag on volume %s/%s", sdUUID, volUUID)
+ raise se.VolumeMetadataReadError("missing offset tag on volume %s/%s" %
+ (sdUUID, volUUID))
+
+
def _getVolsTree(sdUUID):
lvs = lvm.getLV(sdUUID)
vols = {}
@@ -156,7 +174,8 @@
elif tag.startswith(blockVolume.TAG_PREFIX_PARENT):
parent = tag[len(blockVolume.TAG_PREFIX_PARENT):]
if parent and image:
- vols[lv.name] = BlockSDVol(lv.name, image, parent)
+ gc_meta_id = _get_garbage_vol_meta_id(sdUUID, lv.name, lv.tags)
+ vols[lv.name] = BlockSDVol(lv.name, image, parent, gc_meta_id)
break
else:
if lv.name not in SPECIAL_LVS:
@@ -175,6 +194,12 @@
Template self image is the 1st term in template volume entry images.
"""
vols = _getVolsTree(sdUUID)
+
+ # Remove volumes awaiting garbage collection from the result
+ for vol_id in vols.iterkeys():
+ if vols[vol_id].garbage_meta_id is not None:
+ del vols[vol_id]
+
res = {}
for volName in vols.iterkeys():
res[volName] = {'imgs': [], 'parent': None}
--
To view, visit
https://gerrit.ovirt.org/44568
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e71b3d0ff7c76b815f84d895cd0cbddff251791
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>