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()
190 fc->start = tmpll; in flakey_ctr()
192 r = dm_read_arg(_args, &as, &fc->up_interval, &ti->error); in flakey_ctr()
196 r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); in flakey_ctr()
200 if (!(fc->up_interval + fc->down_interval)) { in flakey_ctr()
205 if (fc->up_interval + fc->down_interval < fc->up_interval) { in flakey_ctr()
210 r = parse_features(&as, fc, ti); in flakey_ctr()
214 if (dm_get_device(ti, devname, dm_table_get_mode(ti->table), &fc->dev)) { in flakey_ctr()
222 ti->private = fc; in flakey_ctr()
226 kfree(fc); in flakey_ctr()
232 struct flakey_c *fc = ti->private; in flakey_dtr() local
234 dm_put_device(ti, fc->dev); in flakey_dtr()
235 kfree(fc); in flakey_dtr()
240 struct flakey_c *fc = ti->private; in flakey_map_sector() local
242 return fc->start + dm_target_offset(ti, bi_sector); in flakey_map_sector()
247 struct flakey_c *fc = ti->private; in flakey_map_bio() local
249 bio->bi_bdev = fc->dev->bdev; in flakey_map_bio()
255 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) in corrupt_bio_data() argument
263 if (data && bio_bytes >= fc->corrupt_bio_byte) { in corrupt_bio_data()
264 data[fc->corrupt_bio_byte - 1] = fc->corrupt_bio_value; in corrupt_bio_data()
268 bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, in corrupt_bio_data()
276 struct flakey_c *fc = ti->private; in flakey_map() local
282 elapsed = (jiffies - fc->start_time) / HZ; in flakey_map()
283 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { in flakey_map()
298 if (test_bit(DROP_WRITES, &fc->flags)) { in flakey_map()
306 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) { in flakey_map()
307 if (all_corrupt_bio_flags_match(bio, fc)) in flakey_map()
308 corrupt_bio_data(bio, fc); in flakey_map()
326 struct flakey_c *fc = ti->private; in flakey_end_io() local
333 if (fc->corrupt_bio_byte && !error && pb->bio_submitted && in flakey_end_io()
334 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && in flakey_end_io()
335 all_corrupt_bio_flags_match(bio, fc)) in flakey_end_io()
336 corrupt_bio_data(bio, fc); in flakey_end_io()
345 struct flakey_c *fc = ti->private; in flakey_status() local
354 DMEMIT("%s %llu %u %u ", fc->dev->name, in flakey_status()
355 (unsigned long long)fc->start, fc->up_interval, in flakey_status()
356 fc->down_interval); in flakey_status()
358 drop_writes = test_bit(DROP_WRITES, &fc->flags); in flakey_status()
359 DMEMIT("%u ", drop_writes + (fc->corrupt_bio_byte > 0) * 5); in flakey_status()
364 if (fc->corrupt_bio_byte) in flakey_status()
366 fc->corrupt_bio_byte, in flakey_status()
367 (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', in flakey_status()
368 fc->corrupt_bio_value, fc->corrupt_bio_flags); in flakey_status()
376 struct flakey_c *fc = ti->private; in flakey_ioctl() local
377 struct dm_dev *dev = fc->dev; in flakey_ioctl()
383 if (fc->start || in flakey_ioctl()
393 struct flakey_c *fc = ti->private; in flakey_merge() local
394 struct request_queue *q = bdev_get_queue(fc->dev->bdev); in flakey_merge()
399 bvm->bi_bdev = fc->dev->bdev; in flakey_merge()
407 struct flakey_c *fc = ti->private; in flakey_iterate_devices() local
409 return fn(ti, fc->dev, fc->start, ti->len, data); in flakey_iterate_devices()