Commit a774ae8f authored by Mike Snitzer's avatar Mike Snitzer Committed by Ben Hutchings

dm flakey: error READ bios during the down_interval

commit 99f3c90d upstream.

When the corrupt_bio_byte feature was introduced it caused READ bios to
no longer be errored with -EIO during the down_interval.  This had to do
with the complexity of needing to submit READs if the corrupt_bio_byte
feature was used.

Fix it so READ bios are properly errored with -EIO; doing so early in
flakey_map() as long as there isn't a match for the corrupt_bio_byte
feature.

Fixes: a3998799 ("dm flakey: add corrupt_bio_byte feature")
Reported-by: default avatarAkira Hayakawa <ruby.wktk@gmail.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent ada56adf
...@@ -287,10 +287,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) ...@@ -287,10 +287,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
pb->bio_submitted = true; pb->bio_submitted = true;
/* /*
* Map reads as normal. * Map reads as normal only if corrupt_bio_byte set.
*/ */
if (bio_data_dir(bio) == READ) if (bio_data_dir(bio) == READ) {
goto map_bio; /* If flags were specified, only corrupt those that match. */
if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
all_corrupt_bio_flags_match(bio, fc))
goto map_bio;
else
return -EIO;
}
/* /*
* Drop writes? * Drop writes?
...@@ -328,12 +334,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) ...@@ -328,12 +334,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
/* /*
* Corrupt successful READs while in down state. * Corrupt successful READs while in down state.
* If flags were specified, only corrupt those that match.
*/ */
if (fc->corrupt_bio_byte && !error && pb->bio_submitted && if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
(bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && if (fc->corrupt_bio_byte)
all_corrupt_bio_flags_match(bio, fc)) corrupt_bio_data(bio, fc);
corrupt_bio_data(bio, fc); else
return -EIO;
}
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment