]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - monitor.c
mdmon: ping will wait for manage_mon to catch up.
[thirdparty/mdadm.git] / monitor.c
index 46d5e0a00380672285a2667c140e8324cc545721..e29d023a4c756c9ad1599b5c283988ad1c479f00 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -48,7 +48,7 @@ static int read_attr(char *buf, int len, int fd)
 }
 
 
-static int get_resync_start(struct active_array *a)
+int get_resync_start(struct active_array *a)
 {
        char buf[30];
        int n;
@@ -251,7 +251,8 @@ static int read_and_act(struct active_array *a)
                }
        }
 
-       if (a->curr_action == idle &&
+       if (!deactivate &&
+           a->curr_action == idle &&
            a->prev_action == resync) {
                /* A resync has finished.  The endpoint is recorded in
                 * 'sync_start'.  We don't update the metadata
@@ -263,14 +264,19 @@ static int read_and_act(struct active_array *a)
                check_degraded = 1;
        }
 
-       if (a->curr_action == idle &&
+       if (!deactivate &&
+           a->curr_action == idle &&
            a->prev_action == recover) {
+               /* A recovery has finished.  Some disks may be in sync now,
+                * and the array may no longer be degraded
+                */
                for (mdi = a->info.devs ; mdi ; mdi = mdi->next) {
                        a->container->ss->set_disk(a, mdi->disk.raid_disk,
                                                   mdi->curr_state);
                        if (! (mdi->curr_state & DS_INSYNC))
                                check_degraded = 1;
                }
+               a->container->ss->set_array_state(a, 0);
        }
 
        for (mdi = a->info.devs ; mdi ; mdi = mdi->next) {
@@ -399,6 +405,8 @@ static void dprint_wake_reasons(fd_set *fds)
 }
 #endif
 
+int monitor_loop_cnt;
+
 static int wait_and_act(struct supertype *container, int nowait)
 {
        fd_set rfds;
@@ -456,7 +464,9 @@ static int wait_and_act(struct supertype *container, int nowait)
                sigset_t set;
                sigprocmask(SIG_UNBLOCK, NULL, &set);
                sigdelset(&set, SIGUSR1);
+               monitor_loop_cnt |= 1;
                rv = pselect(maxfd+1, &rfds, NULL, NULL, NULL, &set);
+               monitor_loop_cnt += 1;
                if (rv == -1 && errno == EINTR)
                        rv = 0;
                #ifdef DEBUG