Repository navigation
Move a mounted workspace onto a newer source in place - #166
Conversation
sandfs update on a mounted workspace no longer asks for an unmount. The command finds the newer source, then asks the process serving the mount to move it: that process saves every change with requests held off, moves the workspace on disk as when unmounted, serves the moved workspace from then on and tells the kernel to forget the names, attributes, pages and listings that changed. Inodes stay with their paths, so a shell in one of the mount's folders and files left open carry on; a name that went or changed kind is removed as if unlinked, still readable through handles left open. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 043b8a0735
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… copy while it may be read macOS's NFS client keeps a file's attributes and pages for up to a minute without asking, opens included, so files an update changed kept reading as before. On NFS, a file that may have changed now gets a new inode, its folder a new time, and folders' attributes are asked for again after a second (acdirmin/acdirmax 1): once the client looks the name up again it finds the new inode, with nothing cached. update waits that second before returning. A mount that moved off a copy of a folder holds the copy (a locked .held file next to it) until the mount ends, so files of it left open still read; copies are deleted only once nothing holds them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq
An NFS client never says when it is done with an inode, so removed files go at once there. A file left open across an in-place update (removed, or renumbered because it may have changed) then failed to read. Inodes a replace takes off their names now stay readable until the next one. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aececcf621
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…hard link - A served workspace's new saved state takes over the old one's objects (Saved::take_over), so a file left open across an in-place update keeps reading its object after later saves. - Another name of an inode an update takes off its name stays on it when the newer workspace still links them, and is looked up anew when it doesn't, so writes never go to a removed inode. - A mounted update holds the shared source lock until the mount has recorded the new source, so sandfs clean can't delete a copy frozen for it in between. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq
sandfs update NAME [SOURCE]used to refuse a mounted workspace. Now a mounted workspace moves in place, so a shell or agent working inside the folder carries on and reads the newer files from then on. Graft'ssyncneeds this.How it works
Finding the source. The command finds the newer source itself, so a relative path means what it says, and freezes a new copy for a fork of a plain folder. It then sends the result to the home's mount process over its socket: a new
updatefield on the request, withUpdatedin the reply.Moving the workspace. The mount process keeps a list of the mounts it serves (
server.rs). For the named mount,Shared::replace:update::apply, the same on-disk move as for an unmounted workspace, now split out ofmove_onto;What the kernel forgets (Linux FUSE), worked out by
Inner::replace:.git. For a folder, everything the kernel knows./proc/PID/cwd).macOS (NFS). The NFS client can't be told to forget anything, and macOS doesn't revalidate even on open:
nfs_vnop_openuses cached attributes, up toacregmax= 60 s. The first CI run showed stale reads, so on NFS (Inner::renumber_changed):acdirmin/acdirmax/acrootdirmin/acrootdirmax=1);updatewaits that second before returning.The client's next lookup sees the folder changed, drops its name cache and finds the new handle, which has nothing cached. Files keep the default attribute times.
An NFS client never says when it is done with an inode, so sandfs normally drops a removed one at once. An inode that an update takes off its name now stays readable until the next update (
Inner::moved_off), so a file left open across a sync still reads as it was, as on Linux.Frozen folder copies. A mount that moves off a copy of a folder holds the old copy (a locked
COPY.heldfile next to it) until the mount ends, so files of it left open still read.remove_unused_copiesskips held copies, and the mount deletes them when it ends.Mounts this can't move. A mount served by a process that can't move it, such as
mount --foreground, still gets "unmount it first".Tests
update_moves_a_mounted_workspace_in_place:sub/, a file is held open, and the kernel has cached names, sizes, a missing name and listings.updatewhile mounted: everything reads as upstream, the workspace's own change stays, andgit statusandchangesare right.update_moves_a_mounted_folder_workspace_onto_another_folder.a_fork_of_a_plain_folder_keeps_it_as_it_wasnow does a mounted update with a file left open that the folder removed, and checks the old copy is held. This test runs only on a disk that clones files; I ran it on a btrfs loop.a_newer_workspace_keeps_inodes_and_names_what_went_staleanda_newer_workspace_renumbers_files_that_may_have_changed_where_asked. The second also covers the NFS keep-until-next-update rule.cargo fmt,clippy -D warnings(Linux andaarch64-apple-darwin) and the workspace tests pass on Linux.sandfs-bench's smoke test fails when its temp folder is on the btrfs loop and passes on ext4, so that failure isn't from this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01CboUL9BU7nvDEZKfQBSkkq