lib/vfscore: Reorder locks in *at syscalls #951
Closed
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.
Description of changes
*at syscalls are implemented in Unikraft in two stages: (1) build the full target path relative to the supplied dirfd, and (2) delegate to the regular syscall. Previously these syscalls held the lock on the dirfd vnode throughout steps (1) and (2); however, the sub-syscalls often need to acquire the same lock (along with perhaps others), causing double-lock asserts to trigger.
This commit changes this logic to only hold the vnode lock during step (1) and release it immediately before (2). While this relaxes the previous atomicity guarantees somewhat, holding the vnode lock on dirfd only prevented concurrent changes to first-generation descendents, and unorthogonal and arguably unexpected behavior. The useful purpose of holding the dirfd lock is to ensure we build a full path that was (at one point in time) valid, with the sub-syscalls implementing their own atomicity guarantees as per usual.
Prerequisite checklist
checkpatch.uk
on your commit series before opening this PR;Base target
Additional configuration
Test with using any of the
openat
,mkdirat
,fstatat
,faccessat
syscalls; staging fails with a lock assertion, fixed code should behave as expected.