Skip to content

Commit 816b0ac

Browse files
FWei-HWshligit
authored andcommitted
md:raid1: fix a dead loop when read from a WriteMostly disk
If first_bad == this_sector when we get the WriteMostly disk in read_balance(), valid disk will be returned with zero max_sectors. It'll lead to a dead loop in make_request(), and OOM will happen because of endless allocation of struct bio. Since we can't get data from this disk in this case, so continue for another disk. Signed-off-by: Wei Fang <fangwei1@huawei.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent c05c2ec commit 816b0ac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/raid1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
570570
if (best_dist_disk < 0) {
571571
if (is_badblock(rdev, this_sector, sectors,
572572
&first_bad, &bad_sectors)) {
573-
if (first_bad < this_sector)
573+
if (first_bad <= this_sector)
574574
/* Cannot use this */
575575
continue;
576576
best_good_sectors = first_bad - this_sector;

0 commit comments

Comments
 (0)