diff options
author | Wei Fang <fangwei1@huawei.com> | 2016-03-21 19:18:32 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-08 07:44:07 +0200 |
commit | 6541ad80d598cc810de25af437317b6e93a07232 (patch) | |
tree | 4ba4b8ea8360d948a58c22d2185b7b5005e0324a /drivers | |
parent | 238adc343f488f0fea90060a6ffa0ced9be8d3c8 (diff) |
md:raid1: fix a dead loop when read from a WriteMostly disk
commit 816b0acf3deb6d6be5d0519b286fdd4bafade905 upstream.
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>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-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 3c8ada48ca76..0b6fa15825aa 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -563,7 +563,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; |