Lines Matching refs:fc
18 #define all_corrupt_bio_flags_match(bio, fc) \ argument
19 (((bio)->bi_opf & (fc)->corrupt_bio_flags) == (fc)->corrupt_bio_flags)
47 static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, in parse_features() argument
82 if (test_and_set_bit(DROP_WRITES, &fc->flags)) { in parse_features()
85 } else if (test_bit(ERROR_WRITES, &fc->flags)) { in parse_features()
97 if (test_and_set_bit(ERROR_WRITES, &fc->flags)) { in parse_features()
101 } else if (test_bit(DROP_WRITES, &fc->flags)) { in parse_features()
118 r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error); in parse_features()
128 fc->corrupt_bio_rw = WRITE; in parse_features()
130 fc->corrupt_bio_rw = READ; in parse_features()
140 r = dm_read_arg(_args + 2, as, &fc->corrupt_bio_value, &ti->error); in parse_features()
148 BUILD_BUG_ON(sizeof(fc->corrupt_bio_flags) != in parse_features()
151 (__force unsigned *)&fc->corrupt_bio_flags, in parse_features()
164 if (test_bit(DROP_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
168 } else if (test_bit(ERROR_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
196 struct flakey_c *fc; in flakey_ctr() local
210 fc = kzalloc(sizeof(*fc), GFP_KERNEL); in flakey_ctr()
211 if (!fc) { in flakey_ctr()
215 fc->start_time = jiffies; in flakey_ctr()
224 fc->start = tmpll; in flakey_ctr()
226 r = dm_read_arg(_args, &as, &fc->up_interval, &ti->error); in flakey_ctr()
230 r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); in flakey_ctr()
234 if (!(fc->up_interval + fc->down_interval)) { in flakey_ctr()
240 if (fc->up_interval + fc->down_interval < fc->up_interval) { in flakey_ctr()
246 r = parse_features(&as, fc, ti); in flakey_ctr()
250 r = dm_get_device(ti, devname, dm_table_get_mode(ti->table), &fc->dev); in flakey_ctr()
259 ti->private = fc; in flakey_ctr()
263 kfree(fc); in flakey_ctr()
269 struct flakey_c *fc = ti->private; in flakey_dtr() local
271 dm_put_device(ti, fc->dev); in flakey_dtr()
272 kfree(fc); in flakey_dtr()
277 struct flakey_c *fc = ti->private; in flakey_map_sector() local
279 return fc->start + dm_target_offset(ti, bi_sector); in flakey_map_sector()
284 struct flakey_c *fc = ti->private; in flakey_map_bio() local
286 bio_set_dev(bio, fc->dev->bdev); in flakey_map_bio()
290 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) in corrupt_bio_data() argument
292 unsigned int corrupt_bio_byte = fc->corrupt_bio_byte - 1; in corrupt_bio_data()
308 segment[corrupt_bio_byte] = fc->corrupt_bio_value; in corrupt_bio_data()
311 bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, in corrupt_bio_data()
322 struct flakey_c *fc = ti->private; in flakey_map() local
331 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
332 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
343 if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags) && in flakey_map()
344 !test_bit(ERROR_WRITES, &fc->flags)) in flakey_map()
352 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
356 else if (test_bit(ERROR_WRITES, &fc->flags)) { in flakey_map()
364 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) { in flakey_map()
365 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
366 corrupt_bio_data(bio, fc); in flakey_map()
385 struct flakey_c *fc = ti->private; in flakey_end_io() local
392 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && in flakey_end_io()
393 all_corrupt_bio_flags_match(bio, fc)) { in flakey_end_io()
397 corrupt_bio_data(bio, fc); in flakey_end_io()
399 } else if (!test_bit(DROP_WRITES, &fc->flags) && in flakey_end_io()
400 !test_bit(ERROR_WRITES, &fc->flags)) { in flakey_end_io()
416 struct flakey_c *fc = ti->private; in flakey_status() local
425 DMEMIT("%s %llu %u %u ", fc->dev->name, in flakey_status()
426 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
427 fc->down_interval); in flakey_status()
429 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
430 error_writes = test_bit(ERROR_WRITES, &fc->flags); in flakey_status()
431 DMEMIT("%u ", drop_writes + error_writes + (fc->corrupt_bio_byte > 0) * 5); in flakey_status()
438 if (fc->corrupt_bio_byte) in flakey_status()
440 fc->corrupt_bio_byte, in flakey_status()
441 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
442 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
454 struct flakey_c *fc = ti->private; in flakey_prepare_ioctl() local
456 *bdev = fc->dev->bdev; in flakey_prepare_ioctl()
461 if (fc->start || ti->len != bdev_nr_sectors((*bdev))) in flakey_prepare_ioctl()
470 struct flakey_c *fc = ti->private; in flakey_report_zones() local
472 return dm_report_zones(fc->dev->bdev, fc->start, in flakey_report_zones()
482 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
484 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()