The 'enough' function is written to work with 'near' arrays only
in that is implicitly assumes that the offset from one 'group' of
devices to the next is the same as the number of copies.
In reality it is the number of 'near' copies.
So change it to make this number explicit.
Reported-by: Jakub Husák <jakub@gooseman.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
/* there must be one of the 'copies' form 'first' */
int n = copies;
int cnt=0;
+ int this = first;
while (n--) {
- if (avail[first])
+ if (avail[this])
cnt++;
- first = (first+1) % raid_disks;
+ this = (this+1) % raid_disks;
}
if (cnt == 0)
return 0;
-
+ first = (first+(layout&255)) % raid_disks;
} while (first != 0);
return 1;