mdmon: Check both RUN directories to find running mdmon

If mdmon is run without "--takeover", it should still
check both *_RUN directories for a valid 'pid' file
to guard against having two mdmons running at the same time.


Suggested-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2010-02-28 15:43:40 +01:00
parent ed8fa52f31
commit 32f217017f
1 changed files with 9 additions and 12 deletions

21
mdmon.c
View File

@ -445,26 +445,23 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
act.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &act, NULL);
if (takeover) {
pid_dir = VAR_RUN;
pid_dir = VAR_RUN;
victim = mdmon_pid(container->devnum);
if (victim < 0) {
pid_dir = ALT_RUN;
victim = mdmon_pid(container->devnum);
if (victim < 0) {
pid_dir = ALT_RUN;
victim = mdmon_pid(container->devnum);
}
if (victim >= 0)
victim_sock = connect_monitor(container->devname);
}
if (victim >= 0)
victim_sock = connect_monitor(container->devname);
ignore = chdir("/");
if (victim < 0) {
if (ping_monitor(container->devname) == 0) {
if (!takeover && victim > 0 && victim_sock >= 0) {
if (fping_monitor(victim_sock) == 0) {
fprintf(stderr, "mdmon: %s already managed\n",
container->devname);
exit(3);
}
/* if there is a pid file, kill whoever is there just in case */
victim = mdmon_pid(container->devnum);
close(victim_sock);
}
if (container->ss->load_super(container, mdfd, devname)) {
fprintf(stderr, "mdmon: Cannot load metadata for %s\n",