Skip to content

fix(fuse): support fsync on directories - #29

Merged
tofarr merged 1 commit into
mainfrom
fix/fsyncdir-enotsup
Dec 1, 2026
Merged

tofarr merged 1 commit into
mainfrom
fix/fsyncdir-enotsup

Conversation

@tofarr

@tofarr tofarr commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

This PR was created by an AI agent (OpenHands) on behalf of the user.

Why

fsync(2) on a directory returns ENOTSUP on a fusey mount. go-fuse answers FSYNCDIR with ENOTSUP unless the node implements Fsync, and fusey only implemented FileHandle.Fsync.

This breaks conversation start in OpenHands on fuse-based runtimes. The OpenHands SDK (>= 1.65.0, software-agent-sdk#7081) fsyncs the parent directory at the end of atomic_write_text, after the rename, and treats any OSError as fatal. Every POST /api/conversations on the agent-server-fusey:1.65.0-python-fusey0.0.15 image returned 500 with:

openhands/sdk/utils/files.py  atomic_write_text
OSError: [Errno 95] Operation not supported

I reproduced this on the beta cluster by running the same syscalls against a live fusey mount in a pod. fchmod, write, fsync(file) and rename succeeded. Only fsync(directory) failed with ENOTSUP.

What changed (internal/fuse/fs.go):

  • Node now implements fs.NodeFsyncer. go-fuse 2.10.1 prefers NodeFsyncer over FileFsyncer for FSYNC, and falls back to it for FSYNCDIR, so one method serves both files and directories.
  • The existing logic moved into Fusey.sync: flush the active chunk, then persist the index snapshot. Persisting the index also makes a rename durable, because directory entries live in the index.
  • FileHandle.Fsync and its FileFsyncer assertion are removed. go-fuse would never call it now that Node.Fsync takes precedence.

Directory fsync on a read-only (as-of) mount behaves the same as file fsync does today.

Validation

  • go build ./..., go vet ./internal/fuse/ and go test ./... pass.
  • New tests in internal/fuse/fs_test.go:
    • TestFsyncDirectory: directory fsync succeeds, and the entry is in the persisted index.
    • TestAtomicWriteSequence: replays the SDK's temp file, fchmod, fsync, rename, parent-directory fsync sequence.
    • TestNodeFsyncWithoutMount: calls Node.Fsync directly with no mount.
  • Not yet verified on a real mount. The development sandbox has no /dev/fuse, so TestFsyncDirectory and TestAtomicWriteSequence skipped there, and only TestNodeFsyncWithoutMount ran. I also did not run the new tests against the old code to show them failing. Please confirm that CI (if it has FUSE) or a local run executes the two mounted tests: go test ./internal/fuse/ -run 'Fsync|AtomicWrite' -v.
  • Follow-up after merge: build a new fusey image, bump the v1_fuse image tag in OpenHands, and retry a conversation start on beta.

@tofarr can click here to continue refining the PR

fsync(2) on a directory returned ENOTSUP: go-fuse answers FSYNCDIR with
ENOTSUP unless the node (or directory handle) implements Fsync/Fsyncdir.
The OpenHands SDK's atomic_write_text fsyncs the parent directory after
the rename and treats any OSError as fatal, so every conversation start
on a fusey mount failed with "OSError: [Errno 95] Operation not supported".

Implement NodeFsyncer on Node. go-fuse routes both FSYNC (preferred over
FileFsyncer) and the FSYNCDIR fallback to it, so the shared sync helper
now serves files and directories: flush the active chunk and persist the
index, which is also what makes renamed directory entries durable.

Co-authored-by: openhands <openhands@all-hands.dev>

@hieptl hieptl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙏

@tofarr
tofarr merged commit 94859d9 into main Dec 1, 2026
1 check 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.

2 participants