From 433c63aab0342a567f993374c86d73391e67d85d Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 29 Jan 2010 12:37:35 +0100 Subject: [PATCH] Make the snapshot decision based on disk type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit β¦ 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: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/backend.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 306780870..711d7bca9 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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: -- GitLab