From: NeilBrown Date: Thu, 27 Sep 2012 02:35:21 +0000 (+1000) Subject: md/raid10: fix "enough" function for detecting if array is failed. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=80b4812407c6b1f66a4f2430e69747a13f010839;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git md/raid10: fix "enough" function for detecting if array is failed. 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. This bug makes it possible to run arrays without enough drives present, which is dangerous. It is appropriate for an -stable kernel, but will almost certainly need to be modified for some of them. Cc: stable@vger.kernel.org Reported-by: Jakub Husák Signed-off-by: NeilBrown --- diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 1c2eb38f3c5..0138a727c1f 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1512,14 +1512,16 @@ static int _enough(struct r10conf *conf, struct geom *geo, int ignore) do { int n = conf->copies; int cnt = 0; + int this = first; while (n--) { - if (conf->mirrors[first].rdev && - first != ignore) + if (conf->mirrors[this].rdev && + this != ignore) cnt++; - first = (first+1) % geo->raid_disks; + this = (this+1) % geo->raid_disks; } if (cnt == 0) return 0; + first = (first + geo->near_copies) % geo->raid_disks; } while (first != 0); return 1; }