Skip to content

feat(fs): fsync directories - #155

Merged
mattmattox merged 5 commits into
mainfrom
claude/dir-fsync
Nov 16, 2026
Merged

mattmattox merged 5 commits into
mainfrom
claude/dir-fsync

Conversation

@mattmattox

@mattmattox mattmattox commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

An fsync of a directory returned ENOTSUP, because Dir and the root didn't implement Fsync. Git, SQLite and Postgres fsync a directory after creating or removing an entry in it, then fail or warn. A directory fsync now flushes the device, as a file fsync already does.

Why one flush rather than per-mode logic: in Sync and Batch mode, a create or unlink is already durable when it returns, because Commit and CompleteIntent flush before returning. Without a journal, or with an async one, nothing else flushes the entry. A device flush covers every mode and costs one fsync per directory fsync, which applications do rarely.

Rename: this filesystem has no rename, so the tests cover create, mkdir and unlink.

Tests

  • TestDirectoryFsync (integration, through FUSE's FSYNCDIR) fsyncs directories after create, mkdir and unlink. Docker and VM run the same steps with sync DIR.
  • TestDirFsyncSurvivesPowerCut models a disk cache that loses every write since the last flush. The device gains a write observer and a sync observer for this. With no journal, entries made or removed before a directory fsync survive the cut, and a create after the last fsync is lost. The lost create shows the model really drops writes.

Results

  • Lint at 54317cc: 0 issues.
  • .66 at 788c450, before the merge with main: race unit tests pass; integration -short 145/0; Docker 55 passed, 1 skipped, 0 failed, including Directory Fsync.
  • .68 VM at 788c450: 65/0, including Directory Fsync.
  • .66 at 54317cc, the merged head: storage, goclusterfs and journal pass under race; the power-cut test passes 3 times; TestDirectoryFsync passes.
  • Mutation check: with directory fsync turned into a no-op, the power-cut test fails: "kept" and "inner" are lost and "gone" comes back. On main, TestDirectoryFsync fails with "operation not supported" at each directory fsync.

🤖 Generated with Claude Code

mattmattox and others added 5 commits November 13, 2026 22:33
Directories had no Fsync, so go-fuse answered an fsync of a directory with
ENOTSUP. Git, SQLite and Postgres fsync a directory after creating or removing
an entry in it, and fail or warn. Directory fsync now flushes the device, as
file fsync does: without a journal, or with an async one, nothing else makes
those entries durable.

The device gains a write and a sync observer, so tests can model a write cache
that loses everything since the last flush.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h a power cut

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit cb32725 into main Nov 16, 2026
17 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.

1 participant