Commit 299f6230 authored by Mike Snitzer's avatar Mike Snitzer

dm flakey: fix reads to be issued if drop_writes configured

v4.8-rc3 commit 99f3c90d ("dm flakey: error READ bios during the
down_interval") overlooked the 'drop_writes' feature, which is meant to
allow reads to be issued rather than errored, during the down_interval.

Fixes: 99f3c90d ("dm flakey: error READ bios during the down_interval")
Reported-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
parent fa8410b3
...@@ -289,15 +289,13 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) ...@@ -289,15 +289,13 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
pb->bio_submitted = true; pb->bio_submitted = true;
/* /*
* Map reads as normal only if corrupt_bio_byte set. * Error reads if neither corrupt_bio_byte or drop_writes are set.
* Otherwise, flakey_end_io() will decide if the reads should be modified.
*/ */
if (bio_data_dir(bio) == READ) { if (bio_data_dir(bio) == READ) {
/* If flags were specified, only corrupt those that match. */ if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags))
if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
all_corrupt_bio_flags_match(bio, fc))
goto map_bio;
else
return -EIO; return -EIO;
goto map_bio;
} }
/* /*
...@@ -334,14 +332,21 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) ...@@ -334,14 +332,21 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
struct flakey_c *fc = ti->private; struct flakey_c *fc = ti->private;
struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
/*
* Corrupt successful READs while in down state.
*/
if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
if (fc->corrupt_bio_byte) if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
all_corrupt_bio_flags_match(bio, fc)) {
/*
* Corrupt successful matching READs while in down state.
*/
corrupt_bio_data(bio, fc); corrupt_bio_data(bio, fc);
else
} else if (!test_bit(DROP_WRITES, &fc->flags)) {
/*
* Error read during the down_interval if drop_writes
* wasn't configured.
*/
return -EIO; 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