Fix race in libzfs_run_process_impl #16801
Open
+1
−1
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.
When replacing a disk, a child process is forked to run a script called
zfs_prepare_disk
(which can be useful for disk firmware update or health check). By default this script does nothing - it simply returns 0.When testing on a virtual machine, it returns so fast that the parent misses it: when checking, the child already exited. As waitpid returns -1, the parent incorrectly assume that the child process had an error or was killed. This, in turn, leaves the newly added disk in REMOVED or UNAVAIL status rather than completing the replace process.
As child should be inspected via
waitpid
status flag and the relative macros, this patch remove the check aroundwaitpid
return code.NOTE: the issue mostly affects
zed
autoreplacement, while plainzpool replace
from command line seems fine.Motivation and Context
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.