diff options
| author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-03-08 18:42:56 -0500 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-03-16 13:47:55 -0400 |
| commit | 5a06cb8000addbbfd1f9ce6891098da5b48d3d1e (patch) | |
| tree | a06a6e73e97725d666b58a421155c3e328e99f72 /fs/bcachefs/util.h | |
| parent | bcachefs: Don't create bch_io_failures unless it's needed (diff) | |
| download | linux-5a06cb8000addbbfd1f9ce6891098da5b48d3d1e.tar.gz linux-5a06cb8000addbbfd1f9ce6891098da5b48d3d1e.zip | |
bcachefs: Debug params for data corruption injection
dm-flakey is busted, and this is simpler anyways - this lets us test the
checksum error retry ptahs
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.h')
| -rw-r--r-- | fs/bcachefs/util.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index f4a4783219d9..d41e133acc4d 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -406,6 +406,18 @@ u64 bch2_get_random_u64_below(u64); 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) { |
