Sometimes one metadata update will require allocating several
larger data structures. As 'monitor' cannot allocate, 'manager'
must, so it must be able to attach a list of allocates to the
update, and importantly it must be able to easily free them.
So add a 'space_list' element to metadata updates where each
element on the list starts with a pointer to the next.
Signed-off-by: NeilBrown <neilb@suse.de>
{
while (*update) {
struct metadata_update *this = *update;
+ void **space_list = this->space_list;
*update = this->next;
free(this->buf);
free(this->space);
+ while (space_list) {
+ void *space = space_list;
+ space_list = *space_list;
+ free(space);
+ }
free(this);
}
}
mu->buf = msg->buf;
msg->buf = NULL;
mu->space = NULL;
+ mu->space_list = NULL;
mu->next = NULL;
if (container->ss->prepare_update)
container->ss->prepare_update(container, mu);
int len;
char *buf;
void *space; /* allocated space that monitor will use */
+ void **space_list; /* list of allocated spaces that monitor can
+ * use or that it returned.
+ */
struct metadata_update *next;
};
}
mu->space = NULL;
+ mu->space_list = NULL;
mu->len = sizeof(struct imsm_update_activate_spare) * num_spares;
mu->next = *updates;
u = (struct imsm_update_activate_spare *) mu->buf;
mu->buf = buf;
mu->len = len;
mu->space = NULL;
+ mu->space_list = NULL;
mu->next = NULL;
*st->update_tail = mu;
st->update_tail = &mu->next;