mirror_zfs/cmd/zed
наб 3bd6b0e05a
zed: protect against wait4()/fork() races to the global PID table
This can be very easily triggered by adding a sleep(1) before
the wait4() on a PID-starved system: the reaper thread would wait
for a child before its entry appeared, letting old entries accumulate:

  Invoking "all-debug.sh" eid=3021 pid=391
  Finished "(null)" eid=0 pid=391 time=0.002432s exit=0
  Invoking "all-syslog.sh" eid=3021 pid=336
  Finished "(null)" eid=0 pid=336 time=0.002432s exit=0
  Invoking "history_event-zfs-list-cacher.sh" eid=3021 pid=347
  Invoking "all-debug.sh" eid=3022 pid=349
  Finished "history_event-zfs-list-cacher.sh" eid=3021 pid=347
                                              time=0.001669s exit=0
  Finished "(null)" eid=0 pid=349 time=0.002404s exit=0
  Invoking "all-syslog.sh" eid=3022 pid=370
  Finished "(null)" eid=0 pid=370 time=0.002427s exit=0
  Invoking "history_event-zfs-list-cacher.sh" eid=3022 pid=391
  avl_find(tree, new_node, &where) == NULL
  ASSERT at ../../module/avl/avl.c:641:avl_add()
  Thread 1 "zed" received signal SIGABRT, Aborted.

By employing this wider lock, we atomise [wait, remove] and [fork, add]:
slowing down the reaper thread now just causes some zombies
to accumulate until it can get to them

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 #11963
Closes #11965
2021-05-07 15:10:16 -07:00
..
agents zed: set names for all threads 2021-04-02 16:29:35 -07:00
zed.d zed.d/zed-functions.sh: fix zed_guid_to_pool() on dash 2021-04-30 15:04:41 -07: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 global PID table 2021-05-07 15:10:16 -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