]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - monitor.c
fix mdmon takeover
[thirdparty/mdadm.git] / monitor.c
index a8e0af369bb4cad5fc2fd2145578da8d296cfdb6..e43e545ce196f1370ad68b78c9b02dac67ae89f9 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -75,7 +75,7 @@ static unsigned long long read_resync_start(int fd)
        if (n <= 0)
                return 0;
        if (strncmp(buf, "none", 4) == 0)
-               return ~0ULL;
+               return MaxSector;
        else
                return strtoull(buf, NULL, 10);
 }
@@ -208,8 +208,10 @@ static int read_and_act(struct active_array *a)
        a->info.resync_start = read_resync_start(a->resync_start_fd);
        for (mdi = a->info.devs; mdi ; mdi = mdi->next) {
                mdi->next_state = 0;
-               if (mdi->state_fd >= 0)
+               if (mdi->state_fd >= 0) {
+                       mdi->recovery_start = read_resync_start(mdi->recovery_fd);
                        mdi->curr_state = read_dev_state(mdi->state_fd);
+               }
        }
 
        if (a->curr_state <= inactive &&
@@ -479,7 +481,11 @@ static int wait_and_act(struct supertype *container, int nowait)
                                dprintf("caught sigterm, all clean... exiting\n");
                        else
                                dprintf("no arrays to monitor... exiting\n");
-                       remove_pidfile(container->devname);
+                       if (!sigterm)
+                               /* On SIGTERM, someone (the take-over mdmon) will
+                                * clean up
+                                */
+                               remove_pidfile(container->devname);
                        exit_now = 1;
                        signal_manager();
                        exit(0);