]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Allow a metadata update to have a linked list of allocated spaces.
authorNeilBrown <neilb@suse.de>
Thu, 16 Dec 2010 01:10:01 +0000 (12:10 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 16 Dec 2010 01:10:01 +0000 (12:10 +1100)
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>
managemon.c
mdadm.h
super-intel.c
util.c

index 5cc50d8d3d9473be7003045bb82708d03de91d50..860e5785aaf7f4abd9fa8e3418e740b6fbcf5cfa 100644 (file)
@@ -217,10 +217,16 @@ static void free_updates(struct metadata_update **update)
 {
        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);
        }
 }
@@ -710,6 +716,7 @@ static void handle_message(struct supertype *container, struct metadata_update *
                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);
diff --git a/mdadm.h b/mdadm.h
index 2062825405353a7ed19e634686d2b6847d600ca6..36124dea9a0dd5198aa62602c4390cbdff6e49be 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -764,6 +764,9 @@ struct metadata_update {
        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;
 };
 
index 68382513a910c89766f253dbdb43795d2a6388db..43f75d9e5adf5d618ba724b1f08c668b71302d80 100644 (file)
@@ -5357,6 +5357,7 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
        }
                        
        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;
diff --git a/util.c b/util.c
index f57cd9eea8eb8c379f7ce3c0f5099b7ae9967cb4..7544ce17a3c760c9817a11d1f0b14208584c515b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1890,6 +1890,7 @@ void append_metadata_update(struct supertype *st, void *buf, int len)
        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;