fix: prevent poll from deleting inodes with open file handles#74
Merged
Conversation
The poll thread could remove an inode from the table while file handles were still referencing it, causing read/getattr/release to fail with ENOENT. Now checks open_files before removing, keeping the inode alive until all handles are released. - Wrap open_files in Arc so it can be shared with the poll task - Pass open_files to apply_poll_diff, skip deletion when handles exist - Add poll_skips_deletion_with_open_handles test
POSIX Compliance (pjdfstest) |
Benchmark Results |
- Extract has_open_handles_for() free function (shared by VirtualFs and poll) - Fix missing continue when inode already removed between snapshot and write lock - Simplify deletion guard with match expression - Test now verifies second poll cleans up after handle release
…en handles Instead of skipping the deletion entirely (leaving the file visible by name), unlink the pathname via unlink_one() but keep the inode as an orphan (nlink=0). This way open handles can still read/fstat, but the file disappears from lookup/readdir. release() cleans up the orphan.
a80e0a2 to
891d656
Compare
XciD
added a commit
that referenced
this pull request
Mar 26, 2026
Bump version to 0.1.1. ## Changes since v0.1.0 ### Bug fixes - fix: prevent file descriptor exhaustion on bulk NFS deletes (#68) - fix: schedule flush after NFS exclusive create with empty files (#71) - fix: re-check dirty status before poll deletes inode, TOCTOU race (#67) - fix: prevent poll from deleting inodes with open file handles (#74) - fix: prevent apply_commit from clobbering size/hash on generation mismatch (#75) - fix: serialize setattr truncate with write to prevent inode size race (#76) - fix: tolerate rename Phase 3 failure after remote mutation (#77) ### Performance - perf: chunk upload_files to bound FD usage during flush (#72) - perf: skip redundant HEAD revalidation after flush commit (#73)
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.
Summary
Fixes REVIEW.md finding 2-#69: the poll thread could remove an inode from the table while file handles were still referencing it, causing
read()/getattr()/release()on those handles to fail withENOENT.Root cause:
apply_poll_diffcalledinode_table.remove(ino)without checking whether anyOpenFileentries referenced that inode.Fix
open_filesinArcso it can be shared with the poll taskopen_filestoapply_poll_diff, skip deletion when handles existTest
poll_skips_deletion_with_open_handles: opens a file, simulates remote deletion via poll, verifies the inode survives while the handle is open