From: NeilBrown Date: Thu, 27 Sep 2012 06:58:44 +0000 (+1000) Subject: Fix 'enough' function for RAID10. X-Git-Tag: mdadm-3.2.6~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2117ad1dd1b79cf6d02a065d9e38076aa9f4788d;p=thirdparty%2Fmdadm.git Fix 'enough' function for RAID10. 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 Signed-off-by: NeilBrown --- diff --git a/util.c b/util.c index 83f31872..eef0d6f0 100644 --- a/util.c +++ b/util.c @@ -332,14 +332,15 @@ int enough(int level, int raid_disks, int layout, int clean, char *avail) /* 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;