NeilBrown: mdmon: discard test_pidfile()

Martin F. Krafft madduck at alioth.debian.org
Mon May 24 09:20:52 UTC 2010


Module: mdadm
Branch: upstream
Commit: 24cfdbc5c0b6a1ccae28ffb10a707160525f18c6
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=24cfdbc5c0b6a1ccae28ffb10a707160525f18c6

Author: NeilBrown <neilb at suse.de>
Date:   Thu Feb  4 14:49:32 2010 +1100

mdmon: discard test_pidfile()

devname2mdmon() can be used just as easily and doing so saves us from
some duplicate code.
Also tidy up some related logic.

Signed-off-by: NeilBrown <neilb at suse.de>

---

 mdmon.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/mdmon.c b/mdmon.c
index c5fcc4b..1cdbde1 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -113,15 +113,6 @@ static struct superswitch *find_metadata_methods(char *vers)
 	return NULL;
 }
 
-static int test_pidfile(char *devname)
-{
-	char path[100];
-	struct stat st;
-
-	sprintf(path, "/var/run/mdadm/%s.pid", devname);
-	return stat(path, &st);
-}
-
 int make_pidfile(char *devname, int o_excl)
 {
 	char path[100];
@@ -529,13 +520,14 @@ static int mdmon(char *devname, int devnum, int must_fork, char *switchroot)
 	}
 
 	ignore = chdir("/");
-	if (victim < 0 && test_pidfile(container->devname) == 0) {
+	if (victim < 0) {
 		if (ping_monitor(container->devname) == 0) {
 			fprintf(stderr, "mdmon: %s already managed\n",
 				container->devname);
 			exit(3);
-		} else if (victim < 0)
-			victim = devname2mdmon(container->devname);
+		}
+		/* if there is a pid file, kill whoever is there just in case */
+		victim = devname2mdmon(container->devname);
 	}
 	if (container->ss->load_super(container, mdfd, devname)) {
 		fprintf(stderr, "mdmon: Cannot load metadata for %s\n",




More information about the pkg-mdadm-commits mailing list