]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assemble: improve efficacy of -Af in assembling degraded dirty arrays.
authorNeilBrown <neilb@suse.de>
Wed, 23 Mar 2011 00:07:27 +0000 (11:07 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 23 Mar 2011 01:10:31 +0000 (12:10 +1100)
If a degraded dirty array has some superblocks which are clean and
others that are dirty, and the dirty ones are newer by precisely '1'
in the event count, then the current code to force the array to be
clean will not work.
We need to make sure to find a superblock with most recent event count
and force that one to be 'clean'.

Reported-by: A J Wyborny <ajwyborny@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c

index ee0346a52b0ffb26e81bef39536827610ffa65ec..268e248a083f99fdfbc8d0895b0716ea06915509 100644 (file)
@@ -1062,6 +1062,8 @@ int Assemble(struct supertype *st, char *mddev,
                        continue;
                if (!devices[j].uptodate)
                        continue;
+               if (devices[j].i.events < devices[most_recent].i.events)
+                       continue;
                chosen_drive = j;
                if ((fd=dev_open(devices[j].devname, O_RDONLY|O_EXCL))< 0) {
                        fprintf(stderr, Name ": Cannot open %s: %s\n",
@@ -1158,6 +1160,9 @@ int Assemble(struct supertype *st, char *mddev,
                        free(devices);
                        return 1;
                }
+               if (verbose >= 0)
+                       fprintf(stderr, Name ": Marking array %s as 'clean'\n",
+                               mddev);
                close(fd);
        }