Skip to content

Before Close, a listing and Stat describe every name of a file as the file, under the name asked - #307

Open
closer-claudio wants to merge 2 commits into
mainfrom
claudio/20261123-linked-name-info
Open

closer-claudio wants to merge 2 commits into
mainfrom
claudio/20261123-linked-name-info

Conversation

@closer-claudio

Copy link
Copy Markdown

This is the second layer of a stack: it sits on #305, whose commit shows in the diff until that one merges. Its own commit is "Before Close, every name of a file answers with the file, under that name".

The defect

A file's second name is an entry of its own in a Writer, pointing at the entry that holds the file and carrying only a mode: the one the file had when the name was linked.

  • Stat and Open followed the pointer and handed out the holding entry, whose path is the first name's. Stat of a second name, and the info of a file opened under it, were named after the first name.
  • A listing handed out the second name's own entry. Its info said no bytes, the mode of the day it was linked, and no time.

For /d/a of 12 bytes linked as /d/b and then made 0600: the listing's b said 0 bytes and 0644 where Stat("/d/b") said 12 and 0600, and Stat("/d/b").Name() was a.

The image written at Close was right, and so is what a reader of it answers. The Writer's documentation says an entry reads back before Close as it will after.

The change

An info carries the name it was asked or listed under, and describes the file: for a second name, the entry it points at. A file opened under a name is named so, in its info and in the error of a Close that fails.

What a consumer sees

Before Close, for a file with more than one name:

  • the entry a listing gives for any of its names has the file's size, mode, owner, time, link count and attributes;
  • Stat(name).Name() and the name of the info of a file opened as name are that name.

Nothing changes for a file with one name, nor in any image written.

Evidence

TestContractAFilesSecondNameReadsAsTheFile: a file under two names, its mode, owner, time and an attribute set after the second name was linked, through either name. The listing's entry, Stat and the open file's info of each name say the same, each under its own name, before Close and from the image after it. Before the change the three ways disagree for the second name.

With the second name's own fields kept, with the open file named as the first name, or with the name read from the holding entry, the test fails.

just lint and just test pass.

For #306

closer-claudio and others added 2 commits November 23, 2026 01:05
…g of it

A name removed from a Writer stayed in its directory's list of children,
marked removed, for the Writer's life: nothing took it out, and every
reader of the list stepped over it. A name made and removed over and
over grew the Writer by an entry each time (300,000 rounds: about
90 MiB), and every pass over the directory walked them all.

Now an entry knows its place among its parent's children and leaves the
list when its name is removed: the last child takes its place, the
list's order being no one's (ReadDir and Close sort). A children list
holds no removed entry, so the readers that stepped over them no longer
look.

Two walks remove entries of the list they are walking, where taking one
out would move the last child under the walk. They drop the names and
settle the list themselves once done: RemoveAll and a directory that a
copy turns into a file empty it; a marker of a merged layer sifts out
what it removed and gives the entries it spared their new places.

An entry written over in place by a later copy, and the name that takes
over a removed first name's file, are copies of another entry: each
keeps its own place.

The list of a file's other names keeps a removed name until the file's
last other name goes or a handover passes over it, and was then all
that held the entry: it drops the removed once they outnumber the
live, at a cost each removal has paid for.

What is not given back: the capacity a map and a list keep of the most
they held at once (300,000 names made and then removed: 16 MiB, where
the names themselves were 108).

Removal costs what it did: BenchmarkPerfRemoveLinkedNames and
BenchmarkPerfRemoveNamesOfOneInode on the commit before and here, two
runs each, alternated: every pair of ranges overlaps (16,000 linked
files 1.2 to 1.4 ms and 1.1 to 2.0 ms; 80,000 names of one file removed
one at a time 7.1 to 10.1 ms and 9.9 to 11.5 ms).

Tests, in contract_writer_removal_test.go.
TestContractWriterHoldsNothingOfARemovedName: the heap in use after
300,000 rounds of a directory made and removed, of a file's other name
made and removed beside one that stays, of a directory removed with
what it holds, each under 8 MiB, and after 300,000 names made and then
each removed, under 32. All four fail before the change (89, 92, 270
and 108 MiB).
TestContractWriterLeavesWhatItsCallsLeave: 600 random sequences of
Create, Mkdir, Link, Remove and RemoveAll against a model of the tree:
the image holds the model's names, each file's content, one inode for
the names that share one, the link counts that follow. It passes before
the change: the behaviour is the same.
TestContractRemovingWhatACopyPlaced: a name removed after a copy wrote
over it, after its layer's opaque marker spared it, a spared directory
whose earlier entries the marker took, and a name that stopped being a
directory.
Broken twelve ways, each fails a test: the heir or the overwritten
entry losing its place, the moved sibling keeping its old one, no new
place after the sift, no sift, a removed directory keeping its list, no
detach, a new child without a place, the freed slot not cleared, the
alias list unbounded, a marker dropping its own layer, a directory
with entries removed.

For #297

Signed-off-by: closer-claudio <claudio@farcloser.world>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…name

A file's second name is an entry of its own in a Writer, pointing at
the entry that holds the file and carrying only a mode, the one the
file had when the name was linked. Stat and Open followed the pointer
and handed out the holding entry, whose path is the first name's: Stat
of a second name, and the info of a file opened under it, were named
after the first. A listing handed out the second name's own entry: its
info said no bytes, the mode of the day it was linked, and no time.

For /d/a of 12 bytes linked as /d/b and then made 0600: the listing's
b said 0 bytes and 0644 where Stat("/d/b") said 12 and 0600, and
Stat("/d/b").Name() was "a". The image written at Close was right, and
so was what a reader of it answers; the Writer's documentation says an
entry reads back before Close as it will after.

An info now carries the name it was asked or listed under, and
describes the file: for a second name, the entry it points at. A file
opened under a name is named so, in its info and in the error of a
Close that fails.

TestContractAFilesSecondNameReadsAsTheFile: a file under two names, its
mode, owner, time and an attribute set after the second name was
linked, through either name: the listing's entry, Stat and the open
file's info of each name say the same, each under its own name, before
Close and from the image after it. Before the change the three ways
disagree for the second name. With the second name's own fields kept,
with the open file named as the first name, or with the name read from
the holding entry, it fails.

For #306

Signed-off-by: closer-claudio <claudio@farcloser.world>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@closer-claudio

Copy link
Copy Markdown
Author

Reviewed at 7f35dc6

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