Skip to content

fix(daemon,sandbox): follow-ups to the native NFS forced teardown (#644) - #731

Merged
yifanxuaaa merged 1 commit into
layerfs_v2_0_0from
claude/nfs-unmount-644-fixes
Nov 17, 2026
Merged

yifanxuaaa merged 1 commit into
layerfs_v2_0_0from
claude/nfs-unmount-644-fixes

Conversation

@yifanxuaaa

Copy link
Copy Markdown
Contributor

Tier: P1
Risks: risk:kernel risk:security
Docs: docs/architecture/engine/kernel-routes/nfs.md, docs/architecture/engine/daemon/control-calls.md, docs/architecture/api/sdk/workspace.md

Review follow-ups to #644 (layerfs-project#136), which is merged into layerfs_v2_0_0.

What changes

  • The mount table counts as proof only after the helper has exited. A failed or timed-out unmount helper now finishes teardown only if its exit was observed (Ran::ended). On Linux, a plain umount removes the mount from mountinfo before the kernel shuts it down, and that shutdown still flushes the client's writes through the export. Under fix(daemon): 原生 NFS 卸载超时后回收 helper 并完成 teardown(layerfs-project#136) #644, a killed helper stuck in that flush with the mount already gone from the table let teardown stop the server. Now the export is kept as Retained(Detach) and force finishes it.
  • An unmount whose request was never sent no longer overwrites the record. If the exchange fails before sending was attempted (ControlFailure::attempted == false), the sandbox puts back the earlier unmount record, as it already did for a failed connect. Before, a failed --force over a Retained/Detach record wrote forced: true with no stage, so the Workspace could never be forced again. A send that was attempted is still recorded.
  • The macOS mount listing has a deadline. The bounded /sbin/mount reader moves from the macOS driver into the bridge crate as layerfs_bridge::process::mount_table: 500 ms, then the listing is killed and treated as an unreadable table, never as "not mounted". Attach tracking, failed-unmount checks and startup cleanup in the daemon now use it instead of a Command::output() with no time limit.
  • Helpers no longer derives Default. The derived default had a 0 s helper deadline, which would kill every helper immediately. Its wait fields are now private.

Production LOC: 172,703 -> 172,717 (delta +14). Engine +73 (layerfs-bridge +79, where mount_table moved in; layerfs-daemon -6). Control -59 (layerfs-sandbox +6; layerfs-sandbox-backend -65, where mount_table moved out). Core and api unchanged.

Not changed (left for owner decision)

  • Test hooks in production code from fix(daemon): 原生 NFS 卸载超时后回收 helper 并完成 teardown(layerfs-project#136) #644 (ExportServingConfig::mount_table, ExportServing::reaped_helpers, the zero-reap_wait branch) still conflict with engine/AGENTS.md ("fault injection", "test-only public APIs"). Removing them means deleting five helper_deadline tests or building a test setup with real mounts.
  • Helper::lazy still detects a lazy unmount from the helper's own flags, so a wrapper script that runs umount -l reads as non-lazy. An explicit setting on the mounter would fix that.

Checks (macOS, toolchain 1.85.1)

  • cargo clippy -p layerfs-bridge -p layerfs-daemon -p layerfs-sandbox -p layerfs-nfs -p layerfs-sandbox-backend --all-targets -- -D warnings: clean.
  • helper_deadline 9/9, record_codec 5/5, unmount_record 9/9, each run under a 120 s limit.
  • New test a_helper_still_running_never_proves_a_vanished_mount_gone: checked against the old rule (it fails there) and passes with the fix.
  • NOT_RUN: Linux build and tests, a real-mount NFS check, and a dedicated test for restoring the record when nothing was sent (it needs a fake daemon connection).

🤖 Generated with Claude Code

Review follow-ups after merging #644 (layerfs-project#136):

- A failed or timed-out unmount helper proves the client mount gone only
  once its exit has been observed (`Ran::ended`). A plain Linux `umount`
  drops the mountinfo entry before the superblock's shutdown, which flushes
  the client's writes through the export; a killed helper still running
  keeps `Retained(Detach)`, and Force finishes it.
- The sandbox undoes an unmount attempt's record when the exchange failed
  before sending was attempted, as for a call that never connected, so a
  forceable `Retained/Detach` record is not replaced by an unforceable one.
- The macOS mount table is read by one bounded listing, moved from the
  macOS driver to `layerfs_bridge::process::mount_table` (500 ms, then
  killed and read as an unreadable table); the daemon's Attach tracking,
  failed-unmount checks and reclaim now use it instead of an unbounded
  `/sbin/mount`.
- `Helpers` no longer derives `Default` (a zero helper deadline) and keeps
  its waits private.

Tests: new `a_helper_still_running_never_proves_a_vanished_mount_gone`
(fails under the previous rule); `timed_out_helper_when_mount_already_gone_
completes_teardown` now observes the killed helper's exit. No tests deleted.

Production LOC: 172,703 -> 172,717 (delta +14)
  core     39,795 -> 39,795 (0)
  engine   77,204 -> 77,277 (+73)   layerfs-bridge +79 (mount_table moved in), layerfs-daemon -6
  control  49,287 -> 49,228 (-59)   layerfs-sandbox +6, layerfs-sandbox-backend -65 (mount_table moved out)
  api       6,417 -> 6,417 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Method: python3 tools/production_loc.py --json on the parent (39a2513)
and the staged tree, exported with git archive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yifanxuaaa
yifanxuaaa merged commit 346e9fa into layerfs_v2_0_0 Nov 17, 2026
@yifanxuaaa
yifanxuaaa deleted the claude/nfs-unmount-644-fixes branch November 18, 2026 08:04
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