瀏覽代碼

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>
Wei Fang 9 年之前
父節點
當前提交
816b0acf3d
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/md/raid1.c

+ 1 - 1
drivers/md/raid1.c

@@ -570,7 +570,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
 			if (best_dist_disk < 0) {
 			if (best_dist_disk < 0) {
 				if (is_badblock(rdev, this_sector, sectors,
 				if (is_badblock(rdev, this_sector, sectors,
 						&first_bad, &bad_sectors)) {
 						&first_bad, &bad_sectors)) {
-					if (first_bad < this_sector)
+					if (first_bad <= this_sector)
 						/* Cannot use this */
 						/* Cannot use this */
 						continue;
 						continue;
 					best_good_sectors = first_bad - this_sector;
 					best_good_sectors = first_bad - this_sector;