Skip to content

feat(fs): rename files and directories - #175

Merged
mattmattox merged 11 commits into
mainfrom
feat/rename
Nov 16, 2026
Merged

mattmattox merged 11 commits into
mainfrom
feat/rename

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Rename PR 1 of 3 from the approved plan: the core. PR 2 adds fsck checks (one name per directory, "..", cycles). PR 3 adds multi-node, Docker and VM tests, renames in the history checker, and the soak model.

What the code can't tell you:

  • Locking: the stripes of every directory whose entries change, then the volume lock only when a directory changes parent, then the inode locks in lock-record order (new lock.Record). The volume lock stops two concurrent moves that each pass the ancestor check from forming a cycle.
  • Replacing a target: a file goes through fix(fs): keep a file unlinked while open until every node closes it #161's reserveOrphan, LinkDrop and dropLink, so a peer that has it open keeps it until its last close. An empty directory is freed.
  • Replay: a committed rename always ends with the new name, unless another node took that name after the crash. Then the old name stays, and the target's own records in the transaction are skipped. A parent's link count changes only while the parent is as the rename logged it.
  • RENAME_EXCHANGE and RENAME_WHITEOUT give EINVAL.

Evidence on .68, on main 580d18f plus #174: lint, unit, -race, -short integration (150 pass, 0 fail), parity, -race on dir and journal. Power cuts at every write of five renames (6 to 15 writes each) end with exactly one name, and fsck finds only leaks. TestRename runs through the mount.

The first commit fixes the two wording nits from #174's review.

🤖 Generated with Claude Code

mattmattox and others added 11 commits November 16, 2026 17:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… of one type in order

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rename takes the stripes of every directory whose entries change, the
volume lock when a directory changes parent, and the inode locks in
lock-record order. Under them it rechecks both names, the types, an
emptied target and the move-into-itself case. It runs the caller's
commit, then writes both parent inodes before any chunk. A directory
that changes parent gets its ".." rewritten and both link counts
adjusted. A full new parent grows by an empty block first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DirRename now carries both parents' generations, the moved inode's
generation and type, and the replaced target, so replay finishes a
committed rename: the new name ends up naming the moved inode, the old
name goes, a moved directory's ".." follows, and each parent's link
count changes only while the parent is as the rename logged it. If
another node took the new name since, the old name stays and the
target's own records in the transaction leave it alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rename and RENAME_NOREPLACE now work within a directory and between
directories; RENAME_EXCHANGE and RENAME_WHITEOUT give EINVAL. A
replaced file loses its link through the same path unlink uses, so a
peer that has it open keeps it until its last close; a replaced empty
directory is freed. The journal records the rename and what it does to
the target before anything changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each of five renames, in one directory, between directories, over a
file, a directory moving between parents, and a directory over an empty
one, ends with exactly one of its two names after replay, and fsck finds
nothing but leaks.

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>
…nged its names

renameOnce releases its locks before it completes its intent, so a later
rename, rename back or unlink could change the names before a crash, and
replay then redid the rename over them: two names for one link, a name
for a freed inode, or a rename undone. A rename writes each parent, and
a moved directory, once under its locks, so replay now skips the names
when any of them is freed or more than one write past the generation
the rename logged.

The CHANGELOG notes that older nodes replaying this journal skip the
rename but drop the target's link, so every node must be upgraded before
anyone renames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No node holds a symlink open, so listing it as an orphan only delays its
free until peers let go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each uses its own image and its own closures, and the hooks they could
touch are only set by sequential tests, which Go runs first. Under
-race with coverage on .68 their wall time fell from 184 s to 91 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattmattox added a commit that referenced this pull request Nov 16, 2026
internal/goclusterfs alone took 407 s of group 1's 8 min, and #175 adds
about 85 s. unit-groups.sh now gives a package with a shard count in
unit-timings.txt that many groups of its own, split by test name and
balanced with unit-test-timings.txt; the other packages share the
rest. CI runs 4 groups: goclusterfs in two halves of about 259 s of
test time each, fsck (197 s), and everything else (190 s). make
test-unit takes the -run regex from UNIT_RUN in the environment.

A split package shows up in two cover profiles, so the coverage summary
now merges blocks (covered if either profile ran them) and builds the
per-package table from the merged profile instead of go test's lines.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit d1068b0 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