summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorWei Fang <fangwei1@huawei.com>2016-03-21 19:18:32 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-02 21:19:48 -0700
commit49b2fe4b020776640268a5d75c5eca712fcc7b01 (patch)
tree45545c59625e31ec302a230f599aec6140c8fdfe /drivers/md
parent28320756e78b3e8f1520bc1c34b23a3df452569e (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/md')
-rw-r--r--drivers/md/raid1.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 9be39988bf06..d81be5e471d0 100644
--- a/drivers/md/raid1.c
+++ b/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 (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;