[master 1/1] Use the RAID classes to calculate btrfs sizes (#1264696)
dashea
installerbot-noreply at redhat.com
Tue Sep 22 18:57:52 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. Default to a raid level of "single"
instead of None for consistency.
---
blivet/devices/btrfs.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index bfd51da..d79bd7b 100644
--- a/blivet/devices/btrfs.py
+++ b/blivet/devices/btrfs.py
@@ -177,7 +177,7 @@ def __init__(self, *args, **kwargs):
"""
# pop these arguments before the constructor call to avoid
# unrecognized keyword error in superclass constructor
- dataLevel = kwargs.pop("dataLevel", None)
+ dataLevel = kwargs.pop("dataLevel", raid.Single)
metaDataLevel = kwargs.pop("metaDataLevel", None)
createOptions = kwargs.pop("createOptions", None)
@@ -230,7 +230,7 @@ def _setLevel(self, value, data):
:raises :class:`~.errors.BTRFSValueError`: if value represents
an invalid level.
"""
- level = None
+ level = raid.Single
if value:
levels = btrfs.RAID_levels if data else btrfs.metadata_levels
try:
@@ -303,11 +303,10 @@ 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
+ return self.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/4072522a27c33e6336813910431248ba8a01b153
More information about the anaconda-patches
mailing list