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

df: switch from u64 to u128 to handle fs with large inodes nr #6071

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

cre4ture
Copy link
Contributor

@cre4ture cre4ture commented Mar 14, 2024

addresses #6070

changes:

  • use u128 for accumulating inodes
  • use Option<> additionally to handle overflows correctly
  • add unittests accordingly

I know that u128 is slower than u64 as its probably not natively supported, but we are not accumulating millions of numbers such that it should not be significant.

ADDITION:

  • I also fixed the issue that the total row was not considered when computation of column widths is done

@cakebaker cakebaker linked an issue Mar 14, 2024 that may be closed by this pull request
@cakebaker cakebaker changed the title switch from u64 to Optional<u128> to handle fs with large inodes nr df: switch from u64 to Optional<u128> to handle fs with large inodes nr Mar 14, 2024
@cre4ture cre4ture force-pushed the fix/df_total_int_overflow_android branch 2 times, most recently from eaab79c to 68679ea Compare March 14, 2024 13:45
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/mv/backup-dir is no longer failing!

@cre4ture cre4ture force-pushed the fix/df_total_int_overflow_android branch from 68679ea to 29844af Compare March 14, 2024 14:42
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/mv/backup-dir is no longer failing!

Copy link
Member

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

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

The u128 change is fine I think. I guess it's not compatible, but it feels correct. Having to deal with overflow here seems a bit like overflow though. I'd say that's an issue that we postpone for when someone actually runs into a real use case where u128 overflows. But if you have some use case for it we can discuss that.

Comment on lines 21 to 22
type InodesIntT = u128;
type MaybeInodesT = Option<InodesIntT>;
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate the idea here, but I think it obfuscates the exact data type too much. Id rather just see Option<u128> everywhere than MaybeInodesT because then I actually know what I'm dealing with.

@cre4ture cre4ture changed the title df: switch from u64 to Optional<u128> to handle fs with large inodes nr df: switch from u64 to Option<u128> to handle fs with large inodes nr Mar 14, 2024
@cre4ture cre4ture force-pushed the fix/df_total_int_overflow_android branch from bd87899 to 018758c Compare March 15, 2024 11:30
@cre4ture cre4ture changed the title df: switch from u64 to Option<u128> to handle fs with large inodes nr df: switch from u64 to u128 to handle fs with large inodes nr Mar 15, 2024
Copy link

GNU testsuite comparison:

GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@cre4ture cre4ture force-pushed the fix/df_total_int_overflow_android branch from 667f5c3 to eed7a53 Compare March 15, 2024 12:34
@cre4ture cre4ture force-pushed the fix/df_total_int_overflow_android branch from eed7a53 to 6fa2c58 Compare March 15, 2024 12:40
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre merged commit 32b5591 into uutils:main Mar 18, 2024
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android 12: df fix integer overflow in computation of Total row
3 participants