From b3ec716d009ec5f8054ae0cdee38a44bfb60524e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 3 Oct 2012 13:53:46 +1000 Subject: [PATCH] Fix 'enough' function for RAID10. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util.c b/util.c index cb97816c..427a8cf7 100644 --- a/util.c +++ b/util.c @@ -344,14 +344,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; -- 2.39.2