Repository navigation
Conversation
`NodeDirectory::insertMove` renamed the file on the host but left the host path cached in the moved file, and in everything already looked up below a moved directory, pointing at the old name. Later operations then used the old path: they failed, or reached a different file created under the old name. Rewrite the cached host path of the moved file and of every loaded file below it, holding their locks (each before its children) across the host's rename. Moving a symlink no longer casts it to a directory, and moving a mount point of another backend now fails with EBUSY, as on Linux and in the JS file system, instead of being treated as a Node file. Fixes: emscripten-core#27824
This branch has not been deployed
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.
NodeDirectory::insertMoverenamed the file on the host but left the host path cached in the movedFile, and in everything already looked up below a moved directory, pointing at the old name. Later operations then failed, or read and wrote a different file created under the old name.insertMovenow rewrites the cached host path of the moved file and of every loaded file below it, which it finds through a new protectedDirectory::getLoadedChildren(). It holds their locks, parents first, across the host's rename, so no operation sees a path change under it. It also stops casting a moved symlink to a directory, and returnsEBUSYfor a mount point of another backend (as Linux and the JS file system'sFS.renamedo) instead of treating it as a Node file.Locking and #27684: the new locks are only taken downward, after
renameat's ancestor walk, in the same parent-before-child order lookups use. So this neither depends on #27685 nor conflicts with it.Test:
other.test_wasmfs_rename(memory,NODEFSandNODERAWFS) renames a file and reuses its old name, renames a directory with an open file, looked-up files and a symlink inside, moves a symlink, and checksEBUSYfor a mount point. The Node variants fail onmainand pass with this change. The test is single-threaded, so it doesn't exercise the locking.Fixes: #27824