disk_space: Support btrfs backend #2159
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Btrfs is too smart for the statvfs based backend (i.e., only counting blocks leads to wrong numbers).
For example, a btrfs disk with a lot of de-duplicated blocks (via the copy on write mechanism) might have a drastically over-reported disk usage.
The btrfs backend is currently implemented by parsing the output of the
btrfs filesystem usage --raw
command. This is suboptimal, as this now relies on the command output not changing.Vendoring the algorithm used internally by the
btrfs
command does not seem to be a reasonable alternative, considering that the code1 is rather complex, low level and would require semi-constant maintenance. Additionally, the c code would need bindings to be usable from rust.I assume, that the
btrfs
command output will stay rather similar in the future, as a lot of tools rely on directly parsing it (see the various scripts in the issue, this commit fixes).Fixes: #1654