Repository navigation
v0.11.0 phase A/B: rm and rmdir work, and the write buffer is bounded - #238
Merged
Merged
Conversation
write_buffer.max_memory was declared in the config schema, defaulted to "512MB", validated as a size string — and read by nothing. A grep for the field name outside internal/config returned three hits, all inside internal/config. So every mount reported a 512 MB write-buffer ceiling and enforced none, on the one path that holds user data in memory before it is durable, where the failure mode is the OOM killer taking the mount process and with it every open file's unflushed dirty ranges. This is the same defect shape the whole v0.10.x series was spent correcting: a configuration key asserting a property no code enforces. Three properties of the bound matter more than its existence: It reclaims before it refuses. At the ceiling with flushable data, the write path flushes and accepts. A bound that refused first would turn every workload writing more than the limit in total into ENOSPC — which, at the shipped 512 MB default, is every workload ObjectFS exists for — while the bytes it was holding were perfectly storable. A limit that rejects legal writes is worse than the unbounded growth it replaces. A single write larger than the entire limit is admitted. POSIX has no way to say "this write is too large, try a smaller one": write(2)'s ENOSPC means the filesystem is full, so a caller that retries gets the same answer forever. Refusing would make the file permanently unwritable at that configuration rather than the buffer bounded. The bound exists to stop accumulation across files, which one oversize write is not. A refusal is vfs.ErrNoSpace, mapped to ENOSPC by the FUSE layer. A bare fmt.Errorf would reach the kernel as EIO — "the filesystem is broken" rather than "the filesystem is full" — and no program handles EIO by retrying or freeing space. The node-count bound (write_buffer.max_buffers) exempts keys already holding writes. Otherwise a program appending to one log file starts failing as soon as other files fill the map, its own writes refused for a limit it is not contributing to. buildWriterOptions is a method rather than an inline literal in the constructor so the mapping is assertable without a live backend. That is not a style preference: D12 survived 32,680 lines of tests precisely because its mapping was only reachable through a constructor nothing could call in a unit test. Mutation-verified, four rounds, each restored: dropping the admit() call, skipping reclaim so the bound refuses first, removing the oversize admission, and stubbing buildWriterOptions to return a zero value each produced the specific expected failure. The last one fails TestDefaultConfigProducesABoundedWritePath, which would have failed for every release through v0.10.3 at the only configuration most users ever run. Closes #205
Unlink and Rmdir were EROFS stubs. That stub was itself a fix, and the thing it fixed explains why this needs care: go-fuse defaults an unimplemented NodeUnlinker or NodeRmdirer to *success*, so before it `rm` exited 0, the kernel dropped the inode, and the object stayed in the bucket billing with no path that reached it. Failing loudly was the interim answer. Deleting the object is the real one. Unlink discards the write path's pending state before deleting the object. `echo x > f; rm f` is an ordinary sequence and the kernel does not guarantee a flush before the unlink, so a surviving dirty range outlives the object: the next flush, or the unmount, PUTs it back and the file returns from the dead at the size it was written, with no error anywhere. Writer.Discard is new for this — dropping the node is the whole operation, since its extents, truncation, and dirty attributes all live on it, and FlushAll iterates that map so a node absent from it cannot be uploaded at unmount either. The ordering claim is narrower than it looks, and the comment now says so. Both orders discard, so on this sequential path both are correct; what discard-before-delete buys is the concurrent case, where a background flush landing between the steps would recreate the object after the delete removed it. Moving the discard after the delete fails no test in delete_test.go — established by mutation, not assumed, and recorded rather than left as an unverified assertion in a comment. Unlink establishes existence itself rather than inferring it from the delete. types.Backend's DeleteObject returns nil for a key that is not there — S3's contract and the SDK's documented behavior — so relying on its error would report success for every `rm` of a file that never existed. The check asks two places, because a file can exist in the bucket or only as dirty ranges: Create records attributes through the write path and PUTs nothing, so between `touch f` and the first flush the file is real and visible to stat with no object behind it. Consulting only the backend would make `touch f && rm f` fail with ENOENT on a file the user can see. A HeadObject error that is not absence — a throttle, a permission failure — does not proceed to the delete; reporting ENOENT for those is what let v0.10.0's Lookup invite an overwrite of an intact object. Rmdir checks emptiness first, and lists with a limit of two rather than one. The marker object's key *is* the prefix, so it appears in its own listing: one entry means "just the marker" and two means something else is under it, and a limit of one cannot tell those apart. Refusing with ENOTEMPTY is required by POSIX and is also the only safe answer, since removing the marker of a populated prefix succeeds at the storage layer and leaves every object under it present, billing, and unreachable through the filesystem. stats.Deletes is now incremented. The field has existed on Stats since v0.10.0 and no code ever wrote it — a number reported to an operator that nothing produced. delete_stub_test.go is replaced by delete_test.go, which keeps its NodeUnlinker/NodeRmdirer compile-time guards. Those are load-bearing rather than decorative: if DirectoryNode stops satisfying them, go-fuse never calls this package and silently defaults both operations to success, and no runtime test would catch it because the methods would still exist and still work when called directly. 14 tests against a real S3 endpoint, real write path, real cache — no mock on any seam, because a mock asked "was Delete called" answers the question the implementation was written to answer, and only the object's actual absence distinguishes a delete from a report of one. Mutation-verified in nine rounds, each restored; eight produced targeted failures and the ninth is the ordering null result documented above. Closes #163
The memory bound landed in the previous commit with a rule that was correct in isolation and wrong
as the only rule. reclaim flushes other keys and skips the one being written, because its pending
writes are about to be extended and uploading them now guarantees a second upload of the same
object moments later. But a program appending to one file has no other key to flush, and small
appends never trip the oversize escape hatch, so the bound refused the most ordinary write there
is: at the shipped 512 MB default, writing any file past 512 MB failed at exactly 512 MB with
ENOSPC.
append 4 at offset 1024 failed: vfs: no space in write buffer: write path holds 1024 dirty
bytes and this 256-byte write would exceed the 1024-byte limit
Sequentially writing a large file is the workload ObjectFS exists for, so a bound that forbids it
is worse than no bound at all. admit now flushes the target key as a last resort. That is safe
rather than expedient: Flush performs the read-modify-write and leaves the node clean, and the
write that follows lands on a clean node at its own offset — which is what streaming a large file
through a bounded buffer looks like. Same probe afterwards: all 32 appends succeeded, held = 1024.
TestWriterStreamsOneFilePastItsWholeLimit writes a file to eight times its limit and asserts three
things, not one: every write succeeds, Size() stays inside the bound throughout, and the flushed
object is the full 8192 bytes. The third is the one that matters — a "reclaim" that dropped bytes
would satisfy the first two.
Found by asking why a coverage gate could not reach a branch, not by a failing test. The rest of
this commit is that coverage work, which is also where two comments turned out to be wrong:
dirtyContentLocked and Flusher.attempt both called a negative stored size unreachable because "this
type never assigns" one, but NewNode is exported and, unlike HandleTable.Open, cannot refuse it. It
is reachable, both fail closed, and TestNodeWithANegativeStoredSizeFailsClosed and
TestFlushRefusesANodeWhoseLengthCannotBeComputed now pin that — including that the refused flush
issues no request at all, since a write that fails after touching the object leaves the caller
unable to tell what is stored. NewNode's doc says so now instead of the comments claiming it cannot
happen.
Verified by mutation, each restored and rebuilt: reporting clean from dirtyContentLocked fails both
new node tests; ignoring attempt's plan error makes the flush silently succeed; perturbing
UncoveredEnd's fully-covered return fails the two new cases that reach it. One mutation produced
nothing — early-returning from UncoveredEnd's loop after a single step breaks no test, which
confirms rather than contradicts the comment already there: the loop exists for the invariant's
benefit, not because a second iteration is expected.
The two refusal branches admit can still reach are unreachable deterministically — a successful
flush always removes the node, and attribute-only nodes flush successfully — so both carry a
reachability comment rather than a race-dependent test. A test that depends on winning a race is a
flake, and a bound that quietly stops applying is the defect this change fixes.
internal/vfs coverage 96.5% → 98.3%, back above its floor.
Refs #205
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First two issues of v0.11.0. Both are the same defect shape the v0.10.x series was spent on — a
surface that claims something no code enforces — in the two places it still survived.
#163 —
rmandrmdirUnlinkandRmdirwere EROFS stubs. The stub was itself a fix: go-fuse defaults an unimplementedNodeUnlinkerto success, so before itrmexited 0, the kernel dropped the inode, and the objectstayed in the bucket billing with no path that reached it.
Three details carry the weight:
echo x > f; rm fis ordinary and the kernel does not guarantee aflush first, so a surviving dirty range would be PUT back by the next flush or the unmount — the
file returning from the dead at its written size, with no error anywhere.
rmdirrefuses a non-empty directory. The listing asks for two entries, not one: the markerobject's key is the prefix, so it appears in its own listing, and one entry cannot be told from
"just the marker". Removing the marker of a populated prefix succeeds at the storage layer and
leaves every object under it present, billing, and unreachable through the filesystem.
DeleteObjectno-ops a missing key (S3's contract), so existence is checkedexplicitly — against both the bucket and the write path, since
Createrecords attributes with noPUT and a just-created file is visible to
statwith no object behind it.#205 —
write_buffer.max_memoryDeclared, defaulted to
"512MB", validated as a size string, read by nothing. Every mount reported aceiling and enforced none, on the one path holding user data in memory before it is durable.
The bound reclaims before it refuses — at the ceiling with flushable data it flushes and accepts.
Refusing first would turn every workload writing more than 512 MB in total into ENOSPC, which is every
workload ObjectFS exists for. A single write larger than the whole limit is admitted, since
write(2)'s ENOSPC means "filesystem full" and a retry would get the same answer forever. Refusalssurface as ENOSPC via
vfs.ErrNoSpace, not EIO.Verification
24 new tests. The delete tests run against a real S3 endpoint, real write path, and real cache — no
mock on any seam, because a mock asked "was Delete called" answers the question the implementation was
written to answer, and only the object's actual absence distinguishes a delete from a report of one.
Mutation-verified, 13 rounds, each restored. Twelve produced targeted failures. The thirteenth did
not: moving
Discardto afterDeleteObjectfails nothing, because both orders discard on asequential path. That null result is recorded in the code comment and the test doc rather than left as
an unverified claim — the order closes a concurrent-flush window, which is a narrower thing than the
comment originally asserted.
TestDefaultConfigProducesABoundedWritePathwould have failed for every release through v0.10.3, atthe only configuration most users ever run.
Closes #163
Closes #205