Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free_space_estimate: adjust for compression on btrfs #1301

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion blivet/formats/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ def dict(self):
"mountable": self.mountable})
return d

@classmethod
def _compression_size_factor(cls):
""" Adjust free space estimate for transparent compression.
Classes for filesystems that implement transparent compression
can override this.
"""
return 1

@classmethod
def free_space_estimate(cls, device_size):
""" Get estimated free space when format will be done on device
Expand All @@ -207,7 +215,7 @@ def free_space_estimate(cls, device_size):
:return: estimated free size after format
:rtype: :class:`~.size.Size`
"""
return device_size * cls._metadata_size_factor
return device_size * cls._metadata_size_factor * cls._compression_size_factor()

@classmethod
def get_required_size(cls, free_space):
Expand Down Expand Up @@ -1108,6 +1116,16 @@ def _pre_process_subvolnames(subvols):
return False
return True

@classmethod
def _compression_size_factor(cls):
""" Adjust free space estimate for transparent compression.
We estimate 40% 'additional space' if it's enabled (this is
pretty conservative).
"""
if flags.btrfs_compression:
return 1.40
return 1


register_device_format(BTRFS)

Expand Down