diff options
author | Wei Fang <fangwei1@huawei.com> | 2016-03-21 19:18:32 +0800 |
---|---|---|
committer | Sasha Levin <alexander.levin@verizon.com> | 2017-06-13 09:29:18 -0400 |
commit | d0388c0e2556ea797bc433618f54238f0c7b9fcf (patch) | |
tree | 3d2bf553edceca14fb0416a956fcf75eaf8c10cb | |
parent | f364181f7aa2e6dc6ae837da02c7c7811023c2cd (diff) |
md:raid1: fix a dead loop when read from a WriteMostly disk
[ Upstream commit 816b0acf3deb6d6be5d0519b286fdd4bafade905 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r-- | drivers/md/raid1.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index bff6c1c7fecb..2b4e51c0544c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -569,7 +569,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect if (best_dist_disk < 0) { if (is_badblock(rdev, this_sector, sectors, &first_bad, &bad_sectors)) { - if (first_bad < this_sector) + if (first_bad <= this_sector) /* Cannot use this */ continue; best_good_sectors = first_bad - this_sector; |