diff options
author | Dan Williams <dan.j.williams@intel.com> | 2008-05-15 16:48:44 +1000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2008-05-15 16:48:44 +1000 |
commit | 2a0bb19e0089aef4fcc65513c40a54cb00e53a7b (patch) | |
tree | bcd5731d93f1f5067cd6b8374c6dc2a79cd57fbd /managemon.c | |
parent | fd7cde1bf0221049b6359a96ab4c43578897d0ab (diff) | |
download | mdadm-2a0bb19e0089aef4fcc65513c40a54cb00e53a7b.tar.gz |
Flag arrays for deletion after they have been stopped.
From: Dan Williams <dan.j.williams@intel.com>
If they are later reassembled they will be replaced and deallocated
via replace_array.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'managemon.c')
-rw-r--r-- | managemon.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/managemon.c b/managemon.c index 14e7184b..43c731fa 100644 --- a/managemon.c +++ b/managemon.c @@ -77,11 +77,26 @@ #include <sys/socket.h> +static void close_aa(struct active_array *aa) +{ + struct mdinfo *d; + + for (d = aa->info.devs; d; d = d->next) + close(d->state_fd); + + close(aa->action_fd); + close(aa->info.state_fd); + close(aa->resync_start_fd); + close(aa->sync_pos_fd); +} + static void free_aa(struct active_array *aa) { - /* Note that this doesn't close fds, as they may be in used - * by a clone. Use close_aa for that. + /* Note that this doesn't close fds if they are being used + * by a clone. ->container will be set for a clone */ + if (!aa->container) + close_aa(aa); while (aa->info.devs) { struct mdinfo *d = aa->info.devs; aa->info.devs = d->next; @@ -90,6 +105,11 @@ static void free_aa(struct active_array *aa) free(aa); } +static void write_wakeup(struct supertype *c) +{ + write(c->pipe[1], "PING", 4); +} + static void replace_array(struct supertype *container, struct active_array *old, struct active_array *new) @@ -115,6 +135,7 @@ static void replace_array(struct supertype *container, new->replaces = old; new->next = container->arrays; container->arrays = new; + write_wakeup(container); } @@ -158,13 +179,9 @@ static void manage_member(struct mdstat_ent *mdstat, } -static void write_wakeup(struct supertype *c) -{ - write(c->pipe[1], "PING", 4); -} - static void manage_new(struct mdstat_ent *mdstat, - struct supertype *container) + struct supertype *container, + struct active_array *victim) { /* A new array has appeared in this container. * Hopefully it is already recorded in the metadata. @@ -200,7 +217,7 @@ static void manage_new(struct mdstat_ent *mdstat, * Mark it to be ignored by setting container to NULL */ new->container = NULL; - replace_array(container, NULL, new); + replace_array(container, victim, new); return; } @@ -240,11 +257,10 @@ static void manage_new(struct mdstat_ent *mdstat, if (container->ss->open_new(container, new, inst) < 0) { // FIXME close all those files new->container = NULL; - replace_array(container, NULL, new); + replace_array(container, victim, new); return; } - replace_array(container, NULL, new); - write_wakeup(container); + replace_array(container, victim, new); return; } @@ -278,8 +294,8 @@ void manage(struct mdstat_ent *mdstat, struct active_array *aa, break; } } - if (a == NULL) - manage_new(mdstat, container); + if (a == NULL || !a->container) + manage_new(mdstat, container, a); } } |