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 stat to use the fd instead of the path #649

Merged
merged 3 commits into from
Apr 24, 2024
Merged

Conversation

vlovich
Copy link
Contributor

@vlovich vlovich commented Apr 12, 2024

What does this PR do?

Fixes #648. Noticed that the reported inode for two sibling O_TMPFILE was identical because the stat was being invoked on the parent directory (i.e. stat never worked for temporary files). Similarly, you can now remove the path backing a file and stat continues to work.

Motivation

2 sibling O_TMPFILE files having the same inode & being unable to get the size of a temporary file.

Related issues

Additional Notes

Checklist

[X] I have added unit tests to the code I am submitting
[X] My unit tests cover both failure and success scenarios
[] If applicable, I have discussed my architecture

@glommer
Copy link
Collaborator

glommer commented Apr 12, 2024

tnx. Will merge, but format tests failing

@vlovich vlovich force-pushed the fix-stat branch 2 times, most recently from 8c59a1d to 7a03027 Compare April 12, 2024 14:44
vlovich added 3 commits April 24, 2024 10:36
Has a race condition fix for async APIs. Not sure if this actually
impacts us but sounds like a worthwhile upgrade.
Attempting to stat on an unlinked file will error with NotFound when it
shouldn't since we still have the fd. Similarly, invoking stat on a
tempfile will stat the parent directory instead of the file itself.
This fixes the broken test cases - unlinked files will still stat
successfully and temporary files will return stat for the file rather
than the parent directory.

There's probably a negligible performance boost since we don't need to
do anything with the path (I believe it saves a memory allocation + some
other cycles) + the kernel might have to do less work handling the
syscall. Of course, stat should never be in the hot path so it's largely
an academic difference.
@glommer glommer merged commit f939477 into DataDog:master Apr 24, 2024
5 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.

Statx is invoked on path instead of fd
2 participants