FIX: Last checkpoint is not initialized on reshape restart

When reshape is restarted and active array in mdmon is being initialized,
mdmon has to know last checkpoint, otherwise reshape will be restarted
form '0' position.
mdadm when reshaped array is assembled stores reshape_position in sysfs
and runs mdmon. Initialize last_checkpoint in active array structure
to value present in sysfs for reshaped array start.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Adam Kwolek 2011-03-10 15:05:54 +01:00 committed by NeilBrown
parent bcc9e9edd0
commit 138477db4b
1 changed files with 15 additions and 0 deletions

View File

@ -596,6 +596,7 @@ static void manage_new(struct mdstat_ent *mdstat,
char *inst;
int i;
int failed = 0;
char buf[40];
/* check if array is ready to be monitored */
if (!mdstat->active)
@ -657,6 +658,20 @@ static void manage_new(struct mdstat_ent *mdstat,
dprintf("%s: inst: %d action: %d state: %d\n", __func__, atoi(inst),
new->action_fd, new->info.state_fd);
/* reshape_position is set by mdadm in sysfs
* read this information for new arrays only (empty victim)
*/
if ((victim == NULL) &&
(sysfs_get_str(mdi, NULL, "sync_action", buf, 40) > 0) &&
(strncmp(buf, "reshape", 7) == 0)) {
if (sysfs_get_ll(mdi, NULL, "reshape_position",
&new->last_checkpoint) != 0)
new->last_checkpoint = 0;
dprintf("mdmon: New monitored array is under reshape.\n"
" Last checkpoint is: %llu\n",
new->last_checkpoint);
}
sysfs_free(mdi);
/* if everything checks out tell the metadata handler we want to