Skip to content

Kernel routes: ESTALE for dropped serials, checked parent index, full readdir pages (#7, #17, #12) - #763

Merged
yifanxuaaa merged 1 commit into
layerfs_v2_0_0from
claude/v2-kernel-stale-fixes-eecc17
Nov 23, 2026
Merged

yifanxuaaa merged 1 commit into
layerfs_v2_0_0from
claude/v2-kernel-stale-fixes-eecc17

Conversation

@yifanxuaaa

Copy link
Copy Markdown
Contributor

Fixes three kernel-route findings from the LayerFS 2.0.0 overlay review (#7, #17, #12). Each one was confirmed in code, and each new test fails on the old code (macOS for the workspace tests, Linux FUSE for the daemon test).

#7: a dropped serial gives ESTALE, not a terminal FUSE mount

  • Before: a merge can drop a serial the kernel still holds (a cwd or an open fd). GETATTR on it hit InvalidRecord("bound inode is absent"). The failure was retained, and work.terminal = true ended the whole mount.
  • Now: this case answers OverlayError::Stale (Eval::held). It covers any request that names a serial on its own: GETATTR, OPEN, OPENDIR, a LOOKUP's directory, READ, READLINK, and READDIR on an open handle. The serial has no local row and no base inode.
  • Mount ports: ports::stale accepts only two shapes, the visit's own Stale and the Workspace Stale from a window finished outside the owner. It never looks through wrappers, so an uncertain, retained or owner failure stays retained.
  • FUSE: answers ESTALE for that request alone, retains nothing, and keeps serving.
  • NFS: already maps an engine Stale to NFS3ERR_STALE. No NFS file is touched.
  • Still terminal: a name bound to an absent inode, and count underflow.
  • Unchanged: mutations already refuse with Missing.

#17: the parent index is checked against the current view

  • Finding confirmed: the post-merge invalidation does not force a re-LOOKUP. A held cwd or fd starts its walk at the held dentry, so rename(/x, y/x2) could still make a cycle after a merge moved y under x.
  • Index rows: each row now records the name it was written under. The writers are LOOKUP, MKDIR, a READDIRPLUS handle and renames, now including renames in place.
  • Rename check: a kernel directory rename checks every link from the destination up to the root before the cycle check. Each parent must still bind that name to that child.
  • Stale link: a link that no longer holds is refused with AncestryMismatch (EINVAL). The next LOOKUP records the directory's current place.
  • Ownership: install.rs and generation.rs (owned by v2-commit-path) are not touched.

#12: readdir byte budget

  • Budget: now PAGE_ROWS * (NAME_LENGTH_BYTES + DIRECTORY_LEAF_SERIAL_BYTES + MAXIMUM_NAME_BYTES), replacing * 264.
  • Merge stop: whenever the base page has a continuation, the merge stops at the base's last fetched name.

Behaviour changes to note

  • LOOKUP inside a dropped directory, and READ of a dropped file, now answer ESTALE instead of ENOENT. On NFS this is NFS3ERR_STALE instead of NOENT or IO.
  • A cookie-offset Stale raised inside the owner's directory visit still reaches FUSE wrapped in an owner error. It is still retained, so that pre-existing case is unchanged.

Tests

Test Covers
layerfs-workspace kernel_stale (new) #7: GETATTR, LOOKUP, OPEN, OPENDIR, READ and READDIR on dropped serials, and the mount still serves. #17: a stale link is refused, refreshed by LOOKUP, then refused as a cycle; legal moves still work, including after a rename in place. #12: 1,100 base names of 255 bytes plus local names, each listed once through SDK list and through READDIR paging
layerfs-mount-ports stale (new) The classifier accepts only the two shapes
layerfs-daemon stale_handles (new, Linux FUSE) ESTALE through a held cwd that a merge dropped, with the mount still serving and retained == 0. No cycle through a held cwd that a merge moved
kernel_data (changed) A kernel-held inode with no row and no base inode now expects Stale instead of Missing. The contract changed; the assertion is not weakened

Checks run

  • macOS --no-run builds: all 63 test binaries of layerfs-workspace, overlay, mount-ports and nfs build and pass.
  • macOS clippy: -D warnings is clean for workspace, overlay, mount-ports, nfs, daemon and fuse.
  • rustfmt: clean on every changed file.
  • Linux FUSE tests (built from the final bytes, one container each, 120 s cap, /dev/fuse, SYS_ADMIN, apparmor=unconfined): stale_handles, negative_entries, kernel_mutation, kernel_coherence, kernel_custody, mounted_install, mounted_listing_reads, mounted_cycles, mounted_links and mounted_rewind all pass. The fuse attributes and requests tests and mount-ports stale pass on Linux too.
  • Regression proof: with the old semantics restored, kernel_stale fails 3/3 on macOS. stale_handles fails 2/2 on Linux: stat . gives EIO (the mount went terminal), and mv makes the cycle.

Gaps

  • Linux clippy not run: the Linux build image has no clippy component. The FUSE request/ module is Linux-only, so clippy did not check it. The Linux rustc build had 0 warnings.
  • Daemon suite: only the mount targets above were run on Linux, not the full daemon suite.
  • NFS mounted route: no NFS test was added, and the NFS export was not run against a real mount.

Production LOC: 206,537 -> 206,676 (delta +139)
core 40,988 -> 40,988 (0)
engine 95,899 -> 96,038 (+139) layerfs-fuse +6, layerfs-mount-ports +25, layerfs-overlay +61, layerfs-workspace +47
control 59,325 -> 59,325 (0)
api 10,325 -> 10,325 (0)
reference absent (retired R9c; last counted 65,417 at tree 498dd1917812)
Method: tools/production_loc.py --detail on parent 343c59b and the staged tree

🤖 Generated with Claude Code

… readdir pages

Three fixes from the 2.0.0 overlay review, each confirmed in code and by a
test that fails on the old code.

#7 A merge can drop a serial the kernel still holds (a cwd, an open
descriptor). GETATTR on it hit InvalidRecord("bound inode is absent"),
was retained, and made the whole FUSE mount terminal. A serial the kernel
names by itself (GETATTR, OPEN, OPENDIR, a LOOKUP's directory, READ,
READLINK, READDIR of an open handle) that no local row or base inode has
is now OverlayError::Stale (Eval::held). Mount ports classify only the
engine's own Stale answer as stale (ports::stale; no wrapper is looked
through), and FUSE answers ESTALE for that request alone without
retaining it. NFS already maps an engine Stale to NFS3ERR_STALE. A name
bound to an absent inode and count underflow stay InvalidRecord and
terminal. Mutations are unchanged: they already refuse Missing.

#17 The kernel parent index is the only evidence the rename cycle check
has, and an install never rewrites it. Invalidation does not help: a
held cwd or descriptor needs no path walk. Each index row now carries
the name it was recorded under, a rename in place updates it too, and a
kernel rename of a directory checks every link from the destination to
the root against the current view before its cycle check. A link that no
longer holds is AncestryMismatch (EINVAL); the next LOOKUP records the
directory's current place. install.rs and generation.rs are untouched.

#12 The base page budget is derived from the reader's row charge
(NAME_LENGTH_BYTES + DIRECTORY_LEAF_SERIAL_BYTES + 255) instead of 264,
and the merge stops at the base's last fetched name whenever the base
page has a continuation, so a short page can never skip names.

Tests: workspace kernel_stale (all three), mount-ports stale (classifier),
daemon stale_handles (Linux FUSE: ESTALE through a held cwd with the
mount still serving; no cycle through a held cwd the merge moved). The
kernel_data case "an inode the kernel holds that neither the base nor a
local row has" now expects Stale instead of Missing: the contract
changed, the assertion is not weakened. No test deleted.

Production LOC: 206,537 -> 206,676 (delta +139)
  core     40,988 -> 40,988 (0)
  engine   95,899 -> 96,038 (+139)  layerfs-fuse +6, layerfs-mount-ports +25, layerfs-overlay +61, layerfs-workspace +47
  control  59,325 -> 59,325 (0)
  api      10,325 -> 10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent 343c59b and the staged tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yifanxuaaa
yifanxuaaa merged commit bb0615c into layerfs_v2_0_0 Nov 23, 2026
2 checks passed
@yifanxuaaa
yifanxuaaa deleted the claude/v2-kernel-stale-fixes-eecc17 branch November 23, 2026 08:15
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