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)
{
remove_old();
+ check_update_queue(container);
+
manager_ready = 1;
sigprocmask(SIG_SETMASK, &block, &orig);
if (woke == 0)
extern char *map_dev(int major, int minor, int create);
struct active_array;
+struct metadata_update;
extern struct superswitch {
void (*examine_super)(struct supertype *st, char *homehost);
* not in fact changed.
*/
void (*set_disk)(struct active_array *a, int n, int state);
- void (*sync_metadata)(struct active_array *a);
+ void (*sync_metadata)(struct supertype *st);
+ void (*process_update)(struct supertype *st,
+ struct metadata_update *update);
int major;
unsigned long long resync_start;
};
-
+/*
+ * Metadata updates are handled by the monitor thread,
+ * as it has exclusive access to the metadata.
+ * When the manager want to updates metadata, either
+ * for it's own reason (e.g. committing a spare) or
+ * on behalf of mdadm, it creates a metadata_update
+ * structure and queues it to the monitor.
+ * Updates are created and processed by code under the
+ * superswitch. All common code sees them as opaque
+ * blobs.
+ */
+struct metadata_update {
+ int len;
+ char *buf;
+ void *space; /* allocated space that monitor will use */
+ struct metadata_update *next;
+};
+extern struct metadata_update *update_queue, *update_queue_handled;
#define MD_MAJOR 9
// FIXME;
}
- a->container->ss->sync_metadata(a);
+ a->container->ss->sync_metadata(a->container);
/* Effect state changes in the array */
if (a->next_state != bad_word)
}
}
+ if (update_queue) {
+ struct metadata_update *this;
+
+ for (this = update_queue; this ; this = this->next)
+ container->ss->process_update(container, this);
+
+ update_queue_handled = update_queue;
+ update_queue = NULL;
+ signal_manager();
+ container->ss->sync_metadata(container);
+ }
+
for (a = *aap; a ; a = a->next) {
if (a->replaces && !discard_this) {
struct active_array **ap;
fprintf(stderr, "ddf: set_disk %d\n", n);
}
-static void ddf_sync_metadata(struct active_array *a)
+static void ddf_sync_metadata(struct supertype *st)
{
/*
* but ddf is sufficiently weird that it probably always
* changes global data ....
*/
- __write_init_super_ddf(a->container, 0);
+ __write_init_super_ddf(st, 0);
fprintf(stderr, "ddf: sync_metadata\n");
}
return 0;
}
-static void imsm_sync_metadata(struct active_array *a)
+static void imsm_sync_metadata(struct supertype *container)
{
- struct intel_super *super = a->container->sb;
+ struct intel_super *super = container->sb;
struct imsm_super *mpb = super->mpb;
struct dl *d;
__u32 generation;