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

Fix Btrfs unallocated space accounting #14824

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Conversation

intelfx
Copy link
Contributor

@intelfx intelfx commented Mar 28, 2023

Summary

Btrfs part of the proc collector assumes that /sys/block/<name>/size is reported in hardware sectors, while it is in fact reported in 512-byte sectors (the basic Linux SECTOR_SIZE/SECTOR_SHIFT). This causes unallocated space to be misaccounted by a factor of hw_sector_size/512. Fix this by hardcoding sector size to 512.

Fixes #14816.

Test Plan

Manually tested on multiple systems with Btrfs volumes mounted (single-disk and multi-disk, with and without LUKS2).

Additional Information
For users: How does this change affect me? This change is related to the Btrfs support in the proc collector plugin ("Btrfs" section on the netdata dashboard). It fixes the "unallocated" storage size on the "BTRFS Physical Disk Allocation" chart, which previously could be off by a factor of 8 if using Btrfs on a modern disk that uses 4KiB hardware sectors.

@CLAassistant
Copy link

CLAassistant commented Mar 28, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added area/collectors Everything related to data collection collectors/proc labels Mar 28, 2023
@intelfx
Copy link
Contributor Author

intelfx commented Mar 28, 2023

@Ferroin could you please test this on your setup?

Ferroin
Ferroin previously approved these changes Mar 29, 2023
thiagoftsm
thiagoftsm previously approved these changes Mar 29, 2023
Copy link
Contributor

@thiagoftsm thiagoftsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @intelfx !

I also tested on my environment and it looks good, LGTM!

Best regards!

ilyam8
ilyam8 previously approved these changes Mar 30, 2023
collectors/proc.plugin/sys_fs_btrfs.c Show resolved Hide resolved
Dim-P
Dim-P previously approved these changes Mar 30, 2023
@intelfx intelfx requested review from Ferroin, Dim-P and ilyam8 and removed request for Ferroin and Dim-P March 30, 2023 10:53
@ilyam8 ilyam8 merged commit 0ac8f7c into netdata:master Mar 30, 2023
@ilyam8
Copy link
Member

ilyam8 commented Mar 30, 2023

Thanks, @intelfx 👍

@intelfx intelfx deleted the work/fix-14816 branch January 7, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/collectors Everything related to data collection collectors/proc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: btrfs unallocated space accounting is wrong
6 participants