Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 307729c8 authored by NeilBrown's avatar NeilBrown
Browse files

md/raid1: perform bad-block tests for WriteMostly devices too.



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 d2eb35ac and so the patch
is suitable for 3.1.x and 3.2.x

Reported-and-tested-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Reported-and-tested-by: default avatarArt -kwaak- van Breemen <ard@telegraafnet.nl>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Cc: stable@vger.kernel.org
parent f2a371c5
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -531,8 +531,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