[PATCH 2/2] Handle incomplete md arrays.

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

 



---
 storage/devicetree.py |   68 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/storage/devicetree.py b/storage/devicetree.py
index 996e702..74cd112 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -165,6 +165,29 @@ def questionReinitILVM(intf=None, pv_names=None, lv_name=None, vg_name=None):
 
     return retVal
 
+def questionReinitAllMDMembers(intf=None, mdpath=None, member_names=None):
+    retVal = False # The less destructive default
+    if intf == None or member_names == None or mdpath == None:
+        pass
+    else:
+        rc = intf.messageWindow(_("Warning"),
+                _("Error processing mdraid array.\n"
+                  "The mdarray located at %s is missing one or more of its "
+                  "member devices.  The following devices where detected: %s . "
+                  "You can reinitialize all the related devices (this will "
+                  "cause loss of any data contained in them) or ignore them "
+                  "which will preserve their contents." % (mdpath, member_names)),
+                type="custom",
+                custom_buttons = [ _("_Ignore"),
+                                   _("Re-initialize") ],
+                custom_icon="question")
+        if rc == 0:
+            pass
+        else:
+            retVal = True
+
+    return retVal
+
 class DeviceTree(object):
     """ A quasi-tree that represents the devices in the system.
 
@@ -1579,6 +1602,51 @@ class DeviceTree(object):
                         lvm.lvm_cc_addFilterRejectRegexp(parent.name)
                 return
 
+            elif device.type == "mdarray":
+                # Handle the case where we find an md device that has the
+                # wrong amount of parents.  This happnes when something
+                # prevents the correct detection of all the member devs.
+                if device.memberDevices != len(device.parents):
+                    memNames = []
+                    for parent in device.parents:
+                        memNames.append(parent.path)
+
+                    if self.zeroMbr or questionReinitAllMDMembers(intf=self.intf,
+                            member_names=memNames, mdpath=device.path):
+                        #  We destroy the md# device and we give new formats to all
+                        # its parents.  Making sure we destroy each parents format.
+
+                        # We cant use the device object as it is not sane.
+                        try:
+                            mdraid.mddeactivate(device.path)
+                        except:
+                            log.error("Could not deactivate %s" % device.path)
+
+                        if device.format is not None:
+                            device.format.destroy()
+
+                        # Give each parent a new format.
+                        for parent in device.parents:
+                            parent.format.destroy()
+                            kwargs = {"uuid": parent.uuid,
+                                      "label": parent.diskLabel,
+                                      "device": parent.path,
+                                      "exists": parent.exists}
+                            parent.format = formats.getFormat(*[""], **kwargs)
+
+                    else:
+                        for parent in device.parents:
+                            if parent.type == "partition":
+                                # add to Protected partitions.
+                                self.immutableDevices.append([parent.name,
+                                    _("This partition is part of an inconsistent md device.")])
+                            else:
+                                self._removeDevice(parent, moddisk=False)
+
+                    # Finally we make sure that the md device is "erased"
+                    self._removeDevice(device, moddisk=False)
+                return
+
         # Address the inconsistencies present in the tree leaves.
         for leaf in self.leaves:
             leafInconsistencies(leaf)
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux