Commit 433c63aa authored by Iustin Pop's avatar Iustin Pop
Browse files

Make the snapshot decision based on disk type



… instead of disk size, which is not as reliable. This actually
simplifies the code; but it still leaves the possibility of stack
overflows if the disk data structure is corrupted.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 551b6283
......@@ -1926,19 +1926,15 @@ def BlockdevSnapshot(disk):
@return: snapshot disk path
"""
if disk.children:
if len(disk.children) == 1:
# only one child, let's recurse on it
return BlockdevSnapshot(disk.children[0])
else:
# more than one child, choose one that matches
for child in disk.children:
if child.size == disk.size:
# return implies breaking the loop
return BlockdevSnapshot(child)
if disk.dev_type == constants.LD_DRBD8:
if not disk.children:
_Fail("DRBD device '%s' without backing storage cannot be snapshotted",
disk.unique_id)
return BlockdevSnapshot(disk.children[0])
elif disk.dev_type == constants.LD_LV:
r_dev = _RecursiveFindBD(disk)
if r_dev is not None:
# FIXME: choose a saner value for the snapshot size
# let's stay on the safe side and ask for the full size, for now
return r_dev.Snapshot(disk.size)
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment