fs/macos: fix ghost files are double fd closing#544
Merged
slp merged 2 commits intocontainers:mainfrom Feb 17, 2026
Merged
Conversation
Contributor
|
Works on my side. Performance only 6% lower than |
a9bb0e6 to
f8207e2
Compare
When unlinking an inode, we were grabbing and storing an fd to the inode without checking if the underlying `unlinkat` operation succeeded or not. This was wrong, and was leading to us storing an fd in unlinked_fd even for inodes still linked (i.e. if the guest attempts to unlink a non-empty directory). Let's split the action in two steps, first we grab the an fd to the inode before unlinking it, and then we actually store the fd in unlinked_fd after checking that `unlinkat` succeeded. Fixes: containers#541 Signed-off-by: Sergio Lopez <slp@redhat.com>
fdopendir() takes ownership of the fd passed as argument to it, so passing the fd of the HandleData->File will cause the fd to be closed twice, first when closedir() is called and second when Arc<HandleData> is dropped. If the library is built with debug-assertions enabled, this issue will trigger an error like: fatal runtime error: IO Safety violation: owned file descriptor already closed, aborting To avoid this issue, let's use dup() to obtain a new descriptor from HandleData->File to be donated to fdopendir(). Fixes: containers#539 Co-authored-by: dorindabassey <53014273+dorindabassey@users.noreply.github.com> Co-authored-by: Vadzim Dambrouski <pftbest@gmail.com> Signed-off-by: Sergio Lopez <slp@redhat.com>
f8207e2 to
5dc2fee
Compare
Collaborator
Author
|
Applied @dorindabassey's suggestion (thanks!) squashing it in the previous commit (adding her as Co-author) and rebased the series on HEAD. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ghost files were caused by a bug introduced in #513, while the double fd closing came from using the HandleData->File fd with fdopendir, which takes ownership of the fd.