fs/macos: preserve the inode a rename overwrites#700
Open
acdtrx wants to merge 1 commit into
Open
Conversation
The macOS virtio-fs passthrough addresses inodes by their volfs path
("/.vol/{dev}/{ino}"), which only resolves while the inode still has a
directory entry. A rename that REPLACES an existing target drops that
target's last link, but unlike do_unlink -- which stashes an fd to the
doomed inode in InodeData.unlinked_fd -- rename never preserved the
overwritten inode. Any FUSE op the guest later issues on it then resolves
a dangling volfs path and returns ENOENT.
This breaks the common atomic write-new-then-rename-over pattern when the
guest still holds the old target open: apt/dpkg rewrite /var/lib/dpkg/status
this way while apt holds it open, so apt's final close reports
"Problem closing the file /var/lib/dpkg/status - close (2: No such file or
directory)" even though the install succeeded. It reproduces on any
overlayfs upperdir backed by this server.
Mirror do_unlink: grab an fd to the target before renamex_np (replace case
only -- not RENAME_SWAP/RENAME_EXCL) and hand it to the displaced inode on
success. store_unlinked_fd now reports whether a tracked inode took
ownership so the caller closes the fd otherwise instead of leaking it.
Signed-off-by: Alex NOVAC <acdtrx@gmail.com>
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.
The macOS virtio-fs passthrough addresses inodes by their volfs path ("/.vol/{dev}/{ino}"), which only resolves while the inode still has a directory entry. A rename that REPLACES an existing target drops that target's last link, but unlike do_unlink -- which stashes an fd to the doomed inode in InodeData.unlinked_fd -- rename never preserved the overwritten inode. Any FUSE op the guest later issues on it then resolves a dangling volfs path and returns ENOENT.
This breaks the common atomic write-new-then-rename-over pattern when the guest still holds the old target open: apt/dpkg rewrite /var/lib/dpkg/status this way while apt holds it open, so apt's final close reports "Problem closing the file /var/lib/dpkg/status - close (2: No such file or directory)" even though the install succeeded. It reproduces on any overlayfs upperdir backed by this server.
Mirror do_unlink: grab an fd to the target before renamex_np (replace case only -- not RENAME_SWAP/RENAME_EXCL) and hand it to the displaced inode on success. store_unlinked_fd now reports whether a tracked inode took ownership so the caller closes the fd otherwise instead of leaking it.
Built on macOS/aarch64 and verified in a downstream consumer — apt-based setup recipes that previously failed at dpkg's close now succeed.