diff options
author | NeilBrown <neilb@suse.de> | 2012-09-26 22:35:21 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-09-26 22:35:21 -0400 |
commit | 80b4812407c6b1f66a4f2430e69747a13f010839 (patch) | |
tree | 5c2e31a8cbbfabf83d4251c8299ade26934f79fb /drivers/md | |
parent | cb13ff69d6d61ab06285e3ef652f45ecda73e135 (diff) |
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 <jakub@gooseman.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid10.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 1c2eb38f3c51..0138a727c1f3 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) | |||
1512 | do { | 1512 | do { |
1513 | int n = conf->copies; | 1513 | int n = conf->copies; |
1514 | int cnt = 0; | 1514 | int cnt = 0; |
1515 | int this = first; | ||
1515 | while (n--) { | 1516 | while (n--) { |
1516 | if (conf->mirrors[first].rdev && | 1517 | if (conf->mirrors[this].rdev && |
1517 | first != ignore) | 1518 | this != ignore) |
1518 | cnt++; | 1519 | cnt++; |
1519 | first = (first+1) % geo->raid_disks; | 1520 | this = (this+1) % geo->raid_disks; |
1520 | } | 1521 | } |
1521 | if (cnt == 0) | 1522 | if (cnt == 0) |
1522 | return 0; | 1523 | return 0; |
1524 | first = (first + geo->near_copies) % geo->raid_disks; | ||
1523 | } while (first != 0); | 1525 | } while (first != 0); |
1524 | return 1; | 1526 | return 1; |
1525 | } | 1527 | } |