aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zed/zed.c
Commit message (Collapse)AuthorAgeFilesLines
* Obtain advisory lock on ZED PID fileChris Dunlap2014-10-061-1/+2
| | | | | | | | | | | | | | | | | ZED uses an advisory lock on its state file to protect against multiple instances running concurrently. However, work is planned to move this state information into the kernel, and ZED will still need to protect against starting multiple instances. This commit adds an advisory lock on the PID file to protect against starting multiple instances. A lock failure can be overridden with the "-f" (force) command-line option. The advisory lock on the state file is being retained for as long as the state information is stored in the state file. Signed-off-by: Chris Dunlap <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #2756
* Remove reverse indentation from zed comments.Chris Dunlap2014-09-221-7/+11
| | | | | | | | | Remove all occurrences of reverse indentation from zed comments for consistency within the project code base. Signed-off-by: Chris Dunlap <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2695
* Fix race condition with zed pidfile creationChris Dunlap2014-09-021-20/+73
| | | | | | | | | | | | | | | | | | | When the zed is started as a forking daemon (by default), a race-condition exists where the parent process can terminate before the pidfile has been created by the grandchild process. When invoked as a Type=forking systemd service, this can result in the following: systemd[1]: Starting ZFS Event Daemon (zed)... systemd[1]: PID file /var/run/zed.pid not readable (yet?) after start. This commit adds a daemonize pipe to allow the grandchild process to signal the parent process that initialization is complete (and the pidfile has been created). The parent process will wait for this notification before exiting. Signed-off-by: Chris Dunlap <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #2252
* Replace check for _POSIX_MEMLOCK w/ HAVE_MLOCKALLChris Dunlap2014-04-021-5/+4
| | | | | | | | | | | | | | | | | | | zed supports a '-M' cmdline opt to lock all pages in memory via mlockall(). The _POSIX_MEMLOCK define is checked to determine whether this function is supported. The current test assumes mlockall() is supported if _POSIX_MEMLOCK is non-zero. However, this test is insufficient according to mlock(2) and sysconf(3). If _POSIX_MEMLOCK is -1, mlockall() is not supported; but if _POSIX_MEMLOCK is 0, availability must be checked at runtime. This commit adds an autoconf check for mlockall() to user.m4. The zed code block for mlockall() is now guarded with a test for HAVE_MLOCKALL. If defined, mlockall() will be called and its runtime availability checked via its return value. Signed-off-by: Chris Dunlap <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #2
* Initial implementation of zed (ZFS Event Daemon)Chris Dunlap2014-04-021-0/+236
zed monitors ZFS events. When a zevent is posted, zed will run any scripts that have been enabled for the corresponding zevent class. Multiple scripts may be invoked for a given zevent. The zevent nvpairs are passed to the scripts as environment variables. Events are processed synchronously by the single thread, and there is no maximum timeout for script execution. Consequently, a misbehaving script can delay (or forever block) the processing of subsequent zevents. Plans are to address this in future commits. Initial scripts have been developed to log events to syslog and send email in response to checksum/data/io errors and resilver.finish/scrub.finish events. By default, email will only be sent if the ZED_EMAIL variable is configured in zed.rc (which is serving as a config file of sorts until a proper configuration file is implemented). Signed-off-by: Chris Dunlap <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #2