bcachefs: Improve invalid bkey error message
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 19 Apr 2022 03:43:08 +0000 (23:43 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:32 +0000 (17:09 -0400)
Bkeys have gotten a lot bigger since this code was written and now are
often formatted across multiple lines - while the reason a bkey is
invalid will still be short and fit on a single line. This patch prints
the error bfore the bkey, making it a bit more readable.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_io.c

index 33c54803e0a2d99c287d0297a6aa5fe034ecc1a0..e86285c320ed9cbdb3517490f78048b9b4bb72bd 100644 (file)
@@ -815,10 +815,10 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
                printbuf_reset(&buf);
                if (bset_key_invalid(c, b, u.s_c, updated_range, write, &buf)) {
                        printbuf_reset(&buf);
-                       pr_buf(&buf, "invalid bkey:\n  ");
-                       bch2_bkey_val_to_text(&buf, c, u.s_c);
-                       pr_buf(&buf, "  \n");
+                       pr_buf(&buf, "invalid bkey:  ");
                        bset_key_invalid(c, b, u.s_c, updated_range, write, &buf);
+                       pr_buf(&buf, "\n  ");
+                       bch2_bkey_val_to_text(&buf, c, u.s_c);
 
                        btree_err(BTREE_ERR_FIXABLE, c, NULL, b, i, "%s", buf.buf);
 
@@ -1076,10 +1076,10 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
                     !bversion_cmp(u.k->version, MAX_VERSION))) {
                        printbuf_reset(&buf);
 
-                       pr_buf(&buf, "invalid bkey\n  ");
-                       bch2_bkey_val_to_text(&buf, c, u.s_c);
-                       pr_buf(&buf, "\n  ");
+                       pr_buf(&buf, "invalid bkey: ");
                        bch2_bkey_val_invalid(c, u.s_c, READ, &buf);
+                       pr_buf(&buf, "\n  ");
+                       bch2_bkey_val_to_text(&buf, c, u.s_c);
 
                        btree_err(BTREE_ERR_FIXABLE, c, NULL, b, i, "%s", buf.buf);