]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdmon: allow incremental assembly of containers.
authorNeilBrown <neilb@suse.de>
Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 10 Mar 2009 05:28:22 +0000 (16:28 +1100)
If mdmon sees a device added to a container, it should assume it is
a new spare.  It could be a part of the array that just hadn't been
assembled yet.  So check first.

Signed-off-by: NeilBrown <neilb@suse.de>
managemon.c
super-ddf.c

index 5f0a61b5ce106f56d44404ae08b7347f29a1a36f..e02c77ea964ef8fa6746ec05f06dc3835f312eb2 100644 (file)
@@ -241,7 +241,9 @@ static void add_disk_to_container(struct supertype *st, struct mdinfo *sd)
 {
        int dfd;
        char nm[20];
+       struct supertype *st2;
        struct metadata_update *update = NULL;
+       struct mdinfo info;
        mdu_disk_info_t dk = {
                .number = -1,
                .major = sd->disk.major,
@@ -261,6 +263,25 @@ static void add_disk_to_container(struct supertype *st, struct mdinfo *sd)
        if (dfd < 0)
                return;
 
+       /* Check the metadata and see if it is already part of this
+        * array
+        */
+       st2 = dup_super(st);
+       if (st2->ss->load_super(st2, dfd, NULL) == 0) {
+               st2->ss->getinfo_super(st, &info);
+               if (st->ss->compare_super(st, st2) == 0 &&
+                   info.disk.raid_disk >= 0) {
+                       /* Looks like a good member of array.
+                        * Just accept it.
+                        * mdadm will incorporate any parts into
+                        * active arrays.
+                        */
+                       st2->ss->free_super(st2);
+                       return;
+               }
+       }
+       st2->ss->free_super(st2);
+
        st->update_tail = &update;
        st->ss->add_to_super(st, &dk, dfd, NULL);
        st->ss->write_init_super(st);
index 965b8e2cd10a311decbed16bcb89aae5ac5a7f4f..6455deeee148cd1a9cbc01b2e3f37115f612dc39 100644 (file)
@@ -1335,6 +1335,7 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info)
                info->component_size = ddf->dlist->size - info->data_offset;
        } else {
                info->disk.number = -1;
+               info->disk.raid_disk = -1;
 //             info->disk.raid_disk = find refnum in the table and use index;
        }
        info->disk.state = (1 << MD_DISK_SYNC);