[PATCH 2/2] Make sure we use 1.0 mdraid metadata when the set is used for boot (#584596)

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

 



---
 storage/devices.py    |   39 ++++++++++++++++++++++++++++-----------
 storage/devicetree.py |    5 +++--
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index a990708..95b0b50 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -2455,6 +2455,10 @@ class MDRaidArrayDevice(StorageDevice):
         self.chunkSize = 64.0 / 1024.0          # chunk size in MB
         self.superBlockSize = 128.0 / 1024.0    # superblock size in MB
 
+        self.createMetadataVer = "1.1"
+        # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
+        self.createBitmap = self.level != 0
+
         # For container members probe size now, as we cannot determine it
         # when teared down.
         if self.parents and self.parents[0].type == "mdcontainer":
@@ -2814,6 +2818,28 @@ class MDRaidArrayDevice(StorageDevice):
         if recursive:
             self.teardownParents(recursive=recursive)
 
+    def preCommitFixup(self, *args, **kwargs):
+        """ Determine create parameters for this set """
+        mountpoints = kwargs.pop("mountpoints")
+        log_method_call(self, self.name, mountpoints)
+
+        if "/boot" in mountpoints:
+            bootmountpoint = "/boot"
+        else:
+            bootmountpoint = "/"
+
+        # If we are used to boot from we cannot use 1.1 metadata
+        if getattr(self.format, "mountpoint", None) == bootmountpoint or \
+           getattr(self.format, "mountpoint", None) == "/boot/efi" or \
+           self.format.type == "prepboot":
+            self.createMetadataVer = "1.0"
+
+        # Bitmaps are not useful for swap and small partitions
+        if getattr(self.format, "mountpoint", None) == "/boot" or \
+           getattr(self.format, "mountpoint", None) == "/boot/efi" or \
+           self.format.type == "swap":
+            self.createBitmap = False
+
     def create(self, intf=None):
         """ Create the device. """
         log_method_call(self, self.name, status=self.status)
@@ -2832,21 +2858,12 @@ class MDRaidArrayDevice(StorageDevice):
 
             disks = [disk.path for disk in self.devices]
             spares = len(self.devices) - self.memberDevices
-            # Figure out format specific options
-            metadata="1.1"
-            # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
-            bitmap = self.level != 0
-            if getattr(self.format, "mountpoint", None) == "/boot":
-                metadata="1.0"
-                bitmap=False
-            elif self.format.type == "swap":
-                bitmap=False
             mdraid.mdcreate(self.path,
                             self.level,
                             disks,
                             spares,
-                            metadataVer=metadata,
-                            bitmap=bitmap,
+                            metadataVer=self.createMetadataVer,
+                            bitmap=self.createBitmap,
                             progress=w)
         except Exception:
             raise
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 0bc07e5..a128f55 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -632,14 +632,15 @@ class DeviceTree(object):
                     device.originalFormat.resetPartedDisk()
 
         # Call preCommitFixup on all devices
+        mpoints = [getattr(d.format, 'mountpoint', "") for d in self.devices]
         for device in self.devices:
-            device.preCommitFixup()
+            device.preCommitFixup(mountpoints=mpoints)
 
         # Also call preCommitFixup on any devices we're going to
         # destroy (these are already removed from the tree)
         for action in self._actions:
             if isinstance(action, ActionDestroyDevice):
-                action.device.preCommitFixup()
+                action.device.preCommitFixup(mountpoints=mpoints)
 
         # setup actions to create any extended partitions we added
         #
-- 
1.7.0.1

_______________________________________________
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