summaryrefslogtreecommitdiffstats
path: root/managemon.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2008-06-12 10:13:23 +1000
committerNeil Brown <neilb@suse.de>2008-06-12 10:13:23 +1000
commit2e735d198233a67f305862f72e3a5d0f0c3c548c (patch)
tree8dad807f9ed77f623ad5cf70900eab23054a552e /managemon.c
parentb22806772072a3c9a3a7fa406fb573294cb4388b (diff)
downloadmdadm-2e735d198233a67f305862f72e3a5d0f0c3c548c.tar.gz
mdadm-2e735d198233a67f305862f72e3a5d0f0c3c548c.tar.xz
mdadm-2e735d198233a67f305862f72e3a5d0f0c3c548c.zip
Allow passing metadata update to the monitor.
Code in manager can now just call queue_metadata_update with a (freeable) buf holding the update, and it will get passed to the monitor and written out.
Diffstat (limited to 'managemon.c')
-rw-r--r--managemon.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/managemon.c b/managemon.c
index 4b06778..167d176 100644
--- a/managemon.c
+++ b/managemon.c
@@ -151,6 +151,45 @@ static void replace_array(struct supertype *container,
write_wakeup(container);
}
+struct metadata_update *update_queue = NULL;
+struct metadata_update *update_queue_handled = NULL;
+struct metadata_update *update_queue_pending = NULL;
+
+void check_update_queue(struct supertype *container)
+{
+ while (update_queue_handled) {
+ struct metadata_update *this = update_queue_handled;
+ update_queue_handled = this->next;
+ free(this->buf);
+ free(this);
+ }
+ if (update_queue == NULL &&
+ update_queue_pending) {
+ update_queue = update_queue_pending;
+ update_queue_pending = NULL;
+ write_wakeup(container);
+ }
+}
+
+void queue_metadata_update(struct metadata_update *mu)
+{
+ struct metadata_update **qp;
+
+ qp = &update_queue_pending;
+ while (*qp)
+ qp = & ((*qp)->next);
+ *qp = mu;
+}
+
+void wait_update_handled(void)
+{
+ /* Wait for any pending update to be handled by monitor.
+ * i.e. wait until update_queue is NULL
+ */
+ while (update_queue)
+ usleep(100 * 1000);
+}
+
static void manage_container(struct mdstat_ent *mdstat,
struct supertype *container)
{
@@ -404,6 +443,8 @@ void do_manager(struct supertype *container)
remove_old();
+ check_update_queue(container);
+
manager_ready = 1;
sigprocmask(SIG_SETMASK, &block, &orig);
if (woke == 0)