summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-02-28 15:43:40 +0100
committerNeilBrown <neilb@suse.de>2010-03-03 12:07:18 +1100
commit32f217017fd5343ab3c0c564b689b90d0f093bd5 (patch)
tree05a1fe92bcf6b7d1d55218d0120f414ee97f78d4
parented8fa52f31521b8314859f290c464f77359933a0 (diff)
downloadmdadm-32f217017fd5343ab3c0c564b689b90d0f093bd5.tar.gz
mdadm-32f217017fd5343ab3c0c564b689b90d0f093bd5.tar.xz
mdadm-32f217017fd5343ab3c0c564b689b90d0f093bd5.zip
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>
-rw-r--r--mdmon.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/mdmon.c b/mdmon.c
index ef1872a..961aa77 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -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",