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

Incorrect diskstat value wrap up calculations for 64-bit platforms in disk plugin #4245

Open
eero-t opened this issue Jan 22, 2024 · 1 comment
Labels
Bug A genuine bug linux only

Comments

@eero-t
Copy link
Contributor

eero-t commented Jan 22, 2024

  • Version of collectd: v6 HEAD, v5 HEAD

Steps to reproduce

grep UINT_MAX src/disk.c

Expected output

Correct max value used in wrap up calculations.

Actual output

Both v5 (main) and v6 (collectd-6.0) HEAD give:

src/disk.c:        diff_read_sectors = 1 + read_sectors + (UINT_MAX - ds->read_sectors);
src/disk.c:        diff_write_sectors = 1 + write_sectors + (UINT_MAX - ds->write_sectors);
src/disk.c:        diff_read_ops = 1 + read_ops + (UINT_MAX - ds->read_ops);
src/disk.c:        diff_write_ops = 1 + write_ops + (UINT_MAX - ds->write_ops);
src/disk.c:        diff_read_time = 1 + read_time + (UINT_MAX - ds->read_time);
src/disk.c:        diff_write_time = 1 + write_time + (UINT_MAX - ds->write_time);
src/disk.c:        diff_io_time = 1 + io_time + (UINT_MAX - ds->io_time);

Bug description

Above variables and struct members are 64-bit (signed) derive_t values, whereas UINT_MAX is 32-bit (unsigned) value.

According to kernel documentation, values read from /proc/diskstats are unsigned long (native word size) numbers, i.e. UINT_MAX is correct only for 32-bit platforms: https://www.kernel.org/doc/Documentation/iostats.txt

(Whereas most machines today are running 64-bit Linux.)


Noticed while reviewing #4217.

@eero-t
Copy link
Contributor Author

eero-t commented Jan 24, 2024

#4217 fixed the issue for v6, by using collectd counter_diff() helper. v5 still needs a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug linux only
Projects
None yet
Development

No branches or pull requests

2 participants