diff options
author | NeilBrown <neilb@suse.de> | 2010-02-04 16:31:49 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-02-04 16:47:28 +1100 |
commit | 5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f (patch) | |
tree | 86261d4f1521d7953bdbde959fd96bd0fb744d9c /managemon.c | |
parent | 24f6f99b3630b1a89aaa57930c5c9de8a3df9ded (diff) | |
download | mdadm-5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f.tar.gz mdadm-5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f.tar.xz mdadm-5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f.zip |
mdmon: allow pid to be stored in different directory.
/var/run probably doesn't persist from early boot.
So if necessary, store in in /lib/init/rw or somewhere else
that does persist.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'managemon.c')
-rw-r--r-- | managemon.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/managemon.c b/managemon.c index a4e9a8f..2a73d4b 100644 --- a/managemon.c +++ b/managemon.c @@ -702,14 +702,29 @@ void do_manager(struct supertype *container) read_sock(container); - if (container->sock < 0 || socket_hup_requested) { - /* If this fails, we hope it already exists - * pid file lives in /var/run/mdadm/mdXX.pid + if (socket_hup_requested) { + /* Try to create pid file and socket in + * main or alternate RUN directory. */ - mkdir("/var/run/mdadm", 0600); - close(container->sock); - container->sock = make_control_sock(container->devname); - make_pidfile(container->devname, 0); + char *dir = VAR_RUN; + if (mkdir(dir, 0600) < 0 && errno != EEXIST) { + char *dir = ALT_RUN; + if (mkdir(dir, 0600) < 0 && errno != EEXIST) + dir = NULL; + } else { + if (proc_fd >= 0) + close(proc_fd); + proc_fd = -1; + } + if (dir && !sigterm && + (container->sock < 0 || + strcmp(dir, pid_dir) != 0)) { + close(container->sock); + remove_pidfile(container->devname); + pid_dir = dir; + container->sock = make_control_sock(container->devname); + make_pidfile(container->devname); + } socket_hup_requested = 0; } if (container->sock < 0) @@ -726,12 +741,9 @@ void do_manager(struct supertype *container) if (sigterm) wakeup_monitor(); - if (update_queue == NULL) { - if (container->sock < 0) - mdstat_wait_fd(proc_fd, &set); - else - mdstat_wait_fd(container->sock, &set); - } else + if (update_queue == NULL) + mdstat_wait_fd(container->sock, proc_fd, &set); + else /* If an update is happening, just wait for signal */ pselect(0, NULL, NULL, NULL, NULL, &set); } while(1); |