Skip to content

Commit

Permalink
blockVolume: check parent tag and meta match
Browse files Browse the repository at this point in the history
blockVolume getParent method uses the volume tag
PU_<id> to obtain the parent. However, this tag
could be outdated. For example, when the host
syncs a volume chain after removing a volume,
it only updates the metadata. Afterwards,
the SPM will update the volume tag once the
volume is deleted.

To ensure we do not return outdated parent UUID,
we need to ensure that the parent UUID obtained
from the parent tag, and the UUID in the volume
metadata match. If they do not, we try to reload
the volume tag first. If they still do not match
after that, log a warning and use the metadata parent.

Bug-Url: https://bugzilla.redhat.com/2103582
Signed-off-by: Albert Esteve <aesteve@redhat.com>
  • Loading branch information
aesteve-rh committed Jul 25, 2022
1 parent 62544a7 commit 76a8111
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 15 additions & 1 deletion lib/vdsm/storage/blockVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,21 @@ def getParent(self):
"""
Return parent volume UUID
"""
return self.getParentTag()
parent_tag = self.getParentTag()
parent_meta = self.getParentMeta()
if parent_tag != parent_meta:
self.log.debug(
"Getting different PUUID LV from tag %s and metada %s for "
"volume %s, reloading volume tags",
parent_tag, parent_meta, self.volUUID)
lvm.invalidateVG(self.sdUUID)
parent_tag = self.getParentTag()
if parent_tag != parent_meta:
self.log.warning(
"Getting volume %s PUUID: volume tag %s does not "
"match metadata parent %s",
self.volUUID, parent_tag, parent_meta)
return parent_meta

def getChildren(self):
""" Return children volume UUIDs.
Expand Down
7 changes: 5 additions & 2 deletions tests/storage/blocksd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1872,9 +1872,12 @@ def test_sync_volume_chain_internal(
# from the volume metadata.
assert chain.top.getParentMeta() == chain.base.volUUID

# getParent() uses the lv tags, so it still returns the internal volume.
# Parent tag is still pointing to the internal volume.
# This will be fixed later on the SPM when the internal volume is deleted.
assert chain.top.getParent() == chain.internal.volUUID
assert chain.top.getParentTag() == chain.internal.volUUID

# getParent() uses the metadata parent.
assert chain.top.getParent() == chain.base.volUUID


@requires_root
Expand Down

0 comments on commit 76a8111

Please sign in to comment.