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
296 if (data && bio_bytes >= fc->corrupt_bio_byte) { in corrupt_bio_data()
297 data[fc->corrupt_bio_byte - 1] = fc->corrupt_bio_value; in corrupt_bio_data()
301 bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, in corrupt_bio_data()
309 struct flakey_c *fc = ti->private; in flakey_map() local
323 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
324 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
335 if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags) && in flakey_map()
336 !test_bit(ERROR_WRITES, &fc->flags)) in flakey_map()
344 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
348 else if (test_bit(ERROR_WRITES, &fc->flags)) { in flakey_map()
356 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) { in flakey_map()
357 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
358 corrupt_bio_data(bio, fc); in flakey_map()
377 struct flakey_c *fc = ti->private; in flakey_end_io() local
384 dm_remap_zone_report(ti, bio, fc->start); in flakey_end_io()
389 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && in flakey_end_io()
390 all_corrupt_bio_flags_match(bio, fc)) { in flakey_end_io()
394 corrupt_bio_data(bio, fc); in flakey_end_io()
396 } else if (!test_bit(DROP_WRITES, &fc->flags) && in flakey_end_io()
397 !test_bit(ERROR_WRITES, &fc->flags)) { in flakey_end_io()
413 struct flakey_c *fc = ti->private; in flakey_status() local
422 DMEMIT("%s %llu %u %u ", fc->dev->name, in flakey_status()
423 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
424 fc->down_interval); in flakey_status()
426 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
427 error_writes = test_bit(ERROR_WRITES, &fc->flags); in flakey_status()
428 DMEMIT("%u ", drop_writes + error_writes + (fc->corrupt_bio_byte > 0) * 5); in flakey_status()
435 if (fc->corrupt_bio_byte) in flakey_status()
437 fc->corrupt_bio_byte, in flakey_status()
438 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
439 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
447 struct flakey_c *fc = ti->private; in flakey_prepare_ioctl() local
449 *bdev = fc->dev->bdev; in flakey_prepare_ioctl()
454 if (fc->start || in flakey_prepare_ioctl()
462 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
464 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()