diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-02-24 18:45:57 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-02-24 18:45:57 -0700 |
commit | 7da80e6faa16e09eb557c5d66ba34c8f29b0072e (patch) | |
tree | ea8aaea9c34f6c4f41feb37d9f65b29eae833f6e /managemon.c | |
parent | dab4a5134e8d946f3809163af6abb80a945c904c (diff) | |
download | mdadm-7da80e6faa16e09eb557c5d66ba34c8f29b0072e.tar.gz mdadm-7da80e6faa16e09eb557c5d66ba34c8f29b0072e.tar.xz mdadm-7da80e6faa16e09eb557c5d66ba34c8f29b0072e.zip |
mdmon: fix removed disk handling
Use SKIP_GONE_DEVS when reading the container, and correct some confused
logic in manage_new().
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'managemon.c')
-rw-r--r-- | managemon.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/managemon.c b/managemon.c index c9b054f..c48c851 100644 --- a/managemon.c +++ b/managemon.c @@ -283,7 +283,7 @@ static void manage_container(struct mdstat_ent *mdstat, * 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; @@ -460,7 +460,7 @@ static void manage_new(struct mdstat_ent *mdstat, if (i == di->disk.raid_disk) break; - if (di) { + if (di && newd) { memcpy(newd, di, sizeof(*newd)); newd->state_fd = sysfs_open(new->devnum, @@ -469,13 +469,16 @@ static void manage_new(struct mdstat_ent *mdstat, 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); |