]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
Fix 'enough' function for RAID10.
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index cb97816c346f5d4b5e88068d423090d00c10a2bc..427a8cf7724c686d00743b98937a76988ac18064 100644 (file)
--- 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;