]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Grow: update backup-metadata mtime every time we write it.
authorNeilBrown <neilb@suse.de>
Wed, 21 Oct 2009 23:42:06 +0000 (10:42 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 21 Oct 2009 23:42:06 +0000 (10:42 +1100)
Originally the backup-metadata was only written once at the
start of a raid5 reshape that made the array bigger.  So we only
set the mtime once.

Now that we can be writing metadata continually during an in-place
reshape, we need to update the mtime more often.

Also, allow the metadata mtime to be slightly in advance of the
array mtime.  Normally the difference will be less than a second,
so 10 minutes should be plenty.  This guards against an old backup
file being used to restart an array.  but starting two reshapes in the
10 minutes is sufficiently unlikely, and the possibility of an
accident is already sufficiently small, that 10 minutes is probably
fine.

Thanks to Guy Martin <gmsoft@tuxicoman.be> for discovering and
reporting that .mtime wasn't being updated properly.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow.c

diff --git a/Grow.c b/Grow.c
index 1111526ba6259623f9297d38e3e222a1f7d40f40..f36704191a73650b448169ba5655c4e80c8ce168 100644 (file)
--- a/Grow.c
+++ b/Grow.c
@@ -1246,6 +1246,7 @@ int grow_backup(struct mdinfo *sra,
 
        if (rv)
                return rv;
+       bsb.mtime = __cpu_to_le64(time(0));
        for (i = 0; i < dests; i++) {
                bsb.devstart = __cpu_to_le64(destoffsets[i]/512);
 
@@ -1315,6 +1316,7 @@ int wait_backup(struct mdinfo *sra,
                bsb.arraystart = __cpu_to_le64(0);
                bsb.length = __cpu_to_le64(0);
        }
+       bsb.mtime = __cpu_to_le64(time(0));
        for (i = 0; i < dests; i++) {
                bsb.devstart = __cpu_to_le64(destoffsets[i]/512);
                bsb.sb_csum = bsb_csum((char*)&bsb, ((char*)&bsb.sb_csum)-((char*)&bsb));
@@ -1639,8 +1641,8 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt
                        continue; /* Wrong uuid */
                }
 
-               if (info->array.utime > __le64_to_cpu(bsb.mtime) + 3600 ||
-                   info->array.utime < __le64_to_cpu(bsb.mtime)) {
+               if (info->array.utime > __le64_to_cpu(bsb.mtime) + 10*60 ||
+                   info->array.utime < __le64_to_cpu(bsb.mtime) - 10*60) {
                        if (verbose)
                                fprintf(stderr, Name ": too-old timestamp on backup-metadata on %s\n", devname);
                        continue; /* time stamp is too bad */