diff options
author | NeilBrown <neilb@suse.de> | 2012-01-09 01:41:51 +1100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-25 16:13:20 -0800 |
commit | 45c5b2b95f829018321325129d824a6154d5f955 (patch) | |
tree | e4448b152da9d1e3a27fcb8ea8f2193f7d029b31 /drivers | |
parent | ee1f334f2f580ff09f7c1f83be46aa2bbb4d5f6a (diff) |
md/raid1: perform bad-block tests for WriteMostly devices too.
commit 307729c8bc5b5a41361af8af95906eee7552acb1 upstream.
We normally try to avoid reading from write-mostly devices, but when
we do we really have to check for bad blocks and be sure not to
try reading them.
With the current code, best_good_sectors might not get set and that
causes zero-length read requests to be send down which is very
confusing.
This bug was introduced in commit d2eb35acfdccbe2 and so the patch
is suitable for 3.1.x and 3.2.x
Reported-and-tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reported-and-tested-by: Art -kwaak- van Breemen <ard@telegraafnet.nl>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/raid1.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index ede2461e79c..7d9e071f230 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -525,8 +525,17 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect if (test_bit(WriteMostly, &rdev->flags)) { /* Don't balance among write-mostly, just * use the first as a last resort */ - if (best_disk < 0) + if (best_disk < 0) { + if (is_badblock(rdev, this_sector, sectors, + &first_bad, &bad_sectors)) { + if (first_bad < this_sector) + /* Cannot use this */ + continue; + best_good_sectors = first_bad - this_sector; + } else + best_good_sectors = sectors; best_disk = disk; + } continue; } /* This is a reasonable device to use. It might |