Re: [PATCH 6/6] Improve estimate of md arrays' size.

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

 



Looks good

On 04/14/2009 01:16 PM, David Lehman wrote:
---
  storage/devices.py |   37 +++++++++++++++++++++++++++++++++----
  1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 89595d7..e51ae05 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -2070,6 +2070,9 @@ class MDRaidArrayDevice(StorageDevice):
          self._totalDevices = numeric_type(totalDevices)
          self._memberDevices = numeric_type(memberDevices)
          self.sysfsPath = "/devices/virtual/block/%s" % name
+        self.chunkSize = 64.0 / 1024.0          # chunk size in MB
+        self.superBlockSize = 128.0 / 1024.0    # superblock size in MB
+

          # FIXME: Bitmap is more complicated than this.
          # It can be internal or external. External requires a filename.
@@ -2086,11 +2089,37 @@ 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
+        smallestMemberSize = self.smallestMember.size - self.superBlockSize
+        if not self.exists or not self.partedDevice:
+            if self.level == 0:
+                size = self.memberDevices * smallestMemberSize
+                size -= size % self.chunkSize
+            elif self.level == 1:
+                size = smallestMemberSize
+            elif self.level == 5:
+                size = (self.memberDevices - 1) * smallestMemberSize
+                size -= size % self.chunkSize
+            elif self.level == 6:
+                size = (self.memberDevices - 2) * smallestMemberSize
+                size -= size % self.chunkSize
+            elif self.level == 10:
+                size = (self.memberDevices / 2.0) * smallestMemberSize
+                size -= size % self.chunkSize
+        else:
+            size = self.partedDevice.getSize()

          return size



--
David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

_______________________________________________
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