• Home
  • Raw
  • Download

Lines Matching full: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()
309 segment[corrupt_bio_byte] = fc->corrupt_bio_value; in corrupt_bio_data()
312 bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, in corrupt_bio_data()
323 struct flakey_c *fc = ti->private; in flakey_map() local
332 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
333 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
344 if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags) && in flakey_map()
345 !test_bit(ERROR_WRITES, &fc->flags)) in flakey_map()
353 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
357 else if (test_bit(ERROR_WRITES, &fc->flags)) { in flakey_map()
365 if (fc->corrupt_bio_byte) { in flakey_map()
366 if (fc->corrupt_bio_rw == WRITE) { in flakey_map()
367 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
368 corrupt_bio_data(bio, fc); in flakey_map()
388 struct flakey_c *fc = ti->private; in flakey_end_io() local
395 if (fc->corrupt_bio_byte) { in flakey_end_io()
396 if ((fc->corrupt_bio_rw == READ) && in flakey_end_io()
397 all_corrupt_bio_flags_match(bio, fc)) { in flakey_end_io()
401 corrupt_bio_data(bio, fc); in flakey_end_io()
403 } else if (!test_bit(DROP_WRITES, &fc->flags) && in flakey_end_io()
404 !test_bit(ERROR_WRITES, &fc->flags)) { in flakey_end_io()
420 struct flakey_c *fc = ti->private; in flakey_status() local
429 DMEMIT("%s %llu %u %u ", fc->dev->name, in flakey_status()
430 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
431 fc->down_interval); in flakey_status()
433 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
434 error_writes = test_bit(ERROR_WRITES, &fc->flags); in flakey_status()
435 DMEMIT("%u ", drop_writes + error_writes + (fc->corrupt_bio_byte > 0) * 5); in flakey_status()
442 if (fc->corrupt_bio_byte) in flakey_status()
444 fc->corrupt_bio_byte, in flakey_status()
445 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
446 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 || in flakey_prepare_ioctl()
471 struct flakey_c *fc = ti->private; in flakey_report_zones() local
474 args->start = fc->start; in flakey_report_zones()
475 return blkdev_report_zones(fc->dev->bdev, sector, nr_zones, 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()