Repository navigation
Description
Summary
Implement Statfs and Fsync. df currently fails on a mount, and fsync/sync return an
error rather than flushing buffered writes — which matters for durability, not just tooling.
Background
Neither operation exists in internal/fuse/filesystem.go. Statfs is declared in
internal/filesystem/interface.go with only a test-mock implementation.
Fsync is the more consequential of the two. Applications that call fsync and check the
return value are entitled to assume their data is durable afterward. Today the call fails, so
either the application errors out or — worse, if it ignores the result — believes data is
durable when it is still in the write buffer.
Statfs is cosmetic by comparison, but df failing makes the mount look broken, and some
tools refuse to write to a filesystem they cannot stat.
Implementation
Fsync — flush the write buffer for the file's path and wait for the S3 PUT to complete
before returning. Reuse the existing buffer flush machinery rather than adding a parallel path.
Return the underlying error if the upload fails; do not report success on a failed flush. An
fsync on a file with nothing buffered is a no-op returning success.
Statfs — S3 has no size or inode limits to report, so the values are necessarily
synthetic. Report a large fixed capacity with proportional free space, a sane Bsize, and a
large Namelen (S3 keys allow 1024 bytes).
The one thing to get right: do not report zero free space, which causes tools to refuse
writes with ENOSPC. Pick a large capacity with most of it free and document the values as
synthetic.
Acceptance Criteria
-
df -h <mount>reports plausible non-zero total and available space -
Statfsnever reports zero available space -
Namelenreflects the S3 key limit -
fsyncon a file with pending writes flushes to S3 before returning -
fsyncreturns the underlying error when the flush fails -
fsyncon a file with no pending writes succeeds as a no-op -
syncon the mount completes without error - After
fsyncreturns success, the object is readable from S3 by an independent client - Synthetic
Statfsvalues are documented -
go test -race ./internal/fuse/...passes -
AWS_PROFILE=aws AWS_REGION=us-west-2 go test -race -tags=integration ./internal/fuse/...passes
Dependencies
Independent of the attribute-storage work. Can land alongside #163 and #164.
Activity
scttfrdmn commentedon Aug 2, 2026
Status: implemented in v0.10.1 — this can likely close
Both operations landed. Checking against the acceptance criteria:
Fsync—FileNode.Fsync(internal/fuse/attributes.go:361) callsbuffer.FlushContext(ctx, path), returnstoErrno(err)on failure, invalidates the cache entry, and marks the handle clean. No-op returning success when there is no buffer.rawBridge.FsyncprefersNodeFsynceroverFileFsyncer, so the one implementation answers bothfsync(2)and syncfs-style callers.One deliberate deviation from the issue:
flagsis ignored, sofdatasyncandfsyncare identical. That is not a shortcut — a PUT writes an object's data and its metadata in one request, so there is no cheaper data-only path to take.DirectoryNode.Fsync(:450) returns 0 without doing anything, and the reasoning is recorded at the method: a directory here is a key prefix, holds no state of its own, so no state of its own can be made durable. Databases and VCS tools fsync a directory to force a rename or create to disk, and both already complete synchronously on this filesystem — success is the accurate answer, not a convenient one.Statfs— implemented on both node types (:383,:455), both delegating toFileSystem.statfs(:485). Values (:471-477):Bsize4096,Blocks1<<38 (1 PiB),Bfree/Bavailequal toBlocks,Files/Ffree1<<32,NameLen255.Two notes where the implementation differs from the issue, both intentional:
NameLenis 255, not 1024. The issue asked for the S3 key limit. 255 is the POSIXNAME_MAXmost tools expect for a single path component; the 1024-byte S3 limit is on the whole key, which is closer toPATH_MAX. Reporting 1024 would let a tool create a component the backend accepts but that no other filesystem could hold.statfs. Reporting zero free space would makeinstall(1),dd, and most package managers refuse to write — which the issue correctly flagged as the one thing to get right.statfsexisting at all is load-bearing beyonddf:rawBridge.StatFsleavesStatfsOutentirely zeroed and returns success when the node does not implementNodeStatfser, and go-fuse's own documentation says an macOS filesystem must implementStatfsor the mount will not work. A zero block size is not a numberdfor the macOS VFS can do anything with.Not yet verified: the two criteria that need a live mount —
df -h <mount>output, andafter fsync returns success, the object is readable from S3 by an independent client. The unit-level behavior is covered; the end-to-end assertions want the real-S3 smoke test.Suggest closing once those two are checked against a live
us-west-2mount, rather than closing on code inspection — "fsync returned 0" and "the bytes are in S3" are different claims, and the gap between them is precisely the class of defect that made v0.10.0 unusable.