aboutsummaryrefslogtreecommitdiff
path: root/sbin/hastd/hastd.c
Commit message (Collapse)AuthorAgeFilesLines
* hastd(8) assumes it has no extra file descriptors openedEugene Grosbein2020-11-291-0/+1
| | | | | | | | | | and aborts otherwise, so call closefrom() early. PR: 227461 MFC after: 2 weeks Notes: svn path=/head/; revision=368148
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* Use MAX() from sys/param.h.Marcelo Araujo2016-04-211-3/+3
| | | | | | | MFC after: 2 weeks. Notes: svn path=/head/; revision=298393
* Check remote protocol version only for the first connection (when itMikolaj Golub2013-12-101-6/+6
| | | | | | | | | | | | is actually sent by the remote node). Otherwise it generated confusing "Negotiated protocol version 1" debug messages when processing the second connection. MFC after: 2 weeks Notes: svn path=/head/; revision=259196
* - Add support for 'memsync' mode. This is the fastest replication mode that'sPawel Jakub Dawidek2013-02-171-2/+19
| | | | | | | | | | | | | why it will now be the default. - Bump protocol version to 2 and add backward compatibility for version 1. - Allow to specify hosts by kern.hostid as well (in addition to hostname and kern.hostuuid) in configuration file. Sponsored by: Panzura Tested by: trociny Notes: svn path=/head/; revision=246922
* If hastd is invoked with "-P pidfile" option always create pidfileMikolaj Golub2012-03-291-5/+7
| | | | | | | | | | | | | | regardless of whether -F (foreground) option is set or not. Also, if -P option is specified, ignore pidfile setting from configuration not only on start but on reload too. This fixes the issue when for hastd run with -P option reload caused the pidfile change. Reviewed by: pjd MFC after: 1 week Notes: svn path=/head/; revision=233679
* Free memory that won't be used in child.Pawel Jakub Dawidek2012-01-221-3/+7
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=230457
* - Fix a bug where pidfile was removed in SIGHUP when it hasn't changed inPawel Jakub Dawidek2012-01-101-4/+8
| | | | | | | | | | configuration file. - Log the fact that pidfile has changed. MFC after: 3 days Notes: svn path=/head/; revision=229946
* For functions that return -1 on failure check exactly for -1 and not forPawel Jakub Dawidek2012-01-101-20/+20
| | | | | | | | | any negative number. MFC after: 3 days Notes: svn path=/head/; revision=229945
* Don't touch pidfiles when running in foreground. Before that change wePawel Jakub Dawidek2012-01-101-11/+19
| | | | | | | | | would create an empty pidfile on start and check if it changed on SIGHUP. MFC after: 3 days Notes: svn path=/head/; revision=229944
* Spelling fixes for sbin/Ulrich Spörlein2012-01-071-1/+1
| | | | Notes: svn path=/head/; revision=229778
* Allow to specify pidfile in HAST configuration file.Pawel Jakub Dawidek2011-10-171-13/+61
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=226463
* When path to the configuration file is relative, obtain full path,Pawel Jakub Dawidek2011-10-171-0/+16
| | | | | | | | | | so we can always find the file, even after daemonizing and changing working directory to /. MFC after: 1 week Notes: svn path=/head/; revision=226461
* After every activemap change flush disk's write cache, so that writePawel Jakub Dawidek2011-09-281-5/+16
| | | | | | | | | | | | | | | reordering won't make the actual write to be committed before marking the coresponding extent as dirty. It can be disabled in configuration file. If BIO_FLUSH is not supported by the underlying file system we log a warning and never send BIO_FLUSH again to that GEOM provider. MFC after: 3 days Notes: svn path=/head/; revision=225830
* In preparation for IPv6 support allow to specify multiple addresses toPawel Jakub Dawidek2011-05-191-36/+97
| | | | | | | | | listen on. MFC after: 3 weeks Notes: svn path=/head/; revision=222108
* Rename HASTCTL_ defines, which are used for conversion between mainMikolaj Golub2011-04-261-1/+1
| | | | | | | | | | | | | hastd process and workers, remove unused one and set different range of numbers. This is done in order not to confuse them with HASTCTL_CMD defines, used for conversation between hastctl and hastd, and to avoid bugs like the one fixed in in r221075. Approved by: pjd (mentor) MFC after: 1 week Notes: svn path=/head/; revision=221076
* Correct comment.Pawel Jakub Dawidek2011-04-201-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=220899
* When we become primary, we connect to the remote and expect it to be inPawel Jakub Dawidek2011-04-201-0/+7
| | | | | | | | | | | | | secondary role. It is possible that the remote node is primary, but only because there was a role change and it didn't finish cleaning up (unmounting file systems, etc.). If we detect such situation, wait for the remote node to switch the role to secondary before accepting I/Os. If we don't wait for it in that case, we will most likely cause split-brain. MFC after: 1 week Notes: svn path=/head/; revision=220898
* If we act in different role than requested by the remote node, log itPawel Jakub Dawidek2011-04-201-1/+1
| | | | | | | | | as a warning and not an error. MFC after: 1 week Notes: svn path=/head/; revision=220890
* Don't create socketpair for connection forwarding between parent and secondary.Pawel Jakub Dawidek2011-03-231-8/+28
| | | | | | | | | Secondary doesn't need to connect anywhere. MFC after: 1 week Notes: svn path=/head/; revision=219900
* White space cleanups.Pawel Jakub Dawidek2011-03-221-6/+6
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=219864
* Before handling any events on descriptors check signals so we can updatePawel Jakub Dawidek2011-03-211-28/+43
| | | | | | | | | | | | | | | | | our info about worker processes if any of them was terminated in the meantime. This fixes the problem with 'hastctl status' running from a hook called on split-brain: 1. Secondary calls a hooks and terminates. 2. Hook asks for resource status via 'hastctl status'. 3. The main hastd handles the status request by sending it to the secondary worker who is already dead, but because signals weren't checked yet he doesn't know that and we get EPIPE. MFC after: 1 week Notes: svn path=/head/; revision=219837
* In hast.conf we define the other node's address in 'remote' variable.Pawel Jakub Dawidek2011-03-211-1/+9
| | | | | | | | | | | | | | | | | | | | | This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. MFC after: 1 week Notes: svn path=/head/; revision=219818
* When creating connection on behalf of primary worker, set pjdlog prefixPawel Jakub Dawidek2011-03-211-0/+4
| | | | | | | | | | to resource name and role, so that any logs related to that can be identified properly. MFC after: 1 week Notes: svn path=/head/; revision=219814
* If there is any traffic on one of out descriptors, we were not checking forPawel Jakub Dawidek2011-03-211-2/+14
| | | | | | | | | | long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. MFC after: 1 week Notes: svn path=/head/; revision=219813
* Allow to compress on-the-wire data using two algorithms:Pawel Jakub Dawidek2011-03-061-0/+6
| | | | | | | | | | | | | | - HOLE - it simply turns all-zero blocks into few bytes header; it is extremely fast, so it is turned on by default; it is mostly intended to speed up initial synchronization where we expect many zeros; - LZF - very fast algorithm by Marc Alexander Lehmann, which shows very decent compression ratio and has BSD license. MFC after: 2 weeks Notes: svn path=/head/; revision=219354
* Allow to checksum on-the-wire data using either CRC32 or SHA256.Pawel Jakub Dawidek2011-03-061-1/+7
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=219351
* Now that we break the loop on fstat(2) failure we no longer need to satisfyPawel Jakub Dawidek2011-02-061-2/+0
| | | | | | | | | gcc's imperfections. MFC after: 1 week Notes: svn path=/head/; revision=218376
* Add (void) cast before snprintf(3)s for which we are not interested in returnPawel Jakub Dawidek2011-02-061-13/+13
| | | | | | | | | values. MFC after: 1 week Notes: svn path=/head/; revision=218375
* Treat fstat(2) failure (different than EBADF) as fatal error.Pawel Jakub Dawidek2011-02-061-0/+1
| | | | | | | | Reported by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=218374
* Open syslog when logging sysconf(3) failure.Pawel Jakub Dawidek2011-02-061-0/+4
| | | | | | | | Reported by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=218373
* Close more descriptors that can be open if the worker process for the givenPawel Jakub Dawidek2011-02-061-0/+6
| | | | | | | | | | resource is already running. Submitted by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=218370
* Setup another socketpair between parent and child, so that primary sandboxedPawel Jakub Dawidek2011-02-031-0/+64
| | | | | | | | | | | | worker can ask the main privileged process to connect in worker's behalf and then we can migrate descriptor using this socketpair to worker. This is not really needed now, but will be needed once we start to use capsicum for sandboxing. MFC after: 1 week Notes: svn path=/head/; revision=218218
* - Use pjdlog for assertions and aborts as this will log assert/abort messagePawel Jakub Dawidek2011-01-311-15/+14
| | | | | | | | | | | | to syslog if we run in background. - Asserts in proto.c that method we want to call is implemented and remove dummy methods from protocols implementation that are only there to abort the program with nice message. MFC after: 1 week Notes: svn path=/head/; revision=218138
* Add function to assert that the only descriptors we have open are the onesPawel Jakub Dawidek2011-01-281-0/+141
| | | | | | | | | | | | | we expect to be open. Also assert that they point at expected type. Because openlog(3) API is unable to tell us descriptor number it is using, we have to close syslog socket, remember assert message in local buffer and if we fail on assertion, reopen syslog socket and log the message. MFC after: 1 week Notes: svn path=/head/; revision=218044
* Add function to close all unneeded descriptors after fork(2).Pawel Jakub Dawidek2011-01-281-1/+27
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=218041
* Close the control socket before exiting, so it will be unlinked.Pawel Jakub Dawidek2011-01-271-0/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=217967
* Add functions to initialize/finalize pjdlog. This allows to open/close logPawel Jakub Dawidek2011-01-271-0/+1
| | | | | | | | | file at will. MFC after: 1 week Notes: svn path=/head/; revision=217965
* Don't open configuration file from worker process. Handle SIGHUP in thePawel Jakub Dawidek2011-01-241-7/+41
| | | | | | | | | | | master process only and pass changes to the worker processes over control socket. This removes access to global namespace in preparation for capsicum sandboxing. MFC after: 2 weeks Notes: svn path=/head/; revision=217784
* - On primary worker reload, update hr_exec field.Pawel Jakub Dawidek2011-01-221-2/+5
| | | | | | | | | - Update comment. MFC after: 1 week Notes: svn path=/head/; revision=217729
* Install default signal handlers before masking signals we want to handle.Pawel Jakub Dawidek2011-01-121-0/+8
| | | | | | | | | | | | | | | | It is possible that the parent process ignores some of them and sigtimedwait() will never see them, eventhough they are masked. The most common situation for this to happen is boot process where init(8) ignores SIGHUP before starting to execute /etc/rc. This in turn caused hastd(8) to ignore SIGHUP. Reported by: trasz Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com MFC after: 3 days Notes: svn path=/head/; revision=217307
* Log the fact of launching and include protocol version number.Pawel Jakub Dawidek2010-12-161-0/+3
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=216477
* Load geom_gate.ko module after parsing arguments.Pawel Jakub Dawidek2010-10-241-2/+2
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=214273
* Log correct connection when canceling half-open connection.Pawel Jakub Dawidek2010-10-171-1/+2
| | | | | | | | Submitted by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 3 days Notes: svn path=/head/; revision=213981
* Decrease report interval to 5 seconds, as this also means we will check forPawel Jakub Dawidek2010-10-041-1/+1
| | | | | | | | | signals every 5 seconds and not every 10 seconds as before. MFC after: 3 days Notes: svn path=/head/; revision=213430
* hook_check() is now only used to report about long-running hooks, so thePawel Jakub Dawidek2010-10-041-1/+1
| | | | | | | | | argument is redundant, remove it. MFC after: 3 days Notes: svn path=/head/; revision=213429
* We can't mask ignored signal, so install dummy signal hander for SIGCHLD beforePawel Jakub Dawidek2010-10-041-0/+11
| | | | | | | | | | | | | masking it. This fixes bogus reports about hooks running for too long and other problems related to garbage-collecting child processes. Reported by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 3 days Notes: svn path=/head/; revision=213428
* Switch to sigprocmask(2) API also in the main process and secondary process.Pawel Jakub Dawidek2010-09-221-45/+39
| | | | | | | | | | | | This way the primary process inherits signal mask from the main process, which fixes a race where signal is delivered to the primary process before configuring signal mask. Reported by: Mikolaj Golub <to.my.trociny@gmail.com> MFC after: 3 days Notes: svn path=/head/; revision=213009
* Assert that descriptor numbers are sane.Pawel Jakub Dawidek2010-09-221-0/+4
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=213008
* Fix descriptor leaks: when child exits, we have to close control and eventPawel Jakub Dawidek2010-09-221-8/+2
| | | | | | | | | socket pairs. We did that only in one case out of three. MFC after: 3 days Notes: svn path=/head/; revision=213006