From f87548b5b229d6b856da5f979e35f285eb3284e9 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 13 Jan 2009 15:20:00 +0000
Subject: [PATCH] bdev: Do not call Assemble() on children

The caller of dev.Assemble() (backend._RecursiveAssembleBD) is doing an
explicit recursion over all the children of the device, with better
error reporting. As such, we don't need this repeated assembly inside
the base BlockDev class.

Reviewed-by: ultrotter
---
 lib/bdev.py | 36 ++++++++----------------------------
 1 file changed, 8 insertions(+), 28 deletions(-)

diff --git a/lib/bdev.py b/lib/bdev.py
index d609f1025..559d44199 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -87,36 +87,16 @@ class BlockDev(object):
   def Assemble(self):
     """Assemble the device from its components.
 
-    If this is a plain block device (e.g. LVM) than assemble does
-    nothing, as the LVM has no children and we don't put logical
-    volumes offline.
-
-    One guarantee is that after the device has been assembled, it
-    knows its major/minor numbers. This allows other devices (usually
-    parents) to probe correctly for their children.
+    Implementations of this method by child classes must ensure that:
+      - after the device has been assembled, it knows its major/minor
+        numbers; this allows other devices (usually parents) to probe
+        correctly for their children
+      - calling this method on an existing, in-use device is safe
+      - if the device is already configured (and in an OK state),
+        this method is idempotent
 
     """
-    status = True
-    for child in self._children:
-      if not isinstance(child, BlockDev):
-        raise TypeError("Invalid child passed of type '%s'" % type(child))
-      if not status:
-        break
-      status = status and child.Assemble()
-      if not status:
-        break
-
-      try:
-        child.Open()
-      except errors.BlockDeviceError:
-        for child in self._children:
-          child.Shutdown()
-        raise
-
-    if not status:
-      for child in self._children:
-        child.Shutdown()
-    return status
+    return True
 
   def Attach(self):
     """Find a device which matches our config and attach to it.
-- 
GitLab