"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.
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)
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.
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;
int devnum;
- unsigned long long sync_pos;
unsigned long long resync_start;
};
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)
{
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;
}
* until the array goes inactive or readonly though.
* Just check if we need to fiddle spares.
*/
+ get_resync_start(a);
check_degraded = 1;
}