[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Meke dmraid devices recursive



For raid{10,01} to properly work pyblock needs to activate and
deactivate the dmraid sets properly.  When activating it should activate
the leafs of the tree first.  On deactivation it should start with the
root.

device.py - Added an activeMembers attribute that will hold the members
            children that are activated by the activate function.  On
            acitvation the children get activated first.  On
            deactivation the father goes first and then the children.
            This only applies for RaidSet objects.
---
 device.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/device.py b/device.py
index df08edc..828f198 100644
--- a/device.py
+++ b/device.py
@@ -572,6 +572,7 @@ class RaidSet:
         self._RaidSet__map = None
         self._RaidSet__parts = []
         self._RaidSet__name = rs.name
+        self._RaidSet__activeMembers = []
         self.active = False
         self.mknod = False
 
@@ -796,6 +797,13 @@ class RaidSet:
     def activate(self, degradedOk=False, mknod=False):
         if self.active:
             return
+
+        # We put the active members in a list so we can deactivate them later.
+        for member in self.members:
+            if isinstance(member, RaidSet):
+                member.activate(degradedOk=degradedOk, mknod=mknod)
+                self._RaidSet__activeMembers.append(member)
+
         if mknod:
             try:
                 _os.unlink(self.prefix+self.name)
@@ -826,6 +834,11 @@ class RaidSet:
             self.active = False
         elif len(parts) > 0:
             raise RuntimeError, "raidset has active partitions"
+
+        for activeMember in self._RaidSet__activeMembers:
+            activeMember.deactivate()
+        self._RaidSet__activateMembers = []
+
         self.scanMemberParts()
 
     def display(self, space=0, printer=lambda x,y: _sys.stdout.write("%s%s\n" % (x*' ',y))):
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]