Skip to content

fix(libkernel): pair inotify rename events across reads - #19

Closed
JJenkx wants to merge 1 commit into
validation/linux-file-events-basefrom
fix/linux-vnode-rename-pairs
Closed

JJenkx wants to merge 1 commit into
validation/linux-file-events-basefrom
fix/linux-vnode-rename-pairs

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Superseded by upstream PR #4819, now merged. It resolves the same rename race using directory-lock ordering. The local development branch adopted that implementation in fe4b7cd after a full build, ten focused checks, 20 queue runs pinned to one core, and the forced 32-byte read-boundary regression passed. The normal 16 KiB buffer is restored. This fork proposal is closed as superseded; its original proposal and validation follow for reference.

What

The Linux vnode watcher matches rename cookies only within one inotify read. If the matching IN_MOVED_FROM and IN_MOVED_TO land in different reads, a rename inside a watched directory incorrectly reports NOTE_WRITE | NOTE_EXTEND. The existing guest_kqueue directory-rename assertion intermittently fails for this reason.

Retain move cookies across reads with a 20 ms bounded wait. Matching opposite-direction events produce one NOTE_WRITE; unmatched entries preserve the existing cross-directory hints after expiry. Stop remains interruptible and pending hints are flushed when the host watch ends. Add deterministic tests for split/interleaved pairs, directory pairs, unmatched arrivals/departures, expiry, duplicate cookies and delayed processing; extend the native queue test with movement outside and back into the watched directory.

The mechanism follows the inotify(7) rename caveat: rename pairs may be split across reads and are not inserted atomically. The 20 ms wait is a host policy, not measured console timing; a counterpart arriving after expiry is still treated as a separate move. Windows behavior is unchanged.

Tested

An investigation-only 32-byte inotify read buffer forces the existing rename pair into separate reads. Before the fix, guest_kqueue fails with one event, flags 0x6 (WRITE | EXTEND). With the fix, the same fixture returns flags 0x2 (WRITE) and passes. The normal 16 KiB buffer is restored; no buffer override or diagnostic print is committed.

Full bundled Linux Release integration build with 32 workers; commit f17e22f on upstream 43e3a70. Normal-buffer guest_kqueue passes 40 consecutive runs. Eleven focused checks pass without skips, including the move matcher, native kqueue/equeue/socket tests, patched libraries and HTTP network regression. Both topic and integration conventions pass. Production FileEvent.cpp, matcher and test sources match the tested integration exactly. That integration includes other development fixes; an independent full topic build and Windows run have not been done. No title progression or new guest exports are claimed.

This review PR is in the JJenkx fork because the upstream author allowance is occupied by boykopovar#4474. Its base branch preserves the already-merged upstream kqueue/file-event implementation and follow-up tests with their authors; the PR diff contains only this fix. All prerequisites are already in upstream main.

Checklist

  • One topic per PR
  • No comments added to code
  • Generic file-event handling
  • No game assets, screenshots or investigation logs added
  • No new third-party code
  • Depends on: none (prerequisites already merged upstream)
  • Unblocks: none
  • AI-assisted: yes

@JJenkx JJenkx closed this Oct 12, 2026
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.

1 participant