Lines Matching refs:fc

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