bcachefs: bch2_bio_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 21 Apr 2025 16:04:10 +0000 (12:04 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:28 +0000 (20:14 -0400)
Pretty printer for struct bio, to be used for async object debugging.

This is pretty minimal, we'll add more to it as we discover what we
need.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/util.c
fs/bcachefs/util.h

index 6e5d7fc265bd2328c4242de5894bc312f70c4b08..7e6ebe8cd9ea369c074fee31c141736a572dfca6 100644 (file)
@@ -715,6 +715,16 @@ void bch2_corrupt_bio(struct bio *bio)
 }
 #endif
 
+void bch2_bio_to_text(struct printbuf *out, struct bio *bio)
+{
+       prt_printf(out, "bi_remaining:\t%u\n",
+                  atomic_read(&bio->__bi_remaining));
+       prt_printf(out, "bi_end_io:\t%ps\n",
+                  bio->bi_end_io);
+       prt_printf(out, "bi_status:\t%u\n",
+                  bio->bi_status);
+}
+
 #if 0
 void eytzinger1_test(void)
 {
index 50f7197c67fce9b3ca5d8fb13334304040cf8990..7a93e187a49ad3956ac62055fd0a09f5ed0cdbee 100644 (file)
@@ -419,6 +419,8 @@ static inline void bch2_maybe_corrupt_bio(struct bio *bio, unsigned ratio)
 #define bch2_maybe_corrupt_bio(...)    do {} while (0)
 #endif
 
+void bch2_bio_to_text(struct printbuf *, struct bio *);
+
 static inline void memcpy_u64s_small(void *dst, const void *src,
                                     unsigned u64s)
 {