summaryrefslogtreecommitdiff
path: root/Monitor.c
diff options
context:
space:
mode:
authorMarcin Labun <marcin.labun@intel.com>2010-11-22 20:58:07 +1100
committerNeilBrown <neilb@suse.de>2010-11-22 20:58:07 +1100
commitc3621c0a5fe2344681388cf0439bdf978736d2a6 (patch)
treeb4ff572fdc58fb1596e1b238f969d47ec94e0dc1 /Monitor.c
parent2e0172b1100ef1cb92098f2de8675759f5805566 (diff)
Monitor: link containers with subarrays in statelist
Each containers has list of its subarrays. Each subarray has back link to its parent container. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/Monitor.c b/Monitor.c
index 54f26b19..be8d5904 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -50,6 +50,11 @@ struct state {
* For others, NoMdDev
*/
struct supertype *metadata;
+ struct state *subarray;/* for a container it is a link to first subarray
+ * for a subarray it is a link to next subarray
+ * in the same container */
+ struct state *parent; /* for a subarray it is a link to its container
+ */
struct state *next;
};
@@ -67,6 +72,7 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state *statelist,
static void try_spare_migration(struct state *statelist,
char *mailaddr, char *mailfrom,
char *alert_cmd, int dosyslog);
+static void link_containers_with_subarrays(struct state *list);
int Monitor(struct mddev_dev *devlist,
char *mailaddr, char *alert_cmd,
@@ -680,6 +686,8 @@ static void try_spare_migration(struct state *statelist,
char *alert_cmd, int dosyslog)
{
struct state *st;
+
+ link_containers_with_subarrays(statelist);
for (st = statelist; st; st=st->next)
if (st->active < st->raid &&
st->spare == 0 &&
@@ -735,6 +743,34 @@ static void try_spare_migration(struct state *statelist,
}
}
}
+
+/* search the statelist to connect external
+ * metadata subarrays with their containers
+ * We always completely rebuild the tree from scratch as
+ * that is safest considering the possibility of entries
+ * disappearing or changing.
+ */
+static void link_containers_with_subarrays(struct state *list)
+{
+ struct state *st;
+ struct state *cont;
+ for (st = list; st; st = st->next) {
+ st->parent = NULL;
+ st->subarray = NULL;
+ }
+ for (st = list; st; st = st->next)
+ if (st->parent_dev != NoMdDev)
+ for (cont = list; cont; cont = cont->next)
+ if (!cont->err &&
+ cont->parent_dev == NoMdDev &&
+ cont->devnum == st->parent_dev) {
+ st->parent = cont;
+ st->subarray = cont->subarray;
+ cont->subarray = st;
+ break;
+ }
+}
+
/* Not really Monitor but ... */
int Wait(char *dev)
{