]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdmon: ping will wait for manage_mon to catch up.
authorNeilBrown <neilb@suse.de>
Fri, 18 Jul 2008 06:37:06 +0000 (16:37 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 18 Jul 2008 06:37:06 +0000 (16:37 +1000)
When a 'ping' (empty message) is sent to mdmon, we wait for
'monitor' to do a full loop to make sure it has caught up
with anything that needs doing.
This allows synchronisation between mdadm and mdmon.

Maybe monitor should signal managemon rather than managemon polling...

Signed-off-by: Neil Brown <neilb@suse.de>
managemon.c
mdmon.h
monitor.c

index 447d8ea0001f19e51cbf7e6291b71783aff42a5f..c947552eb7161d69a7aa7f358962ed46d3c84097 100644 (file)
@@ -436,7 +436,15 @@ static void handle_message(struct supertype *container, struct metadata_update *
        struct metadata_update *mu;
 
        if (msg->len == 0) {
+               int cnt = monitor_loop_cnt;
+               if (cnt & 1)
+                       cnt += 2; /* wait until next pselect */
+               else
+                       cnt += 3; /* wait for 2 pselects */
+               wakeup_monitor();
                wait_update_handled();
+               while (monitor_loop_cnt - cnt < 0)
+                       usleep(10 * 1000);
        } else {
                mu = malloc(sizeof(*mu));
                mu->len = msg->len;
diff --git a/mdmon.h b/mdmon.h
index a1f0379b83c08ee2fd8e305b1ed9d57afb54b51c..6c1961ad50a7e2fa2c4dc7414163e5d2fce9caab 100644 (file)
--- a/mdmon.h
+++ b/mdmon.h
@@ -62,3 +62,4 @@ struct mdstat_ent *mdstat_read(int hold, int start);
 
 extern int exit_now, manager_ready;
 extern int mon_tid, mgr_tid;
+extern int monitor_loop_cnt;
index 314889657aaae88629241ab4ae69d80b4832284a..e29d023a4c756c9ad1599b5c283988ad1c479f00 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -405,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;
@@ -462,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