Lines Matching refs:tfc
59 #define FLAKEY_CORRUPT_DIR(tfc) \ argument
60 ((tfc)->corrupt_buf_rw == BUF_CMD_READ ? 'r' : 'w')
71 dm_target_flakey_config_t *tfc; in dm_target_flakey_init() local
82 tfc = kmalloc(sizeof(*tfc), M_DMFLAKEY, M_WAITOK | M_ZERO); in dm_target_flakey_init()
83 if (tfc == NULL) in dm_target_flakey_init()
90 tfc->pdev = dmp; in dm_target_flakey_init()
91 tfc->offset = atoi64(argv[1]); in dm_target_flakey_init()
92 tfc->up_int = atoi64(argv[2]); in dm_target_flakey_init()
93 tfc->down_int = atoi64(argv[3]); in dm_target_flakey_init()
94 tfc->offset_time = ticks; in dm_target_flakey_init()
96 if ((tfc->up_int + tfc->down_int) == 0) { in dm_target_flakey_init()
102 if (tfc->up_int + tfc->down_int < tfc->up_int) { in dm_target_flakey_init()
108 err = _init_features(tfc, argc - 4, argv + 4); in dm_target_flakey_init()
114 dm_table_init_target(table_en, tfc); in dm_target_flakey_init()
118 kfree(tfc, M_DMFLAKEY); in dm_target_flakey_init()
123 _init_features(dm_target_flakey_config_t *tfc, int argc, char **argv) in _init_features() argument
143 tfc->drop_writes = 1; in _init_features()
163 tfc->corrupt_buf_byte = value; in _init_features()
169 tfc->corrupt_buf_rw = BUF_CMD_READ; in _init_features()
171 tfc->corrupt_buf_rw = BUF_CMD_WRITE; in _init_features()
186 tfc->corrupt_buf_value = value; in _init_features()
190 tfc->corrupt_buf_flags = atoi64(*argv++); in _init_features()
199 if (tfc->drop_writes && (tfc->corrupt_buf_rw == BUF_CMD_WRITE)) { in _init_features()
211 dm_target_flakey_config_t *tfc; in dm_target_flakey_destroy() local
213 tfc = table_en->target_config; in dm_target_flakey_destroy()
214 if (tfc == NULL) in dm_target_flakey_destroy()
217 dm_pdev_decr(tfc->pdev); in dm_target_flakey_destroy()
219 kfree(tfc, M_DMFLAKEY); in dm_target_flakey_destroy()
227 dm_target_flakey_config_t *tfc; in dm_target_flakey_strategy() local
230 tfc = table_en->target_config; in dm_target_flakey_strategy()
232 elapsed = (ticks - tfc->offset_time) / hz; in dm_target_flakey_strategy()
233 if (elapsed % (tfc->up_int + tfc->down_int) >= tfc->up_int) { in dm_target_flakey_strategy()
236 return _flakey_read(tfc, bp); in dm_target_flakey_strategy()
238 return _flakey_write(tfc, bp); in dm_target_flakey_strategy()
245 _submit(tfc, &bp->b_bio1); in dm_target_flakey_strategy()
252 _submit(dm_target_flakey_config_t *tfc, struct bio *bio) in _submit() argument
254 bio->bio_offset += tfc->offset * DEV_BSIZE; in _submit()
255 vn_strategy(tfc->pdev->pdev_vnode, bio); in _submit()
270 dm_target_flakey_config_t *tfc; in _flakey_read_iodone() local
272 tfc = bio->bio_caller_info1.ptr; in _flakey_read_iodone()
279 if (tfc->corrupt_buf_byte && tfc->corrupt_buf_rw == BUF_CMD_READ) in _flakey_read_iodone()
280 _flakey_corrupt_buf(tfc, obio); in _flakey_read_iodone()
281 else if (!tfc->drop_writes) in _flakey_read_iodone()
288 _flakey_read(dm_target_flakey_config_t *tfc, struct buf *bp) in _flakey_read() argument
297 if (!tfc->corrupt_buf_byte && !tfc->drop_writes) { in _flakey_read()
305 nbio->bio_caller_info1.ptr = tfc; in _flakey_read()
308 _submit(tfc, nbio); in _flakey_read()
314 _flakey_write(dm_target_flakey_config_t *tfc, struct buf *bp) in _flakey_write() argument
318 if (tfc->drop_writes) { in _flakey_write()
325 if (tfc->corrupt_buf_byte && tfc->corrupt_buf_rw == BUF_CMD_WRITE) { in _flakey_write()
326 _flakey_corrupt_buf(tfc, bio); in _flakey_write()
327 _submit(tfc, bio); in _flakey_write()
339 _flakey_corrupt_buf(dm_target_flakey_config_t *tfc, struct bio *bio) in _flakey_corrupt_buf() argument
349 if (bp->b_bcount < tfc->corrupt_buf_byte) in _flakey_corrupt_buf()
351 if ((bp->b_flags & tfc->corrupt_buf_flags) != tfc->corrupt_buf_flags) in _flakey_corrupt_buf()
354 bp->b_data[tfc->corrupt_buf_byte - 1] = tfc->corrupt_buf_value; in _flakey_corrupt_buf()
357 FLAKEY_CORRUPT_DIR(tfc), in _flakey_corrupt_buf()
359 tfc->corrupt_buf_byte, in _flakey_corrupt_buf()
360 tfc->corrupt_buf_value); in _flakey_corrupt_buf()
368 dm_target_flakey_config_t *tfc; in dm_target_flakey_table() local
372 tfc = target_config; in dm_target_flakey_table()
373 KKASSERT(tfc != NULL); in dm_target_flakey_table()
375 drop_writes = tfc->drop_writes; in dm_target_flakey_table()
380 tfc->pdev->udev_name, tfc->offset_time, in dm_target_flakey_table()
381 tfc->up_int, tfc->down_int, in dm_target_flakey_table()
382 drop_writes + (tfc->corrupt_buf_byte > 0) * 5); in dm_target_flakey_table()
387 if (tfc->corrupt_buf_byte) in dm_target_flakey_table()
390 tfc->corrupt_buf_byte, in dm_target_flakey_table()
391 FLAKEY_CORRUPT_DIR(tfc), in dm_target_flakey_table()
392 tfc->corrupt_buf_value, in dm_target_flakey_table()
393 tfc->corrupt_buf_flags); in dm_target_flakey_table()