mirror_zfs/cmd/zed
наб f9bece92e2
zed: protect against wait4()/fork() races to the launched process tree
As soon as wait4() returns, fork() can immediately return with the same
PID, and race to lock _launched_processes_lock, then try to add the new
(duplicate) PID to _launched_processes, which asserts

By locking before wait4(), we ensure, that, given that same
unfortunate scheduling, _launched_processes_lock cannot be locked by the
spawner before we pop the process in the reaper, and only afterward will
it be added

This moves where the reaper idles when there are children from the
wait4() to the pause(), locking for the duration of that single syscall
in both the no-children and running-children cases; the impact of this
is one to two syscalls (depending on _launched_processes_lock state)
per loop

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11924
Closes #11928
2021-04-22 17:49:21 -07:00
..
agents zed: set names for all threads 2021-04-02 16:29:35 -07:00
zed.d ZED/zfs-list-cacher.sh: don't exit on ignored event type 2020-12-18 09:34:10 -08:00
.gitignore Initial implementation of zed (ZFS Event Daemon) 2014-04-02 13:10:03 -07:00
Makefile.am libspl: implement atomics in terms of atomics 2021-04-18 22:13:24 -07:00
zed_conf.c zed: set O_CLOEXEC on persistent fds, remove closefrom() from pre-exec 2021-04-15 13:46:02 -07:00
zed_conf.h zed: don't malloc() global zed_conf instance, optimise zed_conf layout 2021-04-11 15:27:30 -07:00
zed_disk_event.c zed: set names for all threads 2021-04-02 16:29:35 -07:00
zed_disk_event.h Bring over illumos ZFS FMA logic -- phase 1 2016-09-01 11:39:45 -07:00
zed_event.c zed: set O_CLOEXEC on persistent fds, remove closefrom() from pre-exec 2021-04-15 13:46:02 -07:00
zed_event.h Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00
zed_exec.c zed: protect against wait4()/fork() races to the launched process tree 2021-04-22 17:49:21 -07:00
zed_exec.h zed: allow limiting concurrent jobs 2021-04-02 16:30:53 -07:00
zed_file.c zed: only go up to current limit in close_from() fallback 2021-04-07 14:52:51 -07:00
zed_file.h zed: replace zed_file_write_n() with write(2), purge it 2021-04-07 14:52:30 -07:00
zed_log.c Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00
zed_log.h Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00
zed_strings.c Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00
zed_strings.h Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00
zed.c zed: don't malloc() global zed_conf instance, optimise zed_conf layout 2021-04-11 15:27:30 -07:00
zed.h zed: remove zed_conf::{min,max}_events and ZED_{MIN,MAX}_EVENTS 2021-04-11 15:27:25 -07:00