Skip to content

Commit 80b4812

Browse files
committed
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>
1 parent cb13ff6 commit 80b4812

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/md/raid10.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,14 +1512,16 @@ static int _enough(struct r10conf *conf, struct geom *geo, int ignore)
15121512
do {
15131513
int n = conf->copies;
15141514
int cnt = 0;
1515+
int this = first;
15151516
while (n--) {
1516-
if (conf->mirrors[first].rdev &&
1517-
first != ignore)
1517+
if (conf->mirrors[this].rdev &&
1518+
this != ignore)
15181519
cnt++;
1519-
first = (first+1) % geo->raid_disks;
1520+
this = (this+1) % geo->raid_disks;
15201521
}
15211522
if (cnt == 0)
15221523
return 0;
1524+
first = (first + geo->near_copies) % geo->raid_disks;
15231525
} while (first != 0);
15241526
return 1;
15251527
}

0 commit comments

Comments
 (0)