As pointed out by cjwatson, mdadm's util.c gets this right:
int enough(int level, int raid_disks, int layout, int clean,
char *avail, int avail_disks)
{
int copies, first;
switch (level) {
case 10:
/* This is the tricky one - we need to check
* which actual disks are present.
*/ copies = (layout&255)* ((layout>>8) & 255); first=0;
do { /* there must be one of the 'copies' form 'first' */ int n = copies; int cnt=0; while (n--) { if (avail[first]) cnt++; first = (first+1) % raid_disks; } if (cnt == 0) return 0;
As pointed out by cjwatson, mdadm's util.c gets this right:
copies = (layout&255)* ((layout>>8) & 255);
first= 0;
/* there must be one of the 'copies' form 'first' */
int n = copies;
int cnt=0;
while (n--) {
if (avail[first])
cnt+ +;
first = (first+1) % raid_disks;
}
if (cnt == 0)
return 0;
int enough(int level, int raid_disks, int layout, int clean,
char *avail, int avail_disks)
{
int copies, first;
switch (level) {
case 10:
/* This is the tricky one - we need to check
* which actual disks are present.
*/
do {
} while (first != 0);
return 1;