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 statx #3203

Open
OH-AU opened this issue Mar 1, 2022 · 3 comments
Open

df statx #3203

OH-AU opened this issue Mar 1, 2022 · 3 comments
Labels

Comments

@OH-AU
Copy link

OH-AU commented Mar 1, 2022

checked with 0.0.12 (and 0.0.8)
When running
df -h /my_fs
instead of just checking /my_fs, df iterates through every mounted filesystem with a statx e.g.
statx(AT_FDCWD, "/data/something", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_BASIC_STATS, stx_attributes=0, stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
This may be fine with only a few mounts, but when a system has hundreds of mounts it can take some time to return results when the system is under load and run for the first time. gnu df also had this/similar problem but was addressed a long time ago I believe. Wondering if there was a way to only iterate the mount of interest and skip the rest in this case?

@jfinkels
Copy link
Collaborator

jfinkels commented Mar 2, 2022

Maybe pull request #3161 will resolve this issue?

@OH-AU
Copy link
Author

OH-AU commented Mar 2, 2022

I don't believe it does - I grabbed the latest git version - same problem, Then grabbed the updated df.rs file from the above out of tree and it also shows the same behaviour.

@crazystylus
Copy link
Contributor

I think this issue is not specific to df. This issue is created because when uucore::fsext::read_fs_list is invoked, it will create a mount entry for every line read from mtab file and while creation it will call set_missing_fields() which calls std::fs::metadata() for each entry read from mount_info. This will internally make a syscall statx.

Refer to this section of code -> https://github.com/uutils/coreutils/blob/main/src/uucore/src/lib/features/fsext.rs#L150-L163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants