summaryrefslogtreecommitdiffstats
path: root/monitor.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-05-15 16:48:39 +1000
committerNeil Brown <neilb@suse.de>2008-05-15 16:48:39 +1000
commitc052ba301b417d4fc8493d95a4a87f0472cc0483 (patch)
treee677bbbbe13199a676d56bf384cfb4060f903989 /monitor.c
parent549e9569c6006433512801ae76b34abc0d3e1ac0 (diff)
downloadmdadm-c052ba301b417d4fc8493d95a4a87f0472cc0483.tar.gz
mdadm-c052ba301b417d4fc8493d95a4a87f0472cc0483.tar.xz
mdadm-c052ba301b417d4fc8493d95a4a87f0472cc0483.zip
start resync when transitioning from initial readonly state
From: Dan Williams <dan.j.williams@intel.com> mdadm handles setting resync_start, monitor uses this value to determine whether to set the 'active' or 'readauto' state. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/monitor.c b/monitor.c
index 38725d1..8f5ad46 100644
--- a/monitor.c
+++ b/monitor.c
@@ -64,6 +64,19 @@ static int get_sync_pos(struct active_array *a)
return 1;
}
+static int get_resync_start(struct active_array *a)
+{
+ char buf[30];
+ int n;
+
+ n = read_attr(buf, 30, a->resync_start_fd);
+ if (n <= 0)
+ return n;
+
+ a->resync_start = strtoull(buf, NULL, 10);
+
+ return 1;
+}
static int attr_match(const char *attr, const char *str)
{
@@ -191,12 +204,10 @@ int read_dev_state(int fd)
* Start recovery.
*
* deal with resync
- * This only happens on finding a new array....
- * Maybe this is done by mdadm before passing the array to us?
- *
- * If array is 'clean' but metadata is 'dirty', start a resync
- * and mark array as 'dirty'.
- *
+ * This only happens on finding a new array... mdadm will have set
+ * 'resync_start' to the correct value. If 'resync_start' indicates that an
+ * resync needs to occur set the array to the 'active' state rather than the
+ * initial read-auto state.
*
*
*
@@ -252,7 +263,13 @@ static int read_and_act(struct active_array *a)
* read-auto is OK. FIXME what if we really want
* readonly ???
*/
- a->next_state = read_auto;
+ get_resync_start(a);
+ if (a->resync_start == ~0ULL)
+ a->next_state = read_auto; /* array is clean */
+ else {
+ a->container->ss->mark_dirty(a);
+ a->next_state = active;
+ }
}
if (a->curr_action == idle &&