Skip to content

core: the direct_io test's reference read goes through the page cache - #486

Merged
ashhart merged 1 commit into
ashhart:mainfrom
jschmied:fix-direct-io-test
Oct 9, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
jschmied:fix-direct-io-test

Conversation

@jschmied

@jschmied jschmied commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What this changes

direct_io's test "direct reads return the same bytes as buffered reads" opened its buffered reference with File.open, which makes the descriptor O_DIRECT wherever the file system allows it; setting .direct = false afterwards does not change the descriptor. On ext4 on NVMe (a DGX Spark's root disk) the reference pread of 1 byte into an unaligned buffer then fails with EINVAL, and the test reports expected 1, found -1. Where O_DIRECT is refused (overlay, tmpfs) File.open falls back to the page cache and the test passes, which is why it can go unnoticed.

The reference descriptor is now opened without O_DIRECT. The direct handle is unchanged, so the test still checks the O_DIRECT path. Test only, 3 lines.

Receipt

  • Environment: main at 041d14a, head 9fc4b99. Zig 0.17.0, DGX Spark (GB10), the repository on the root ext4 file system.
  • Before: zig build test fails in direct_io with expected 1, found -1, on main as on every branch.
  • After: zig build test: 17 of 17 steps, every test passes.

The test opened its buffered reference with File.open, which makes the fd
O_DIRECT wherever the file system allows it; setting .direct = false did not
change the fd. On ext4 on NVMe (a DGX Spark's root disk) the reference pread of
1 byte into an unaligned buffer then fails with EINVAL and the test reports
-1. Where O_DIRECT is refused (overlay, tmpfs) File.open falls back and the test
passed. The reference fd is now opened without O_DIRECT; the direct handle is
unchanged, so the test still checks the O_DIRECT path.
@ashhart

ashhart commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Thank you, @jschmied, for isolating the direct-I/O test's reference descriptor. Opening that reference without O_DIRECT fixes the comparison and leaves production reads unchanged. On a DGX Spark's ext4 NVMe root, the old test failed and yours passes all three direct-I/O tests; it landed on main with your original commit.

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.

2 participants