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 commit9dedf60313
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:9dedf60313
Cc: stable@vger.kernel.org (3.6+)
This commit is contained in:
Родитель
c517d838eb
Коммит
d1901ef099
|
@ -560,7 +560,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
|
||||||
if (test_bit(WriteMostly, &rdev->flags)) {
|
if (test_bit(WriteMostly, &rdev->flags)) {
|
||||||
/* Don't balance among write-mostly, just
|
/* Don't balance among write-mostly, just
|
||||||
* use the first as a last resort */
|
* use the first as a last resort */
|
||||||
if (best_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)
|
||||||
|
@ -569,7 +569,8 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
|
||||||
best_good_sectors = first_bad - this_sector;
|
best_good_sectors = first_bad - this_sector;
|
||||||
} else
|
} else
|
||||||
best_good_sectors = sectors;
|
best_good_sectors = sectors;
|
||||||
best_disk = disk;
|
best_dist_disk = disk;
|
||||||
|
best_pending_disk = disk;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче