aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-flakey.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-flakey.c')
-rw-r--r--drivers/md/dm-flakey.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index cc15543a6ad7..9721f2ffb1a2 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -39,6 +39,10 @@ enum feature_flag_bits {
39 DROP_WRITES 39 DROP_WRITES
40}; 40};
41 41
42struct per_bio_data {
43 bool bio_submitted;
44};
45
42static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, 46static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
43 struct dm_target *ti) 47 struct dm_target *ti)
44{ 48{
@@ -214,6 +218,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
214 218
215 ti->num_flush_requests = 1; 219 ti->num_flush_requests = 1;
216 ti->num_discard_requests = 1; 220 ti->num_discard_requests = 1;
221 ti->per_bio_data_size = sizeof(struct per_bio_data);
217 ti->private = fc; 222 ti->private = fc;
218 return 0; 223 return 0;
219 224
@@ -265,11 +270,12 @@ static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc)
265 } 270 }
266} 271}
267 272
268static int flakey_map(struct dm_target *ti, struct bio *bio, 273static int flakey_map(struct dm_target *ti, struct bio *bio)
269 union map_info *map_context)
270{ 274{
271 struct flakey_c *fc = ti->private; 275 struct flakey_c *fc = ti->private;
272 unsigned elapsed; 276 unsigned elapsed;
277 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
278 pb->bio_submitted = false;
273 279
274 /* Are we alive ? */ 280 /* Are we alive ? */
275 elapsed = (jiffies - fc->start_time) / HZ; 281 elapsed = (jiffies - fc->start_time) / HZ;
@@ -277,7 +283,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio,
277 /* 283 /*
278 * Flag this bio as submitted while down. 284 * Flag this bio as submitted while down.
279 */ 285 */
280 map_context->ll = 1; 286 pb->bio_submitted = true;
281 287
282 /* 288 /*
283 * Map reads as normal. 289 * Map reads as normal.
@@ -314,17 +320,16 @@ map_bio:
314 return DM_MAPIO_REMAPPED; 320 return DM_MAPIO_REMAPPED;
315} 321}
316 322
317static int flakey_end_io(struct dm_target *ti, struct bio *bio, 323static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
318 int error, union map_info *map_context)
319{ 324{
320 struct flakey_c *fc = ti->private; 325 struct flakey_c *fc = ti->private;
321 unsigned bio_submitted_while_down = map_context->ll; 326 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
322 327
323 /* 328 /*
324 * Corrupt successful READs while in down state. 329 * Corrupt successful READs while in down state.
325 * If flags were specified, only corrupt those that match. 330 * If flags were specified, only corrupt those that match.
326 */ 331 */
327 if (fc->corrupt_bio_byte && !error && bio_submitted_while_down && 332 if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
328 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && 333 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
329 all_corrupt_bio_flags_match(bio, fc)) 334 all_corrupt_bio_flags_match(bio, fc))
330 corrupt_bio_data(bio, fc); 335 corrupt_bio_data(bio, fc);
@@ -406,7 +411,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_
406 411
407static struct target_type flakey_target = { 412static struct target_type flakey_target = {
408 .name = "flakey", 413 .name = "flakey",
409 .version = {1, 2, 0}, 414 .version = {1, 3, 0},
410 .module = THIS_MODULE, 415 .module = THIS_MODULE,
411 .ctr = flakey_ctr, 416 .ctr = flakey_ctr,
412 .dtr = flakey_dtr, 417 .dtr = flakey_dtr,