[PATCH 2/6] Cache MD metadata while populating the devicetree.

David Lehman dlehman at redhat.com
Thu Jul 31 23:22:30 UTC 2014


Since we cannot inject data into pyudev's Device entries we have to store
the metadata for use from various places unless we want to call mdexamine
multiple times per device.
---
 blivet/devicetree.py | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 755f782..d6f0e25 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -134,7 +134,7 @@ class DeviceTree(object):
         self.unusedRaidMembers = []
 
         # initialize attributes that may later hold cached lvm info
-        self.dropLVMCache()
+        self.dropCache()
 
         self.__passphrases = []
         if passphrase:
@@ -188,6 +188,20 @@ class DeviceTree(object):
         self._pvInfo = None # pylint: disable=attribute-defined-outside-init
         self._lvInfo = None # pylint: disable=attribute-defined-outside-init
 
+    @property
+    def mdInfo(self):
+        if self._mdInfo is None:
+            self._mdInfo = {}
+
+        return self._mdInfo
+
+    def dropMDCache(self):
+        self._mdInfo = None # pylint: disable=attribute-defined-outside-init
+
+    def dropCache(self):
+        self.dropLVMCache()
+        self.dropMDCache()
+
     def pruneActions(self):
         """ Remove redundant/obsolete actions from the action list. """
         for action in reversed(self._actions[:]):
@@ -1808,11 +1822,12 @@ class DeviceTree(object):
             # luks/dmcrypt
             kwargs["name"] = "luks-%s" % uuid
         elif format_type in formats.mdraid.MDRaidMember._udevTypes:
-            info.update(mdraid.mdexamine(device.path))
+            md_info = mdraid.mdexamine(device.path)
+            self.mdInfo[device.path] = md_info
 
             # mdraid
             try:
-                kwargs["mdUuid"] = udev.device_get_md_uuid(info)
+                kwargs["mdUuid"] = udev.device_get_md_uuid(md_info)
             except KeyError:
                 log.warning("mdraid member %s has no md uuid", name)
 
@@ -2108,7 +2123,7 @@ class DeviceTree(object):
         # this has proven useful when populating after opening a LUKS device
         udev.settle()
 
-        self.dropLVMCache()
+        self.dropCache()
 
         if flags.installer_mode and not flags.image_install:
             mpath.set_friendly_names(enabled=flags.multipath_friendly_names)
-- 
1.9.3



More information about the anaconda-patches mailing list