diff options
author | NeilBrown <neilb@suse.de> | 2009-03-10 16:28:22 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-03-10 16:28:22 +1100 |
commit | 661dce36178960a20a5bcbb3bbf92e721df1bec0 (patch) | |
tree | 84bc5f3fa9c8e482527b5fae9b9f4f8ac463dd60 /managemon.c | |
parent | bc17324f5e0fd1631bfd9a8d749a34a94da4e621 (diff) | |
download | mdadm-661dce36178960a20a5bcbb3bbf92e721df1bec0.tar.gz mdadm-661dce36178960a20a5bcbb3bbf92e721df1bec0.tar.xz mdadm-661dce36178960a20a5bcbb3bbf92e721df1bec0.zip |
mdmon: allow incremental assembly of containers.
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>
Diffstat (limited to 'managemon.c')
-rw-r--r-- | managemon.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/managemon.c b/managemon.c index 5f0a61b..e02c77e 100644 --- a/managemon.c +++ b/managemon.c @@ -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); |