From 77402e51054701cd02ff07f8d5d43ef23e640226 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 27 May 2008 09:18:53 +1000 Subject: [PATCH] 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. --- managemon.c | 4 +--- mdmon.h | 2 -- monitor.c | 20 ++------------------ 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/managemon.c b/managemon.c index 971dcd1d..91755f92 100644 --- a/managemon.c +++ b/managemon.c @@ -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. diff --git a/mdmon.h b/mdmon.h index b84e270b..ad1a6781 100644 --- a/mdmon.h +++ b/mdmon.h @@ -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; }; diff --git a/monitor.c b/monitor.c index a7e53080..e14fd38a 100644 --- a/monitor.c +++ b/monitor.c @@ -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; } -- 2.39.2