Skip to content

v0.11.0 phase A: mv works, and the README says how far short of POSIX it falls - #239

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/164-rename
Aug 3, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/164-rename

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #164.

Rename is a server-side copy then a delete, per object; a directory moves everything under its
prefix. Before this, go-fuse's default for an absent NodeRenamer answered every mv with ENOTSUP.

What is load-bearing

Six properties, each verified by mutation — the implementation broken in that specific way, the test
watched to fail. 11 mutants, 10 killed on the first pass; the 11th survived, was diagnosed as a
genuinely vacuous assertion, and the test was repaired until it discriminated.

Property What goes wrong without it
1 Each source is deleted only after its own copy succeeds An interruption would be able to leave the data at neither name. Duplicated data is cleanup; missing data is not recoverable
2 The copy is server-side Renaming a 10 GiB file would cost 20 GiB of transfer; a directory, that times its object count. Above S3's 5 GiB single-part limit it routes through UploadPartCopy
3 The write path is flushed before the copy A copy acts on objects, so dirty ranges are invisible to it. echo hi > a; mv a b would copy a key that does not exist, delete the source, then flush the pending ranges back to the old name — the file at neither name asked for
4 The moved node is repointed, recursively for a directory MvChild re-parents the same inode, so a stored path is stale the moment a rename succeeds. After mv a b, a write to b flushed to a and recreated the source the rename had just deleted. Silent at every layer: a stale key is a valid key and every S3 call succeeds
5 Prefix matching is on a path boundary mv dir dir-new would move dir2/file. Not hypothetical — the same defect keyMatches had
6 renameat2 flags are refused with EINVAL RENAME_EXCHANGE and RENAME_NOREPLACE are atomicity promises copy-then-delete cannot keep. mv and Git fall back correctly on EINVAL. A foreign newParent is EXDEV, as go-fuse's own LoopbackNode answers

There is no atomic alternative to reach for. S3's RenameObject (2026) is directory-bucket (Express)
only, and object annotations — which ObjectFS needs for POSIX attributes — are unsupported on
directory buckets, so the two features are mutually exclusive. The README now carries a Rename is
not atomic
section stating what a concurrent reader can observe, what an interruption leaves
behind, and which tools that breaks.

Also here, each found while building the above

  • chmod and automatic tier transitions failed on every key containing a +.
    x-amz-copy-source is read by S3 as a URL path; url.PathEscape leaves + alone and S3 decodes
    + there as a space — so a self-copy of a+b.txt asked for a b.txt and got 404 NoSuchKey. A
    + in a filename is ordinary: version numbers, C++ sources, 2026-08-01T00:00+00:00. Escaping now
    lives in one place rather than open-coded at each call site, one of which escaped nothing at all.
    Verified against real S3 in us-west-2 — both PathEscape and EscapedPath() fail, %2B
    succeeds, and every other character PathEscape passes through was probed on the same endpoint.
  • objectfs stats reported zero for six counters that were maintained correctly all along.
    GetStats copies field by field and its list named nine of fifteen: Creates, Deletes,
    Renames, and the three latency EMAs. Guarded now by a reflection test that sets each counter to a
    distinct non-zero value, so a copy taking the right field from the wrong source fails too.
    time.Duration's reflect kind is Int64, which is how the three latency fields were found.
  • The README listed unlink and rmdir as EROFS and said mv fails "because there is no
    rename".
    Both true when written. A row asserting an operation fails misleads in the worse
    direction once it works: a reader avoids something that would have succeeded. Rename's departure
    from that table is pinned from the other side too — a test asserts the bridge dispatches to
    Rename rather than reaching go-fuse's ENOTSUP default, which a drifted signature or an
    excluding build tag would silently restore.
  • internal/testaws grew a DirectoryMarkerDelete probe and a skip gate. Deleting a dir/
    marker while dir/child exists panics the emulator, whose object store is a filesystem
    abstraction where dir/ is the directory holding the child — filed as
    scttfrdmn/substrate#534, reproduced against
    afero alone with no substrate involved. In S3 a key is an opaque string, so this is the emulator's
    property and not ObjectFS's. Hence a runtime probe and a loud skip rather than asserting a
    dependency's bug as this project's contract.
  • copy_live_test.go (-tags=integration) covers the multipart copy path against real AWS, at
    real part sizes. Substrate dispatches on x-amz-copy-source before checking uploadId, so it
    answers an UploadPartCopy as a whole-object copy with 200 (substrate#532) — leaving the branch
    where a mistake is most expensive, since abandoned parts are billed and invisible to
    ListObjects, resting on nothing but reading.

Testing

15 tests in internal/fuse/rename_test.go, against a real S3 endpoint through internal/testaws,
with the real write path and real cache — no mock on any seam, which is the point: the v0.10.0 audit
found ~45 defects that 32,680 lines of tests had all missed, overwhelmingly because a mock on the far
side of a seam agrees with its caller by construction.

go build ./... && go test -race ./...                      # green
gofmt -l internal/ pkg/ cmd/ tests/                        # clean
go vet ./...                                               # clean
golangci-lint run --new-from-merge-base=origin/main        # 0 issues

Rename is a server-side copy then a delete, per object; a directory moves
everything under its prefix. Before this, go-fuse's default for an absent
NodeRenamer answered every `mv` with ENOTSUP.

Six properties are load-bearing, and each was verified by mutation — the
implementation broken in that specific way, the test watched to fail:

  - Each source object is deleted only after its own copy succeeds. An
    interruption leaves the data at the old name, the new name, or both;
    never at neither. Duplicated data is an operator's cleanup problem,
    missing data is not recoverable, so the ordering is deliberate and a
    partial directory move is resumable by re-running the same mv.
  - The copy is server-side. Reading and rewriting through the process
    would make renaming a 10 GiB file cost 20 GiB of transfer, and a
    directory that times its object count. Above S3's 5 GiB single-part
    CopyObject limit it routes through UploadPartCopy.
  - The write path is flushed first. A copy acts on objects, so a file
    whose only content is dirty ranges is invisible to it: `echo hi > a;
    mv a b` would have copied a key that did not exist, deleted the
    source, then flushed the pending ranges back to the old name — the
    file landing at neither name the user asked for.
  - The moved node is repointed, recursively for a directory. MvChild
    re-parents the same inode, so a FileNode survives a rename holding
    the path it was constructed with, and a stored path is stale the
    moment a rename succeeds. After `mv a b`, a write to `b` flushed to
    `a` and recreated the source the rename had just deleted. Silent at
    every layer: a stale key is a valid key and every S3 call succeeds.
  - Prefix matching is on a path boundary, so `mv dir dir-new` does not
    move dir2/file. Not a hypothetical — the same defect keyMatches had.
  - renameat2's RENAME_EXCHANGE and RENAME_NOREPLACE are refused with
    EINVAL rather than approximated. Both are atomicity promises
    copy-then-delete cannot keep, and mv and Git fall back correctly on
    EINVAL. A foreign newParent is EXDEV, as go-fuse's own LoopbackNode
    answers.

There is no atomic alternative to reach for: S3's RenameObject (2026) is
directory-bucket only, and object annotations are unsupported there, so
the two features are mutually exclusive. The README now carries a "Rename
is not atomic" section stating what a concurrent reader can observe and
which tools that breaks.

Also in this change, each found while building the above:

  - chmod and tier transitions failed on every key containing a "+".
    x-amz-copy-source is read as a URL path, url.PathEscape leaves "+"
    alone, and S3 decodes "+" there as a space — so a self-copy of
    "a+b.txt" asked for "a b.txt" and got 404 NoSuchKey. A "+" in a
    filename is ordinary. Escaping now lives in one place; verified
    against real S3 in us-west-2, where PathEscape and EscapedPath both
    fail and %2B succeeds.
  - GetStats reported zero for six live counters. Its copy named nine of
    fifteen fields, dropping Creates, Deletes, Renames and the three
    latency EMAs. Guarded now by a reflection test that sets each
    counter to a distinct value, so a copy taking the right field from
    the wrong source fails too.
  - The README listed unlink and rmdir as EROFS and said mv fails
    "because there is no rename". Both were true when written. A row
    asserting an operation fails misleads in the worse direction once it
    works: a reader avoids something that would have succeeded.
  - internal/testaws grew a DirectoryMarkerDelete probe and a skip gate.
    Deleting a `dir/` marker while `dir/child` exists panics the
    emulator, whose object store is a filesystem abstraction where
    `dir/` is the directory holding the child (scttfrdmn/substrate#534,
    reproduced against afero alone). In S3 a key is an opaque string, so
    this is the emulator's property, not ObjectFS's — hence a runtime
    probe rather than asserting a dependency's bug as our contract.
  - copy_live_test.go (-tags=integration) covers the multipart copy path
    against real AWS at real part sizes. Substrate dispatches on
    x-amz-copy-source before checking uploadId, so it answers an
    UploadPartCopy as a whole-object copy with 200 (substrate#532),
    leaving the branch where a mistake is most expensive — abandoned
    parts are billed and invisible to ListObjects — resting on reading
    alone.

Closes #164
@scttfrdmn scttfrdmn added type: enhancement New feature or improvement to existing functionality priority: high Important issue that should be addressed soon area: fuse FUSE layer and filesystem interface labels Aug 3, 2026
Comment thread internal/storage/s3/backend.go Fixed
FlushPrefix, DiscardPrefix, and underPrefix live in internal/vfs; their tests were in
internal/fuse/rename_test.go, which left all three reading 0.0% covered no matter how thoroughly
the rename tests exercised them. Coverage is per-package and the profile follows the code, not the
consequence — so the CI gate failed on internal/vfs at 95.4% against a floor of 98.

Moving them there bought two cases the fuse-level fixture could not reach:

  - Failing a flush needs a backend that rejects a PUT. Asserting the rename must not proceed past
    that is the whole point of stopping at the first failure, and it is the opposite of FlushAll's
    press-on behavior, so it needs its own test rather than an assumption.

  - Renaming a single file passes the file's own key where those methods take a prefix, so the
    key-equals-prefix arm of underPrefix is the common path rather than an edge case. It was
    invisible from a directory test because a key beneath a directory satisfies the boundary rule
    too: "dir/a.txt" matches "dir" both ways. Mutation testing confirmed it — deleting that arm
    left every directory rename correct, broke every file rename, and no test failed. Now
    TestPrefixOperationsOnAnExactKeyTakeThatKey fails in both subtests.

internal/vfs is back to 98.4%.

Also count multipart-copy part numbers in the int32 that S3's PartNumber actually is, rather than
converting len(parts) on each iteration. The conversion could not overflow — S3 refuses the upload
above 10,000 parts — but a //nolint comment only quiets golangci-lint, and the gosec workflow
reported it as a new code-scanning alert. An argument a scanner cannot check is better replaced
than annotated.

Refs #164
@scttfrdmn
scttfrdmn merged commit 083c3a0 into main Aug 3, 2026
23 checks passed
@scttfrdmn
scttfrdmn deleted the feat/164-rename branch August 3, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: fuse FUSE layer and filesystem interface priority: high Important issue that should be addressed soon type: enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C4-2: Implement Rename via CopyObject and DeleteObject

2 participants