]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assembe: fix bug in force_array - it wasn't forcing properly.
authorNeilBrown <neilb@suse.de>
Mon, 21 Oct 2013 22:55:04 +0000 (09:55 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 21 Oct 2013 22:55:04 +0000 (09:55 +1100)
Since 'best' was expanded to hold replacement devices, we might
need to go up to raid_disks*2 to find devices to force.

Also fix another place when considering replacement drives would
be wrong (the 'chosen' device should never be a replacement).

Reported-by: John Yates <jyates65@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c

index 86b4c894b260c4b1d13eff1c3224775045badc46..4d5ceeac867404f0be23b2096278b042bdadd980 100644 (file)
@@ -803,7 +803,9 @@ static int force_array(struct mdinfo *content,
                int chosen_drive = -1;
                int i;
 
-               for (i = 0; i < content->array.raid_disks && i < bestcnt; i++) {
+               for (i = 0;
+                    i < content->array.raid_disks * 2 && i < bestcnt;
+                    i += 2) {
                        int j = best[i];
                        if (j>=0 &&
                            !devices[j].uptodate &&
@@ -863,7 +865,9 @@ static int force_array(struct mdinfo *content,
                /* If there are any other drives of the same vintage,
                 * add them in as well.  We can't lose and we might gain
                 */
-               for (i = 0; i < content->array.raid_disks && i < bestcnt ; i++) {
+               for (i = 0;
+                    i < content->array.raid_disks * 2 && i < bestcnt ;
+                    i += 2) {
                        int j = best[i];
                        if (j >= 0 &&
                            !devices[j].uptodate &&
@@ -1528,7 +1532,7 @@ try_again:
         */
        chosen_drive = -1;
        st->ss->free_super(st);
-       for (i=0; chosen_drive < 0 && i<bestcnt; i++) {
+       for (i=0; chosen_drive < 0 && i<bestcnt; i+=2) {
                int j = best[i];
                int fd;