summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2010-04-29 10:50:29 -0700
committerDan Williams <dan.j.williams@intel.com>2010-04-29 10:50:29 -0700
commit63b4aae33ebf00d443378daf313622630f2336c0 (patch)
tree93ee8c5976862d4f49a51601a9f819eea352e4e1
parent4eb269706f403d2424166683688f0a41d893c1c3 (diff)
downloadmdadm-63b4aae33ebf00d443378daf313622630f2336c0.zip
mdadm-63b4aae33ebf00d443378daf313622630f2336c0.tar.gz
mdadm-63b4aae33ebf00d443378daf313622630f2336c0.tar.xz
mdmon: fix missing open of md/<dev>/recovery_start
When activating a spare we neglect to open recovery_start and as such do not see checkpoint events. Move disk initialization to common routine to mitigate recurrence. Reported-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--managemon.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/managemon.c b/managemon.c
index 037406f..454c39d 100644
--- a/managemon.c
+++ b/managemon.c
@@ -361,6 +361,23 @@ static void manage_container(struct mdstat_ent *mdstat,
}
}
+static int disk_init_and_add(struct mdinfo *disk, struct mdinfo *clone,
+ struct active_array *aa)
+{
+ if (!disk || !clone)
+ return -1;
+
+ *disk = *clone;
+ disk->recovery_fd = sysfs_open(aa->devnum, disk->sys_name, "recovery_start");
+ disk->state_fd = sysfs_open(aa->devnum, disk->sys_name, "state");
+ disk->prev_state = read_dev_state(disk->state_fd);
+ disk->curr_state = disk->prev_state;
+ disk->next = aa->info.devs;
+ aa->info.devs = disk;
+
+ return 0;
+}
+
static void manage_member(struct mdstat_ent *mdstat,
struct active_array *a)
{
@@ -414,14 +431,7 @@ static void manage_member(struct mdstat_ent *mdstat,
free(newd);
continue;
}
- *newd = *d;
- newd->next = newa->info.devs;
- newa->info.devs = newd;
-
- newd->state_fd = sysfs_open(a->devnum, newd->sys_name,
- "state");
- newd->prev_state = read_dev_state(newd->state_fd);
- newd->curr_state = newd->prev_state;
+ disk_init_and_add(newd, d, newa);
}
queue_metadata_update(updates);
updates = NULL;
@@ -513,19 +523,7 @@ static void manage_new(struct mdstat_ent *mdstat,
if (i == di->disk.raid_disk)
break;
- if (di && newd) {
- memcpy(newd, di, sizeof(*newd));
-
- newd->state_fd = sysfs_open(new->devnum,
- newd->sys_name,
- "state");
- newd->recovery_fd = sysfs_open(new->devnum,
- newd->sys_name,
- "recovery_start");
-
- newd->prev_state = read_dev_state(newd->state_fd);
- newd->curr_state = newd->prev_state;
- } else {
+ if (disk_init_and_add(newd, di, new) != 0) {
if (newd)
free(newd);
@@ -535,11 +533,7 @@ static void manage_new(struct mdstat_ent *mdstat,
new->container = NULL;
break;
}
- continue;
}
- sprintf(newd->sys_name, "rd%d", i);
- newd->next = new->info.devs;
- new->info.devs = newd;
}
new->action_fd = sysfs_open(new->devnum, NULL, "sync_action");