mirror_zfs/cmd/zed
наб 0a51083e39 zed: implement close_from() in terms of /proc/self/fd, if available
/dev/fd on Darwin

Consider the following strace output:
  prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0

Yes, that is well over a million file descriptors!

This reduces the ZED start-up time from "at least a second" to
"instantaneous", and, under strace, from "don't even try" to "usable"
by simple virtue of doing five syscalls instead of over a million;
in most cases the main loop does nothing

Recent Linuxes (5.8+) have close_range(2) for this, but that's an
overoptimisation (and libcs don't have wrappers for it yet)

This is also run by the ZEDLET pre-exec. Compare:
  Finished "all-syslog.sh" eid=13 pid=6717 time=1.027100s exit=0
  Finished "history_event-zfs-list-cacher.sh" eid=13 pid=6718 time=1.046923s exit=0
to
  Finished "all-syslog.sh" eid=12 pid=4834 time=0.001836s exit=0
  Finished "history_event-zfs-list-cacher.sh" eid=12 pid=4835 time=0.001346s exit=0
lol

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11834
2021-04-14 13:19:49 -07:00
..
agents zed: set names for all threads 2021-04-14 13:19:48 -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 cppcheck: integrete cppcheck 2021-01-26 16:12:26 -08:00
zed_conf.c zed: allow limiting concurrent jobs 2021-04-14 13:19:49 -07:00
zed_conf.h zed: allow limiting concurrent jobs 2021-04-14 13:19:49 -07:00
zed_disk_event.c zed: set names for all threads 2021-04-14 13:19:48 -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: allow limiting concurrent jobs 2021-04-14 13:19:49 -07:00
zed_event.h Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00
zed_exec.c zed: print combined system/user time after ZEDLET death 2021-04-14 13:19:49 -07:00
zed_exec.h zed: allow limiting concurrent jobs 2021-04-14 13:19:49 -07:00
zed_file.c zed: implement close_from() in terms of /proc/self/fd, if available 2021-04-14 13:19:49 -07:00
zed_file.h zed: remove unused zed_file_close_on_exec() 2021-04-14 13:19:49 -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: use separate reaper thread and collect ZEDLETs asynchronously 2021-04-14 13:19:49 -07:00
zed.h Replace ZFS on Linux references with OpenZFS 2020-10-08 20:10:13 -07:00