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 r = dm_read_arg(_args + 3, as, &fc->corrupt_bio_flags, &ti->error); in parse_features()
160 if (test_bit(DROP_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
164 } else if (test_bit(ERROR_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
192 struct flakey_c *fc; in flakey_ctr() local
206 fc = kzalloc(sizeof(*fc), GFP_KERNEL); in flakey_ctr()
207 if (!fc) { in flakey_ctr()
211 fc->start_time = jiffies; in flakey_ctr()
220 fc->start = tmpll; in flakey_ctr()
222 r = dm_read_arg(_args, &as, &fc->up_interval, &ti->error); in flakey_ctr()
226 r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); in flakey_ctr()
230 if (!(fc->up_interval + fc->down_interval)) { in flakey_ctr()
236 if (fc->up_interval + fc->down_interval < fc->up_interval) { in flakey_ctr()
242 r = parse_features(&as, fc, ti); in flakey_ctr()
246 r = dm_get_device(ti, devname, dm_table_get_mode(ti->table), &fc->dev); in flakey_ctr()
255 ti->private = fc; in flakey_ctr()
259 kfree(fc); in flakey_ctr()
265 struct flakey_c *fc = ti->private; in flakey_dtr() local
267 dm_put_device(ti, fc->dev); in flakey_dtr()
268 kfree(fc); in flakey_dtr()
273 struct flakey_c *fc = ti->private; in flakey_map_sector() local
275 return fc->start + dm_target_offset(ti, bi_sector); in flakey_map_sector()
280 struct flakey_c *fc = ti->private; in flakey_map_bio() local
282 bio_set_dev(bio, fc->dev->bdev); in flakey_map_bio()
288 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) in corrupt_bio_data() argument
290 unsigned int corrupt_bio_byte = fc->corrupt_bio_byte - 1; in corrupt_bio_data()
306 segment[corrupt_bio_byte] = fc->corrupt_bio_value; in corrupt_bio_data()
309 bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, in corrupt_bio_data()
320 struct flakey_c *fc = ti->private; in flakey_map() local
329 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
330 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
341 if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags) && in flakey_map()
342 !test_bit(ERROR_WRITES, &fc->flags)) in flakey_map()
350 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
354 else if (test_bit(ERROR_WRITES, &fc->flags)) { in flakey_map()
362 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) { in flakey_map()
363 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
364 corrupt_bio_data(bio, fc); in flakey_map()
383 struct flakey_c *fc = ti->private; in flakey_end_io() local
390 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && in flakey_end_io()
391 all_corrupt_bio_flags_match(bio, fc)) { in flakey_end_io()
395 corrupt_bio_data(bio, fc); in flakey_end_io()
397 } else if (!test_bit(DROP_WRITES, &fc->flags) && in flakey_end_io()
398 !test_bit(ERROR_WRITES, &fc->flags)) { in flakey_end_io()
414 struct flakey_c *fc = ti->private; in flakey_status() local
423 DMEMIT("%s %llu %u %u ", fc->dev->name, in flakey_status()
424 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
425 fc->down_interval); in flakey_status()
427 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
428 error_writes = test_bit(ERROR_WRITES, &fc->flags); in flakey_status()
429 DMEMIT("%u ", drop_writes + error_writes + (fc->corrupt_bio_byte > 0) * 5); in flakey_status()
436 if (fc->corrupt_bio_byte) in flakey_status()
438 fc->corrupt_bio_byte, in flakey_status()
439 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
440 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
452 struct flakey_c *fc = ti->private; in flakey_prepare_ioctl() local
454 *bdev = fc->dev->bdev; in flakey_prepare_ioctl()
459 if (fc->start || ti->len != bdev_nr_sectors((*bdev))) in flakey_prepare_ioctl()
468 struct flakey_c *fc = ti->private; in flakey_report_zones() local
470 return dm_report_zones(fc->dev->bdev, fc->start, in flakey_report_zones()
480 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
482 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()