]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
DDF: increase seq number when writing meta data
authormwilck@arcor.de <mwilck@arcor.de>
Fri, 1 Mar 2013 22:28:24 +0000 (23:28 +0100)
committerNeilBrown <neilb@suse.de>
Mon, 4 Mar 2013 03:29:59 +0000 (14:29 +1100)
Cleanly increase the seq number when the DDF structures are
written, instead of always setting it back to 1.

Also, make sure that the sequential number of all headers and
VD conf records is the same.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
super-ddf.c

index dfbd55100bb51ad4e2d35512062ff71e35e0f33a..5eedbc30ae99389b6d856548510ce2f3548fc1bc 100644 (file)
@@ -2376,6 +2376,7 @@ static int __write_ddf_structure(struct dl *d, struct ddf_super *ddf, __u8 type,
                        c = (struct vcl *)d->spare;
 
                if (c) {
+                       c->conf.seqnum = ddf->primary.seq;
                        c->conf.crc = calc_crc(&c->conf, conf_size);
                        if (write(fd, &c->conf, conf_size) < 0)
                                break;
@@ -2408,12 +2409,20 @@ static int __write_init_super_ddf(struct supertype *st)
        int successes = 0;
        unsigned long long size;
        char *null_aligned;
+       __u32 seq;
 
        if (posix_memalign((void**)&null_aligned, 4096, NULL_CONF_SZ) != 0) {
                return -ENOMEM;
        }
        memset(null_aligned, 0xff, NULL_CONF_SZ);
 
+       if (ddf->primary.seq != 0xffffffff)
+               seq = __cpu_to_be32(__be32_to_cpu(ddf->primary.seq)+1);
+       else if (ddf->secondary.seq != 0xffffffff)
+               seq = __cpu_to_be32(__be32_to_cpu(ddf->secondary.seq)+1);
+       else
+               seq = __cpu_to_be32(1);
+
        /* try to write updated metadata,
         * if we catch a failure move on to the next disk
         */
@@ -2447,7 +2456,7 @@ static int __write_init_super_ddf(struct supertype *st)
                else
                        ddf->anchor.secondary_lba =
                                __cpu_to_be64(size - 32*1024*2);
-               ddf->anchor.seq = __cpu_to_be32(1);
+               ddf->anchor.seq = seq;
                memcpy(&ddf->primary, &ddf->anchor, 512);
                memcpy(&ddf->secondary, &ddf->anchor, 512);