[PATCH] Fix size calculation for MD arrays.

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

 



---
 storage/devices.py |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index d0b00b8..79a4bd5 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -2060,11 +2060,32 @@ class MDRaidArrayDevice(StorageDevice):
                                                 % (self.path, self.uuid))
 
     @property
+    def smallestMember(self):
+        try:
+            smallest = sorted(self.devices, key=lambda d: d.size)[0]
+        except IndexError:
+            smallest = None
+        return smallest
+
+    @property
     def size(self):
-        size = None
-        for device in self.devices:
-            if size is None or device.size < size:
-                size = device.size
+        if not self.devices:
+            return 0
+
+        size = 0
+        if not self.exists or not self.partedDevice:
+            if self.level == 0:
+                size = self.memberDevices * self.smallestMember.size
+            elif self.level == 1:
+                size = self.smallestMember.size
+            elif self.level == 5:
+                size = (self.memberDevices - 1) * self.smallestMember.size
+            elif self.level == 6:
+                size = (self.memberDevices - 2) * self.smallestMember.size
+            elif self.level == 10:
+               size = (self.memberDevices / 2.0) * self.smallestMember.size
+        else:
+            size = super(MDRaidArrayDevice, self).size
 
         return size
 
-- 
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