* To see what is removed and what is added.
* These need to be remove from, or added to, the array
*/
- mdi = sysfs_read(-1, mdstat->devnum, GET_DEVS);
+ mdi = sysfs_read(-1, mdstat->devnum, GET_DEVS|SKIP_GONE_DEVS);
if (!mdi) {
/* invalidate the current count so we can try again */
container->devcnt = -1;
if (i == di->disk.raid_disk)
break;
- if (di) {
+ if (di && newd) {
memcpy(newd, di, sizeof(*newd));
newd->state_fd = sysfs_open(new->devnum,
newd->prev_state = read_dev_state(newd->state_fd);
newd->curr_state = newd->prev_state;
- } else if (failed + 1 > new->info.array.failed_disks) {
- /* we cannot properly monitor without all working disks */
- new->container = NULL;
- break;
} else {
+ if (newd)
+ free(newd);
+
failed++;
- free(newd);
+ if (failed > new->info.array.failed_disks) {
+ /* we cannot properly monitor without all working disks */
+ new->container = NULL;
+ break;
+ }
continue;
}
sprintf(newd->sys_name, "rd%d", i);
}
mdi = sysfs_read(mdfd, container->devnum,
- GET_VERSION|GET_LEVEL|GET_DEVS);
+ GET_VERSION|GET_LEVEL|GET_DEVS|SKIP_GONE_DEVS);
if (!mdi) {
fprintf(stderr, "mdmon: failed to load sysfs info for %s\n",