[PATCH 1/4] Determine existing md arrays' metadata version. (#731266)

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

 



This is needed if we are to validate boot arrays' metadata
version.

Also, don't validate metadata version for arrays we have not
yet created, as the metadata munging happens just before we
create the arrays.

(based on cherry pick of 9599b145793f3aa9e151f28c5cd2cda6f8dcd668)
---
 pyanaconda/bootloader.py         |    4 +++-
 pyanaconda/storage/devices.py    |   23 ++++++++++++++++-------
 pyanaconda/storage/devicetree.py |    5 ++++-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 94805fa..0e9286a 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -398,7 +398,9 @@ class BootLoader(object):
                                % (desc, levels_str))
             ret = False
 
-        if metadata and device.metadataVersion not in metadata:
+        # new arrays will be created with an appropriate metadata format
+        if device.exists and \
+           metadata and device.metadataVersion not in metadata:
             self.errors.append(_("RAID sets that contain '%s' must have one "
                                  "of the following metadata versions: %s.")
                                % (desc, ",".join(metadata)))
diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index d3c3bda..cf68b57 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -2652,7 +2652,7 @@ class MDRaidArrayDevice(StorageDevice):
 
     def __init__(self, name, level=None, major=None, minor=None, size=None,
                  memberDevices=None, totalDevices=None,
-                 uuid=None, format=None, exists=None,
+                 uuid=None, format=None, exists=None, metadataVersion=None,
                  parents=None, sysfsPath=''):
         """ Create a MDRaidArrayDevice instance.
 
@@ -2663,6 +2663,7 @@ class MDRaidArrayDevice(StorageDevice):
             Keyword Arguments:
 
                 level -- the device's RAID level (a string, eg: '1' or 'raid1')
+                metadataVersion -- the version of the device's md metadata
                 parents -- list of member devices (StorageDevice instances)
                 size -- the device's size (units/format TBD)
                 uuid -- the device's UUID
@@ -2699,7 +2700,11 @@ class MDRaidArrayDevice(StorageDevice):
         self.chunkSize = 512.0 / 1024.0         # chunk size in MB
         self.superBlockSize = 2.0               # superblock size in MB
 
-        self.createMetadataVer = "default"
+        if not isinstance(metadataVersion, str):
+            self.metadataVersion = "default"
+        else:
+            self.metadataVersion = metadataVersion
+
         # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
         self.createBitmap = self.level != 0
 
@@ -2784,9 +2789,12 @@ class MDRaidArrayDevice(StorageDevice):
         s = StorageDevice.__repr__(self)
         s += ("  level = %(level)s  spares = %(spares)s\n"
               "  members = %(memberDevices)s\n"
-              "  total devices = %(totalDevices)s" %
+              "  total devices = %(totalDevices)s"
+              "  metadata version = %(metadataVersion)s" %
               {"level": self.level, "spares": self.spares,
-               "memberDevices": self.memberDevices, "totalDevices": self.totalDevices})
+               "memberDevices": self.memberDevices,
+               "totalDevices": self.totalDevices,
+               "metadataVersion": self.metadataVersion})
         return s
 
     @property
@@ -2794,7 +2802,8 @@ class MDRaidArrayDevice(StorageDevice):
         d = super(MDRaidArrayDevice, self).dict
         d.update({"level": self.level,
                   "spares": self.spares, "memberDevices": self.memberDevices,
-                  "totalDevices": self.totalDevices})
+                  "totalDevices": self.totalDevices,
+                  "metadataVersion": self.metadataVersion})
         return d
 
     def writeKS(self, f, preexisting=False, noformat=False, s=None):
@@ -3037,7 +3046,7 @@ class MDRaidArrayDevice(StorageDevice):
         if getattr(self.format, "mountpoint", None) == bootmountpoint or \
            getattr(self.format, "mountpoint", None) == "/boot/efi" or \
            self.format.type == "prepboot":
-            self.createMetadataVer = "1.0"
+            self.metadataVersion = "1.0"
 
         # Bitmaps are not useful for swap and small partitions
         if self.size < 1000 or self.format.type == "swap":
@@ -3062,7 +3071,7 @@ class MDRaidArrayDevice(StorageDevice):
                         self.level,
                         disks,
                         spares,
-                        metadataVer=self.createMetadataVer,
+                        metadataVer=self.metadataVersion,
                         bitmap=self.createBitmap,
                         progress=w)
 
diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 743760d..b735ec2 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -1382,9 +1382,11 @@ class DeviceTree(object):
                     minor = udev_device_get_minor(dev)
                     break
 
+            md_info = devicelibs.mdraid.mdexamine(device.path)
+            md_metadata = md_info.get("metadata")
+
             if not md_name:
                 # try to name the array based on the preferred minor
-                md_info = devicelibs.mdraid.mdexamine(device.path)
                 md_path = md_info.get("device", "")
                 md_name = devicePathToName(md_info.get("device", ""))
                 if md_name:
@@ -1422,6 +1424,7 @@ class DeviceTree(object):
                                              minor=minor,
                                              memberDevices=md_devices,
                                              uuid=md_uuid,
+                                             metadataVersion=md_metadata,
                                              sysfsPath=sysfs_path,
                                              exists=True)
             except ValueError as e:
-- 
1.7.3.4

_______________________________________________
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