[PATCH] update mdraid superBlock space calculation (#883483)

Brian C. Lane bcl at redhat.com
Tue Dec 4 17:35:17 UTC 2012


From: "Brian C. Lane" <bcl at redhat.com>

mdadm 3.2.4 made a major change in the amount of space used for 1.1 and
1.2 metadata in order to reserve space for reshaping. See commit
508a7f16 in the upstream mdadm repository.

This has resulted in a large difference between what anaconda thinks the
size of the array should be and what it actually is.

We now use 2.0MB for metadata that isn't 1.1 or 1.2
For 1.1 and 1.2 we calculate the reserved space value and use that.

NOTE: This is the f18 variation of 87640, tested against anaconda 18.34-1
---
 pyanaconda/storage/devices.py | 57 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 6967b30..06baab2 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -2670,7 +2670,6 @@ class MDRaidArrayDevice(StorageDevice):
         self._memberDevices = numeric_type(memberDevices)
 
         self.chunkSize = 512.0 / 1024.0         # chunk size in MB
-        self.superBlockSize = 2.0               # superblock size in MB
 
         if not self.exists and not isinstance(metadataVersion, str):
             self.metadataVersion = "default"
@@ -2699,6 +2698,62 @@ class MDRaidArrayDevice(StorageDevice):
                                                 % (self.path, self.uuid))
 
     @property
+    def rawArraySize(self):
+        """ Calculate the raw array size without taking into account space
+        reserved for metadata or chunkSize alignment.
+
+        This is used to calculate the superBlockSize for v1.1 and v1.2
+        metadata.
+
+        Returns the raw size in MB
+        """
+        smallestMemberSize = self.smallestMember.size
+        if self.level == mdraid.RAID0:
+            size = self.memberDevices * smallestMemberSize
+        elif self.level == mdraid.RAID1:
+            size = smallestMemberSize
+        elif self.level == mdraid.RAID4:
+            size = (self.memberDevices - 1) * smallestMemberSize
+        elif self.level == mdraid.RAID5:
+            size = (self.memberDevices - 1) * smallestMemberSize
+        elif self.level == mdraid.RAID6:
+            size = (self.memberDevices - 2) * smallestMemberSize
+        elif self.level == mdraid.RAID10:
+            size = (self.memberDevices / 2.0) * smallestMemberSize
+        else:
+            size = smallestMemberSize
+            log.error("unknown RAID level %s" % (self.level))
+        log.debug("raw RAID %s size == %s" % (self.level, size))
+        return size
+
+    @property
+    def superBlockSize(self):
+        """ mdadm has different amounts of space reserved for its use depending
+        on the metadata type and size of the array.
+
+        0.9 use 2.0 MB
+        1.0 use 2.0 MB
+        1.1 or 1.2 use the formula lifted from mdadm/super1.c to calculate it
+        based on the array size.
+        """
+        # mdadm 3.2.4 made a major change in the amount of space used for 1.1 and 1.2
+        # in order to reserve space for reshaping. See commit 508a7f16 in the
+        # upstream mdadm repository.
+        if self.metadataVersion not in ["default", "1.1", "1.2"]:
+            headroom = 2.0
+        else:
+            array_size = self.rawArraySize
+            # MDADM: We try to leave 0.1% at the start for reshape
+            # MDADM: operations, but limit this to 128Meg (0.1% of 10Gig)
+            # MDADM: which is plenty for efficient reshapes
+            # NOTE: In the mdadm code this is in 512b sectors. Converted to use MB
+            headroom = 128
+            while headroom << 10 > array_size:
+                headroom >>= 1
+        log.info("Using %sMB superBlockSize" % (headroom))
+        return headroom
+
+    @property
     def smallestMember(self):
         try:
             smallest = sorted(self.devices, key=lambda d: d.size)[0]
-- 
1.8.0



More information about the anaconda-patches mailing list