summaryrefslogtreecommitdiff
path: root/fs/bcachefs/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r--fs/bcachefs/util.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 6488f098d140..36fe58c71c9f 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -410,6 +410,14 @@ 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_offset(struct bio *, u32);
+static inline void bch2_maybe_corrupt_bio_offset(struct bio *bio, unsigned ratio,
+ unsigned offset)
+{
+ if (ratio && !get_random_u32_below(ratio))
+ bch2_corrupt_bio_offset(bio, offset);
+}
+
void bch2_corrupt_bio(struct bio *);
static inline void bch2_maybe_corrupt_bio(struct bio *bio, unsigned ratio)