summaryrefslogtreecommitdiff
path: root/managemon.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-08-19 14:55:12 +1000
committerNeilBrown <neilb@suse.de>2008-08-19 14:55:12 +1000
commit7bc1962f8c725cdd9e185d924f6894178e6dfec9 (patch)
tree9da8d9378ea5f474dfb1ff10a084629ee9fd34e4 /managemon.c
parentae6aad82398085e07c922fbfa667a5f6ec5dd7e6 (diff)
downloadmdadm-7bc1962f8c725cdd9e185d924f6894178e6dfec9.tar.gz
mdmon: remove devices from container
Once the monitor thread has kicked a drive from all managed arrays mdadm -r is permitted. We are guaranteed that the drive is marked failed at this point, so allow the drive to be re-added as a spare. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'managemon.c')
-rw-r--r--managemon.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/managemon.c b/managemon.c
index b211d8f..d2925ae 100644
--- a/managemon.c
+++ b/managemon.c
@@ -228,12 +228,35 @@ static void manage_container(struct mdstat_ent *mdstat,
* about spare assignment.... probably not.
*/
if (mdstat->devcnt != container->devcnt) {
+ struct mdinfo **cdp, *cd, *di, *mdi;
+ int found;
+
/* read /sys/block/NAME/md/dev-??/block/dev to find out
* what is there, and compare with container->info.devs
* To see what is removed and what is added.
* These need to be remove from, or added to, the array
*/
- // FIXME
+ mdi = sysfs_read(-1, mdstat->devnum, GET_DEVS);
+ if (!mdi)
+ return;
+
+ /* check for removals */
+ for (cdp = &container->devs; *cdp; ) {
+ found = 0;
+ for (di = mdi->devs; di; di = di->next)
+ if (di->disk.major == (*cdp)->disk.major &&
+ di->disk.minor == (*cdp)->disk.minor) {
+ found = 1;
+ break;
+ }
+ if (!found) {
+ cd = *cdp;
+ *cdp = (*cdp)->next;
+ free(cd);
+ } else
+ cdp = &(*cdp)->next;
+ }
+ sysfs_free(mdi);
container->devcnt = mdstat->devcnt;
}
}