zinject: Introduce waiting on injection events #17832
Open
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.
This is useful for reproducing races during the sync pipeline.
See #16025 (comment) for use in the repro case for
free_children
panic in #16025.Motivation and Context
Blocking in the kernel on injection events allows reliably hitting race windows created by
zinject
.Description
Adds a new ioctl
ZFS_IOC_WAIT_INJECT
to wait for inject events,libzfs
marshalling call, and azinject
command.Callers must have admin privileges to use wait on injection events.
The kernel stores a state of the number of events so far, and callers pass in this state to block until another event occurs. This pattern allows the waiter to obtain the state before triggering the inject event to reliably wake exactly when the injection event has fired.
I'm open to feedback on the kernel code as well as the ioctl, API, and zinject command syntax.
How Has This Been Tested?
ZTS and by running the repro case from 16025.
Types of changes
Checklist:
Signed-off-by
.