Skip to content

Commit 352f526

Browse files
neilbrowngregkh
authored andcommitted
md/raid10: fix "enough" function for detecting if array is failed.
commit 80b4812 upstream. 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. Reported-by: Jakub Husák <jakub@gooseman.cz> Signed-off-by: NeilBrown <neilb@suse.de> [bwh: Backported to 3.2: s/geo->/conf->/] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Cc: Rui Xiang <rui.xiang@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e4bf930 commit 352f526

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
@@ -1419,14 +1419,16 @@ static int enough(struct r10conf *conf, int ignore)
14191419
do {
14201420
int n = conf->copies;
14211421
int cnt = 0;
1422+
int this = first;
14221423
while (n--) {
1423-
if (conf->mirrors[first].rdev &&
1424-
first != ignore)
1424+
if (conf->mirrors[this].rdev &&
1425+
this != ignore)
14251426
cnt++;
1426-
first = (first+1) % conf->raid_disks;
1427+
this = (this+1) % conf->raid_disks;
14271428
}
14281429
if (cnt == 0)
14291430
return 0;
1431+
first = (first + conf->near_copies) % conf->raid_disks;
14301432
} while (first != 0);
14311433
return 1;
14321434
}

0 commit comments

Comments
 (0)