Lines Matching refs:fc

18 #define all_corrupt_bio_flags_match(bio, fc)	\  argument
19 (((bio)->bi_rw & (fc)->corrupt_bio_flags) == (fc)->corrupt_bio_flags)
46 static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, in parse_features() argument
76 if (test_and_set_bit(DROP_WRITES, &fc->flags)) { in parse_features()
93 r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error); in parse_features()
103 fc->corrupt_bio_rw = WRITE; in parse_features()
105 fc->corrupt_bio_rw = READ; in parse_features()
115 r = dm_read_arg(_args + 2, as, &fc->corrupt_bio_value, &ti->error); in parse_features()
123 r = dm_read_arg(_args + 3, as, &fc->corrupt_bio_flags, &ti->error); in parse_features()
135 if (test_bit(DROP_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { in parse_features()
163 struct flakey_c *fc; in flakey_ctr() local
177 fc = kzalloc(sizeof(*fc), GFP_KERNEL); in flakey_ctr()
178 if (!fc) { in flakey_ctr()
182 fc->start_time = jiffies; in flakey_ctr()
191 fc->start = tmpll; in flakey_ctr()
193 r = dm_read_arg(_args, &as, &fc->up_interval, &ti->error); in flakey_ctr()
197 r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); in flakey_ctr()
201 if (!(fc->up_interval + fc->down_interval)) { in flakey_ctr()
206 if (fc->up_interval + fc->down_interval < fc->up_interval) { in flakey_ctr()
211 r = parse_features(&as, fc, ti); in flakey_ctr()
215 r = dm_get_device(ti, devname, dm_table_get_mode(ti->table), &fc->dev); in flakey_ctr()
224 ti->private = fc; in flakey_ctr()
228 kfree(fc); in flakey_ctr()
234 struct flakey_c *fc = ti->private; in flakey_dtr() local
236 dm_put_device(ti, fc->dev); in flakey_dtr()
237 kfree(fc); in flakey_dtr()
242 struct flakey_c *fc = ti->private; in flakey_map_sector() local
244 return fc->start + dm_target_offset(ti, bi_sector); in flakey_map_sector()
249 struct flakey_c *fc = ti->private; in flakey_map_bio() local
251 bio->bi_bdev = fc->dev->bdev; in flakey_map_bio()
257 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) in corrupt_bio_data() argument
265 if (data && bio_bytes >= fc->corrupt_bio_byte) { in corrupt_bio_data()
266 data[fc->corrupt_bio_byte - 1] = fc->corrupt_bio_value; in corrupt_bio_data()
270 bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, in corrupt_bio_data()
278 struct flakey_c *fc = ti->private; in flakey_map() local
284 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
285 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
300 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
308 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) { in flakey_map()
309 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
310 corrupt_bio_data(bio, fc); in flakey_map()
328 struct flakey_c *fc = ti->private; in flakey_end_io() local
335 if (fc->corrupt_bio_byte && !error && pb->bio_submitted && in flakey_end_io()
336 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && in flakey_end_io()
337 all_corrupt_bio_flags_match(bio, fc)) in flakey_end_io()
338 corrupt_bio_data(bio, fc); in flakey_end_io()
347 struct flakey_c *fc = ti->private; in flakey_status() local
356 DMEMIT("%s %llu %u %u ", fc->dev->name, in flakey_status()
357 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
358 fc->down_interval); in flakey_status()
360 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
361 DMEMIT("%u ", drop_writes + (fc->corrupt_bio_byte > 0) * 5); in flakey_status()
366 if (fc->corrupt_bio_byte) in flakey_status()
368 fc->corrupt_bio_byte, in flakey_status()
369 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
370 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
379 struct flakey_c *fc = ti->private; in flakey_prepare_ioctl() local
381 *bdev = fc->dev->bdev; in flakey_prepare_ioctl()
386 if (fc->start || in flakey_prepare_ioctl()
394 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
396 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()