bcachefs: Fix bch_alloc_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 19 Dec 2022 20:55:38 +0000 (15:55 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:49 +0000 (17:09 -0400)
We weren't guarding against the alloc key having an invalid data type.

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

index d75738134f94e0878ff45949f13fb097d2b564f6..388a448580971c32f6d09237b92c0051c48aa2e2 100644 (file)
@@ -351,7 +351,10 @@ void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c
        printbuf_indent_add(out, 2);
 
        prt_printf(out, "gen %u oldest_gen %u data_type %s",
-              a->gen, a->oldest_gen, bch2_data_types[a->data_type]);
+              a->gen, a->oldest_gen,
+              a->data_type < BCH_DATA_NR
+              ? bch2_data_types[a->data_type]
+              : "(invalid data type)");
        prt_newline(out);
        prt_printf(out, "journal_seq       %llu",       a->journal_seq);
        prt_newline(out);