diff options
Diffstat (limited to 'libbcachefs/util.h')
-rw-r--r-- | libbcachefs/util.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libbcachefs/util.h b/libbcachefs/util.h index e7c3541b..f0e360eb 100644 --- a/libbcachefs/util.h +++ b/libbcachefs/util.h @@ -401,11 +401,21 @@ do { \ _ret; \ }) -size_t bch2_rand_range(size_t); - void memcpy_to_bio(struct bio *, struct bvec_iter, const void *); void memcpy_from_bio(void *, struct bio *, struct bvec_iter); +#ifdef CONFIG_BCACHEFS_DEBUG +void bch2_corrupt_bio(struct bio *); + +static inline void bch2_maybe_corrupt_bio(struct bio *bio, unsigned ratio) +{ + if (ratio && !get_random_u32_below(ratio)) + bch2_corrupt_bio(bio); +} +#else +#define bch2_maybe_corrupt_bio(...) do {} while (0) +#endif + static inline void memcpy_u64s_small(void *dst, const void *src, unsigned u64s) { |