Discard get_sync_pos. We should be using get_resync_start.

"sync_complete" just tracks the current resync/recover/check/whatever pass.
"resync_start" tracks which parts of the array are known to be in-sync
(modulo active writes).  So it is what we need to use to update the metadata.
Also we cannot call it when the array has stopped, as the value is no longer
available then.  We must call it when the resync completes.
Possibly also call it preiodically if the array is quiescent.
This commit is contained in:
Neil Brown 2008-05-27 09:18:53 +10:00
parent 75aa18b53c
commit 77402e5105
3 changed files with 3 additions and 23 deletions

View File

@ -87,7 +87,6 @@ static void close_aa(struct active_array *aa)
close(aa->action_fd);
close(aa->info.state_fd);
close(aa->resync_start_fd);
close(aa->sync_pos_fd);
}
static void free_aa(struct active_array *aa)
@ -265,8 +264,7 @@ static void manage_new(struct mdstat_ent *mdstat,
new->action_fd = sysfs_open(new->devnum, NULL, "sync_action");
new->info.state_fd = sysfs_open(new->devnum, NULL, "array_state");
new->resync_start_fd = sysfs_open(new->devnum, NULL, "resync_start");
new->sync_pos_fd = sysfs_open(new->devnum, NULL, "sync_completed");
new->sync_pos = 0;
new->resync_start = 0;
sysfs_free(mdi);
// finds and compares.

View File

@ -11,7 +11,6 @@ struct active_array {
struct active_array *next, *replaces;
int action_fd;
int sync_pos_fd;
int resync_start_fd;
enum array_state prev_state, curr_state, next_state;
@ -19,7 +18,6 @@ struct active_array {
int devnum;
unsigned long long sync_pos;
unsigned long long resync_start;
};

View File

@ -47,22 +47,6 @@ static int read_attr(char *buf, int len, int fd)
return n;
}
static int get_sync_pos(struct active_array *a)
{
char buf[30];
int n;
n = read_attr(buf, 30, a->sync_pos_fd);
if (n <= 0)
return n;
if (strncmp(buf, "max", 3) == 0) {
a->sync_pos = ~(unsigned long long)0;
return 1;
}
a->sync_pos = strtoull(buf, NULL, 10);
return 1;
}
static int get_resync_start(struct active_array *a)
{
@ -248,8 +232,7 @@ static int read_and_act(struct active_array *a)
if (a->curr_state <= inactive &&
a->prev_state > inactive) {
/* array has been stopped */
get_sync_pos(a);
a->container->ss->mark_clean(a, a->sync_pos);
a->container->ss->mark_clean(a, a->resync_start);
a->next_state = clear;
deactivate = 1;
}
@ -285,6 +268,7 @@ static int read_and_act(struct active_array *a)
* until the array goes inactive or readonly though.
* Just check if we need to fiddle spares.
*/
get_resync_start(a);
check_degraded = 1;
}