Repository navigation
fix(daemon): end a normal unmount stalled at Join with one forced unmount (#426, #460) - #481
Merged
Merged
Conversation
…ount (#426, #460) A FUSE superblock outlives the daemon's plain detach when another mount namespace holds a copy of the Workspace mount (an engine or VM agent outside the Sandbox). The receive loops then stay blocked, the drain stops at Join, and the entry was kept as Retained with no way out: its owner was boxed as Debug-only evidence, ForceUnmount refused Retained entries, and the session's abort refused once detached. - Retained custody keeps a Join-stalled drain with its real type (Evidence::Stalled). Kept::forceable admits exactly that case: detached, abort control bound, not yet aborted, never forced. - ForceUnmount on such an entry makes one abort write (KernelSession::abort_detached), then reuses the existing force drain, revoke and close. Removing the mount directory also detaches the copy. A refused abort keeps the custody at Join. Plain unmount is unchanged. - The daemon mounts its own fusectl at <overlay dir>/fusectl when /sys/fs/fuse/connections has none (Docker gives containers a read-only /sys without it). The mount is best effort: if it is refused (EPERM in a user namespace) the daemon still starts, logs LAYERFS_DAEMON_ABORT_UNBOUND, and the abort control stays unbound, so forced unmount is refused as before. - workspace.unmount(ws, discard?, force?) in the SDK, `layerfs workspace unmount --force` in the CLI, and the binding return ForceUnmounted. - Docs: forced-teardown and native-mount-session architecture, the agent docs table and the layerfs-js-sdk skill. Tests: - added engine/crates/layerfs-daemon/tests/stalled_unmount.rs: reproduces the stall with `unshare -m` and ends it with one forced unmount. - added engine/crates/layerfs-daemon/tests/control_root.rs: private fusectl mount, reuse, refusal of a leftover directory, and a refused mount in a user namespace leaves no directory. - touched support/mounted.rs, support/host_install.rs (shared_control, once per process), mounted_sqlite_full.rs, and the layerfs-api tests kernel_application.rs, observed_application.rs, r5_1_actual_daemon_commit.rs; the JS fixture adds a forced-unmount case. - deleted: none. Production LOC: 102588 -> 102728 (delta +140) core 38395 -> 38395 (0), engine 61534 -> 61674 (+140), api 2659 -> 2659 (0); reference absent (retired R9c; last counted 65,417 at tree 498dd19). Method: python3 tools/production_loc.py --root on `git archive` of the parent (08ded82) and of the staged tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jiangkoumo
added a commit
to jiangkoumo/layerfs
that referenced
this pull request
Oct 28, 2026
…-AI-Lab#427) Brings main up to 582bc78 (Ephemeral-AI-Lab#488, Ephemeral-AI-Lab#481 forced unmount after a stalled Join, Ephemeral-AI-Lab#479, Ephemeral-AI-Lab#471, Ephemeral-AI-Lab#473, Ephemeral-AI-Lab#445 fs modes, Ephemeral-AI-Lab#475, Ephemeral-AI-Lab#478, Ephemeral-AI-Lab#476 Docker API negotiation, Ephemeral-AI-Lab#396, Ephemeral-AI-Lab#419, Ephemeral-AI-Lab#418, Ephemeral-AI-Lab#415, Ephemeral-AI-Lab#477, Ephemeral-AI-Lab#468). Two conflicts, both from Ephemeral-AI-Lab#481 (forced unmount of a normal unmount stalled at Join): - engine/crates/layerfs-daemon/src/control/force.rs: guard() keeps this branch's ExportKept check (an NFS export kept after a failed teardown answers with its stored custody first) and takes main's comment and its forceable() exception for a retained FUSE session. The non-Linux `let _ = token;` stays removed: ExportKept uses the token on every platform. - engine/crates/layerfs-node/src/workspace.rs: unmount() keeps this branch's per-Workspace unmount lease (repeat a published outcome, drop the admission guard before the daemon call, publish the outcome before cleanup) and takes main's `force` option inside it: forced, one api.unmount(token, true) whose None answer is Unmounted::Closed; otherwise unmount_checked with `discard` as before. Production LOC: first-parent 9478190 108596 -> 109158 (tools/production_loc.py --root .; the delta is main's own changes)
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #426. Refs #460.
Problem
A FUSE superblock outlives the daemon's plain detach when another mount namespace holds a copy of the Workspace mount (an engine or VM agent outside the Sandbox). The receive loops stay blocked, the drain stops at
Join, and the entry was kept asRetainedwith no way out: its owner was boxed as Debug-only evidence,ForceUnmountrefused Retained entries, and the session's abort refused once detached.Change
Evidence::Stalled).Kept::forceableadmits exactly that case: detached, abort control bound, not yet aborted, never forced.ForceUnmounton such an entry makes one abort write (KernelSession::abort_detached), then reuses the existing force drain, revoke and close. Removing the mount directory also detaches the copy. A refused abort keeps the custody atJoin. Plain unmount is unchanged.<overlay dir>/fusectl(/layerfs-local/overlay/fusectlin a Sandbox) when/sys/fs/fuse/connectionshas none. Docker gives containers a read-only/syswithout it. Best effort: if refused (EPERM in a user namespace), the daemon still starts, logsLAYERFS_DAEMON_ABORT_UNBOUND, and forced unmount is refused as before.workspace.unmount(ws, discard?, force?)in the SDK,layerfs workspace unmount --forcein the CLI; the binding returnsForceUnmounted.80-forced-teardown.md,76-native-mount-session.md,api/docs/agent.md, the layerfs-js-sdk skill; corrected the Sandbox SECCOMP comment.Verification (at 888ae70, parent 08ded82)
kernel_application,observed_application,r5_1_actual_daemon_commitin layerfs-api.stalled_unmount: reproduces the stall withunshare -m; plain unmount returns Retained at Join twice; one forced unmount gives abort Written, detach Detached, commit Absent, all loops joined; the connection ends while the copy still runs. 3 s.control_root: private fusectl mount, reuse, leftover directory refused, refused mount in a user namespace leaves no directory.-D warnings(all targets: fuse, daemon, api, sandbox, node) on Linux and macOS; rustfmt clean.timeout 110around a cargo build (exit 124 at 110.8 s, host load average 48); every LayerFS call in that step succeeded. A second depot run is in progress.Tests added:
stalled_unmount.rs,control_root.rs. Touched: supportmounted.rs,host_install.rs,mounted_sqlite_full.rs, the three layerfs-api tests, the JS fixture. Deleted: none.Production LOC: 102588 -> 102728 (delta +140); engine +140, core 0, api 0; reference absent (retired R9c; last counted 65,417 at tree 498dd1917812). Method:
tools/production_loc.py --rootongit archiveof parent and staged tree.🤖 Generated with Claude Code