[master 1/1] Use the RAID classes to calculate btrfs sizes (#1264696)

dashea installerbot-noreply at redhat.com
Tue Sep 22 19:49:05 UTC 2015


From: David Shea <dshea at redhat.com>

We already have a bunch of a RAID size calculcation code, so use that
for the raid modes of btrfs volumes.
---
 blivet/devices/btrfs.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index bfd51da..63f43a4 100644
--- a/blivet/devices/btrfs.py
+++ b/blivet/devices/btrfs.py
@@ -303,11 +303,11 @@ def _setFormat(self, fmt):
             self.format.mountopts = self.parents[0].format.mountopts
 
     def _getSize(self):
-        size = sum((d.size for d in self.parents), Size(0))
-        if self.dataLevel in (raid.RAID1, raid.RAID10):
-            size /= len(self.parents)
-
-        return size
+        # Calculate the size as if it were a RAID with no superblock and a chunk_size of 1
+        dataLevel = self.dataLevel or raid.Single
+        return dataLevel.get_size([d.size for d in self.parents],
+                chunk_size=Size(1),
+                superblock_size_func=lambda x: 0)
 
     def _removeParent(self, member):
         levels = (l for l in (self.dataLevel, self.metaDataLevel) if l)


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/456900eec2661e41e7299bc3635bef8daa7c113f


More information about the anaconda-patches mailing list