Lines Matching full:fc
21 #define all_corrupt_bio_flags_match(bio, fc) \ argument
22 (((bio)->bi_opf & (fc)->corrupt_bio_flags) == (fc)->corrupt_bio_flags)
53 static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, in parse_features() argument
89 if (test_and_set_bit(ERROR_READS, &fc->flags)) { in parse_features()
100 if (test_and_set_bit(DROP_WRITES, &fc->flags)) { in parse_features()
103 } else if (test_bit(ERROR_WRITES, &fc->flags)) { in parse_features()
115 if (test_and_set_bit(ERROR_WRITES, &fc->flags)) { in parse_features()
119 } else if (test_bit(DROP_WRITES, &fc->flags)) { in parse_features()
136 r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error); in parse_features()
146 fc->corrupt_bio_rw = WRITE; in parse_features()
148 fc->corrupt_bio_rw = READ; in parse_features()
158 r = dm_read_arg(_args + 2, as, &fc->corrupt_bio_value, &ti->error); in parse_features()
166 BUILD_BUG_ON(sizeof(fc->corrupt_bio_flags) != in parse_features()
169 (__force unsigned int *)&fc->corrupt_bio_flags, in parse_features()
183 r = dm_read_arg(_args + 4, as, &fc->random_read_corrupt, &ti->error); in parse_features()
196 r = dm_read_arg(_args + 4, as, &fc->random_write_corrupt, &ti->error); in parse_features()
208 if (test_bit(DROP_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
212 } else if (test_bit(ERROR_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
217 if (!fc->corrupt_bio_byte && !test_bit(ERROR_READS, &fc->flags) && in parse_features()
218 !test_bit(DROP_WRITES, &fc->flags) && !test_bit(ERROR_WRITES, &fc->flags) && in parse_features()
219 !fc->random_read_corrupt && !fc->random_write_corrupt) { in parse_features()
220 set_bit(ERROR_WRITES, &fc->flags); in parse_features()
221 set_bit(ERROR_READS, &fc->flags); in parse_features()
247 struct flakey_c *fc; in flakey_ctr() local
261 fc = kzalloc(sizeof(*fc), GFP_KERNEL); in flakey_ctr()
262 if (!fc) { in flakey_ctr()
266 fc->start_time = jiffies; in flakey_ctr()
275 fc->start = tmpll; in flakey_ctr()
277 r = dm_read_arg(_args, &as, &fc->up_interval, &ti->error); in flakey_ctr()
281 r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); in flakey_ctr()
285 if (!(fc->up_interval + fc->down_interval)) { in flakey_ctr()
291 if (fc->up_interval + fc->down_interval < fc->up_interval) { in flakey_ctr()
297 r = parse_features(&as, fc, ti); in flakey_ctr()
301 r = dm_get_device(ti, devname, dm_table_get_mode(ti->table), &fc->dev); in flakey_ctr()
310 ti->private = fc; in flakey_ctr()
314 kfree(fc); in flakey_ctr()
320 struct flakey_c *fc = ti->private; in flakey_dtr() local
322 dm_put_device(ti, fc->dev); in flakey_dtr()
323 kfree(fc); in flakey_dtr()
328 struct flakey_c *fc = ti->private; in flakey_map_sector() local
330 return fc->start + dm_target_offset(ti, bi_sector); in flakey_map_sector()
335 struct flakey_c *fc = ti->private; in flakey_map_bio() local
337 bio_set_dev(bio, fc->dev->bdev); in flakey_map_bio()
368 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) in corrupt_bio_data() argument
370 unsigned int corrupt_bio_byte = fc->corrupt_bio_byte - 1; in corrupt_bio_data()
375 corrupt_bio_common(bio, corrupt_bio_byte, fc->corrupt_bio_value); in corrupt_bio_data()
413 static struct bio *clone_bio(struct dm_target *ti, struct flakey_c *fc, struct bio *bio) in clone_bio() argument
429 bio_init(clone, fc->dev->bdev, bio->bi_inline_vecs, nr_iovecs, bio->bi_opf); in clone_bio()
480 struct flakey_c *fc = ti->private; in flakey_map() local
490 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
491 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
503 if (test_bit(ERROR_READS, &fc->flags)) in flakey_map()
511 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
514 } else if (test_bit(ERROR_WRITES, &fc->flags)) { in flakey_map()
524 if (fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) { in flakey_map()
525 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
528 if (fc->random_write_corrupt) { in flakey_map()
531 if (rem < fc->random_write_corrupt) in flakey_map()
535 struct bio *clone = clone_bio(ti, fc, bio); in flakey_map()
538 corrupt_bio_data(clone, fc); in flakey_map()
556 struct flakey_c *fc = ti->private; in flakey_end_io() local
563 if (fc->corrupt_bio_byte) { in flakey_end_io()
564 if ((fc->corrupt_bio_rw == READ) && in flakey_end_io()
565 all_corrupt_bio_flags_match(bio, fc)) { in flakey_end_io()
569 corrupt_bio_data(bio, fc); in flakey_end_io()
572 if (fc->random_read_corrupt) { in flakey_end_io()
575 if (rem < fc->random_read_corrupt) in flakey_end_io()
578 if (test_bit(ERROR_READS, &fc->flags)) { in flakey_end_io()
594 struct flakey_c *fc = ti->private; in flakey_status() local
603 DMEMIT("%s %llu %u %u", fc->dev->name, in flakey_status()
604 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
605 fc->down_interval); in flakey_status()
607 error_reads = test_bit(ERROR_READS, &fc->flags); in flakey_status()
608 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
609 error_writes = test_bit(ERROR_WRITES, &fc->flags); in flakey_status()
611 (fc->corrupt_bio_byte > 0) * 5 + in flakey_status()
612 (fc->random_read_corrupt > 0) * 2 + in flakey_status()
613 (fc->random_write_corrupt > 0) * 2); in flakey_status()
622 if (fc->corrupt_bio_byte) in flakey_status()
624 fc->corrupt_bio_byte, in flakey_status()
625 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
626 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
628 if (fc->random_read_corrupt > 0) in flakey_status()
629 DMEMIT(" random_read_corrupt %u", fc->random_read_corrupt); in flakey_status()
630 if (fc->random_write_corrupt > 0) in flakey_status()
631 DMEMIT(" random_write_corrupt %u", fc->random_write_corrupt); in flakey_status()
643 struct flakey_c *fc = ti->private; in flakey_prepare_ioctl() local
645 *bdev = fc->dev->bdev; in flakey_prepare_ioctl()
650 if (fc->start || ti->len != bdev_nr_sectors((*bdev))) in flakey_prepare_ioctl()
659 struct flakey_c *fc = ti->private; in flakey_report_zones() local
661 return dm_report_zones(fc->dev->bdev, fc->start, in flakey_report_zones()
671 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
673 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()