diff options
author | grog <grog@FreeBSD.org> | 1999-02-11 06:42:39 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 1999-02-11 06:42:39 +0000 |
commit | ad4e6d446ec2f0a45856b2e2b1d73f82aea303f4 (patch) | |
tree | 8c6aa7a09bec893a3659697c3f0df58e7c69f612 /sys | |
parent | cc1dab1dbe098bc56b2af55540ca2c26eb8ebe5c (diff) | |
download | FreeBSD-src-ad4e6d446ec2f0a45856b2e2b1d73f82aea303f4.zip FreeBSD-src-ad4e6d446ec2f0a45856b2e2b1d73f82aea303f4.tar.gz |
In some cases, it's possible that I/O errors will cause the daemon to
time out on an operation. Under these circumstances, vinum(8) will
automatically start another daemon. Add a pid for the daemon, so that
an overtaken daemon will discover that it's no longer in favour, and
will crawl into a corner and die.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/vinum/vinumdaemon.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/dev/vinum/vinumdaemon.c b/sys/dev/vinum/vinumdaemon.c index 39da3c3..78987b1 100644 --- a/sys/dev/vinum/vinumdaemon.c +++ b/sys/dev/vinum/vinumdaemon.c @@ -34,7 +34,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumdaemon.c,v 1.3 1999/01/18 04:32:50 grog Exp grog $ + * $Id: vinumdaemon.c,v 1.1.2.3 1999/02/11 05:28:41 grog Exp $ */ #define REALLYKERNEL @@ -51,6 +51,7 @@ void recover_io(struct request *rq); struct daemonq *daemonq; /* daemon's work queue */ struct daemonq *dqend; /* and the end of the queue */ int daemon_options = 0; /* options */ +int daemonpid; /* PID of daemon */ void vinum_daemon(void) @@ -59,9 +60,21 @@ vinum_daemon(void) int s; daemon_save_config(); /* start by saving the configuration */ + daemonpid = curproc->p_pid; /* mark our territory */ while (1) { tsleep(&vinum_daemon, PRIBIO, "vinum", 0); /* wait for something to happen */ + /* + * It's conceivable that, as the result of an + * I/O error, we'll be out of action long + * enough that another daemon gets started. + * That's OK, just give up gracefully. + */ + if (curproc->p_pid != daemonpid) { /* we've been ousted in our sleep */ + if (daemon_options & daemon_verbose) + printf("vinumd: abdicating\n"); + return; + } while (daemonq != NULL) { /* we have work to do, */ s = splhigh(); /* don't get interrupted here */ request = daemonq; /* get the request */ @@ -111,7 +124,6 @@ vinum_daemon(void) daemon_options |= daemon_stopped; /* note that we've stopped */ wakeup(vinum_daemon); /* in case somebody's waiting for us to stop */ return; - break; case daemonrq_ping: /* tell the caller we're here */ if (daemon_options & daemon_verbose) @@ -181,7 +193,6 @@ queue_daemon_request(enum daemonrq type, union daemoninfo info) * see if the daemon is running. Return 0 (no error) * if it is, ESRCH otherwise */ - int vinum_finddaemon() { @@ -197,7 +208,7 @@ vinum_finddaemon() } if (result) /* will be EWOULDBLOCK or EINTR */ - return ESRCH; /* no process */ + vinum_daemon(); /* start the daemon */ return 0; } |