aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2016-07-29 13:19:55 -0400
committerMike Snitzer <snitzer@redhat.com>2016-08-02 16:08:59 -0400
commit99f3c90d0d85708e7401a81ce3314e50bf7f2819 (patch)
tree97e77eb78fa2f23e30a3279caed0c08af77bdf90 /drivers/md
parentf7b32e4c021fd788f13f6785e17efbc3eb05b351 (diff)
dm flakey: error READ bios during the down_interval
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: a3998799fb4df ("dm flakey: add corrupt_bio_byte feature") Reported-by: Akira Hayakawa <ruby.wktk@gmail.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-flakey.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index 29b99fb6a16a..19db13e99466 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -289,10 +289,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
289 pb->bio_submitted = true; 289 pb->bio_submitted = true;
290 290
291 /* 291 /*
292 * Map reads as normal. 292 * Map reads as normal only if corrupt_bio_byte set.
293 */ 293 */
294 if (bio_data_dir(bio) == READ) 294 if (bio_data_dir(bio) == READ) {
295 goto map_bio; 295 /* If flags were specified, only corrupt those that match. */
296 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
297 all_corrupt_bio_flags_match(bio, fc))
298 goto map_bio;
299 else
300 return -EIO;
301 }
296 302
297 /* 303 /*
298 * Drop writes? 304 * Drop writes?
@@ -330,12 +336,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
330 336
331 /* 337 /*
332 * Corrupt successful READs while in down state. 338 * Corrupt successful READs while in down state.
333 * If flags were specified, only corrupt those that match.
334 */ 339 */
335 if (fc->corrupt_bio_byte && !error && pb->bio_submitted && 340 if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
336 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && 341 if (fc->corrupt_bio_byte)
337 all_corrupt_bio_flags_match(bio, fc)) 342 corrupt_bio_data(bio, fc);
338 corrupt_bio_data(bio, fc); 343 else
344 return -EIO;
345 }
339 346
340 return error; 347 return error;
341} 348}