Comment 4 for bug 497039

Revision history for this message
Loïc Minier (lool) wrote :

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;

                } while (first != 0);
                return 1;