diff options
author | Tomáš Hodek <tomas.hodek@volny.cz> | 2015-02-22 19:00:38 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2015-02-24 19:37:02 -0500 |
commit | d1901ef099c38afd11add4cfb3312c02ef21ec4a (patch) | |
tree | 75becab74c257df726f895e5dc477f2883cd34b9 | |
parent | c517d838eb7d07bbe9507871fab3931deccff539 (diff) |
md/raid1: fix read balance when a drive is write-mostly.
When a drive is marked write-mostly it should only be the
target of reads if there is no other option.
This behaviour was broken by
commit 9dedf60313fa4dddfd5b9b226a0ef12a512bf9dc
md/raid1: read balance chooses idlest disk for SSD
which causes a write-mostly device to be *preferred* is some cases.
Restore correct behaviour by checking and setting
best_dist_disk and best_pending_disk rather than best_disk.
We only need to test one of these as they are both changed
from -1 or >=0 at the same time.
As we leave min_pending and best_dist unchanged, any non-write-mostly
device will appear better than the write-mostly device.
Reported-by: Tomáš Hodek <tomas.hodek@volny.cz>
Reported-by: Dark Penguin <darkpenguin@yandex.ru>
Signed-off-by: NeilBrown <neilb@suse.de>
Link: http://marc.info/?l=linux-raid&m=135982797322422
Fixes: 9dedf60313fa4dddfd5b9b226a0ef12a512bf9dc
Cc: stable@vger.kernel.org (3.6+)
-rw-r--r-- | drivers/md/raid1.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4153da5d4011..d34e238afa54 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -560,7 +560,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect | |||
560 | if (test_bit(WriteMostly, &rdev->flags)) { | 560 | if (test_bit(WriteMostly, &rdev->flags)) { |
561 | /* Don't balance among write-mostly, just | 561 | /* Don't balance among write-mostly, just |
562 | * use the first as a last resort */ | 562 | * use the first as a last resort */ |
563 | if (best_disk < 0) { | 563 | if (best_dist_disk < 0) { |
564 | if (is_badblock(rdev, this_sector, sectors, | 564 | if (is_badblock(rdev, this_sector, sectors, |
565 | &first_bad, &bad_sectors)) { | 565 | &first_bad, &bad_sectors)) { |
566 | if (first_bad < this_sector) | 566 | if (first_bad < this_sector) |
@@ -569,7 +569,8 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect | |||
569 | best_good_sectors = first_bad - this_sector; | 569 | best_good_sectors = first_bad - this_sector; |
570 | } else | 570 | } else |
571 | best_good_sectors = sectors; | 571 | best_good_sectors = sectors; |
572 | best_disk = disk; | 572 | best_dist_disk = disk; |
573 | best_pending_disk = disk; | ||
573 | } | 574 | } |
574 | continue; | 575 | continue; |
575 | } | 576 | } |