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)
54 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()
221 set_bit(ERROR_WRITES, &fc->flags); in parse_features()
222 set_bit(ERROR_READS, &fc->flags); in parse_features()
248 struct flakey_c *fc; in flakey_ctr() local
262 fc = kzalloc(sizeof(*fc), GFP_KERNEL); in flakey_ctr()
263 if (!fc) { in flakey_ctr()
267 fc->start_time = jiffies; in flakey_ctr()
276 fc->start = tmpll; in flakey_ctr()
278 r = dm_read_arg(_args, &as, &fc->up_interval, &ti->error); in flakey_ctr()
282 r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); in flakey_ctr()
286 if (!(fc->up_interval + fc->down_interval)) { in flakey_ctr()
292 if (fc->up_interval + fc->down_interval < fc->up_interval) { in flakey_ctr()
298 r = parse_features(&as, fc, ti); in flakey_ctr()
302 r = dm_get_device(ti, devname, dm_table_get_mode(ti->table), &fc->dev); in flakey_ctr()
311 ti->private = fc; in flakey_ctr()
315 kfree(fc); in flakey_ctr()
321 struct flakey_c *fc = ti->private; in flakey_dtr() local
323 dm_put_device(ti, fc->dev); in flakey_dtr()
324 kfree(fc); in flakey_dtr()
329 struct flakey_c *fc = ti->private; in flakey_map_sector() local
331 return fc->start + dm_target_offset(ti, bi_sector); in flakey_map_sector()
336 struct flakey_c *fc = ti->private; in flakey_map_bio() local
338 bio_set_dev(bio, fc->dev->bdev); in flakey_map_bio()
370 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc, in corrupt_bio_data() argument
373 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, start); in corrupt_bio_data()
410 static struct bio *clone_bio(struct dm_target *ti, struct flakey_c *fc, struct bio *bio) in clone_bio() argument
426 bio_init(clone, fc->dev->bdev, clone->bi_inline_vecs, nr_iovecs, bio->bi_opf); in clone_bio()
477 struct flakey_c *fc = ti->private; in flakey_map() local
487 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
488 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
501 if (test_bit(ERROR_READS, &fc->flags)) in flakey_map()
509 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
512 } 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()
558 struct flakey_c *fc = ti->private; in flakey_end_io() local
565 if (fc->corrupt_bio_byte) { in flakey_end_io()
566 if ((fc->corrupt_bio_rw == READ) && in flakey_end_io()
567 all_corrupt_bio_flags_match(bio, fc)) { in flakey_end_io()
571 corrupt_bio_data(bio, fc, pb->saved_iter); in flakey_end_io()
574 if (fc->random_read_corrupt) { in flakey_end_io()
577 if (rem < fc->random_read_corrupt) in flakey_end_io()
580 if (test_bit(ERROR_READS, &fc->flags)) { in flakey_end_io()
596 struct flakey_c *fc = ti->private; in flakey_status() local
605 DMEMIT("%s %llu %u %u", fc->dev->name, in flakey_status()
606 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
607 fc->down_interval); in flakey_status()
609 error_reads = test_bit(ERROR_READS, &fc->flags); in flakey_status()
610 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
611 error_writes = test_bit(ERROR_WRITES, &fc->flags); in flakey_status()
613 (fc->corrupt_bio_byte > 0) * 5 + in flakey_status()
614 (fc->random_read_corrupt > 0) * 2 + in flakey_status()
615 (fc->random_write_corrupt > 0) * 2); in flakey_status()
624 if (fc->corrupt_bio_byte) in flakey_status()
626 fc->corrupt_bio_byte, in flakey_status()
627 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
628 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
630 if (fc->random_read_corrupt > 0) in flakey_status()
631 DMEMIT(" random_read_corrupt %u", fc->random_read_corrupt); in flakey_status()
632 if (fc->random_write_corrupt > 0) in flakey_status()
633 DMEMIT(" random_write_corrupt %u", fc->random_write_corrupt); in flakey_status()
645 struct flakey_c *fc = ti->private; in flakey_prepare_ioctl() local
647 *bdev = fc->dev->bdev; in flakey_prepare_ioctl()
652 if (fc->start || ti->len != bdev_nr_sectors((*bdev))) in flakey_prepare_ioctl()
661 struct flakey_c *fc = ti->private; in flakey_report_zones() local
663 return dm_report_zones(fc->dev->bdev, fc->start, in flakey_report_zones()
673 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
675 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()