Hello Federico Simoncelli, Allon Mureinik,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/30944
to review the following change.
Change subject: image: Detect cycles in image volume chain
......................................................................
image: Detect cycles in image volume chain
When sorting volume chains, we could get into an endless loop if there
was a cycle in the volume chain, for example, a volume claiming to be
its own parent. The endless loop create a new volume object on each
iteration, and adds it to the chain list, and will stop only when no
more memory is available or vdsm is stopped.
Now ImageIsNotLegalChain is raised as soon as a cycle is detected.
Change-Id: I687335f17bc7810071ba3523cba8ad980e7d5bdb
Bug-Url: https://bugzilla.redhat.com/1125197
Relates-To: https://bugzilla.redhat.com/1124498
Signed-off-by: Nir Soffer <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/30867
Reviewed-by: Allon Mureinik <[email protected]>
Reviewed-by: Federico Simoncelli <[email protected]>
---
M vdsm/storage/image.py
1 file changed, 12 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/44/30944/1
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 14abb79..37ee135 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -201,13 +201,24 @@
self.log.error("There is no leaf in the image %s", imgUUID)
raise se.ImageIsNotLegalChain(imgUUID)
+ # We have seen corrupted chains that cause endless loops here.
+ # https://bugzilla.redhat.com/1125197
+ seen = set()
+
# Build up the sorted parent -> child chain
while not srcVol.isShared():
chain.insert(0, srcVol)
+ seen.add(srcVol.volUUID)
- if srcVol.getParent() == volume.BLANK_UUID:
+ parentUUID = srcVol.getParent()
+ if parentUUID == volume.BLANK_UUID:
break
+ if parentUUID in seen:
+ self.log.error("Image %s volume %s has invalid parent UUID %s",
+ imgUUID, srcVol.volUUID, parentUUID)
+ raise se.ImageIsNotLegalChain(imgUUID)
+
srcVol = srcVol.getParentVolume()
self.log.info("sdUUID=%s imgUUID=%s chain=%s ", sdUUID, imgUUID, chain)
--
To view, visit http://gerrit.ovirt.org/30944
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I687335f17bc7810071ba3523cba8ad980e7d5bdb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Nir Soffer <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches