diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-04-03 17:50:01 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:30 -0400 |
commit | f0ac7df23d04f3c6d4cd82899aad7f06f6a0b1d4 (patch) | |
tree | e11cada7a81e2d1daab091b4552a498055bdce31 /fs/bcachefs/journal_io.c | |
parent | d1d7737fd9df0cc57cd276b0189faf8c92c1426f (diff) | |
download | linux-stable-f0ac7df23d04f3c6d4cd82899aad7f06f6a0b1d4.tar.gz linux-stable-f0ac7df23d04f3c6d4cd82899aad7f06f6a0b1d4.tar.bz2 linux-stable-f0ac7df23d04f3c6d4cd82899aad7f06f6a0b1d4.zip |
bcachefs: Convert .key_invalid methods to printbufs
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r-- | fs/bcachefs/journal_io.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 3974d043fd8a..56221e316ee6 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -209,7 +209,7 @@ static int journal_validate_key(struct bch_fs *c, const char *where, unsigned version, int big_endian, int write) { void *next = vstruct_next(entry); - const char *invalid; + struct printbuf buf = PRINTBUF; int ret = 0; if (journal_entry_err_on(!k->k.u64s, c, @@ -249,22 +249,28 @@ static int journal_validate_key(struct bch_fs *c, const char *where, bch2_bkey_compat(level, btree_id, version, big_endian, write, NULL, bkey_to_packed(k)); - invalid = bch2_bkey_invalid(c, bkey_i_to_s_c(k), - __btree_node_type(level, btree_id)); - if (invalid) { - struct printbuf buf = PRINTBUF; + if (bch2_bkey_invalid(c, bkey_i_to_s_c(k), + __btree_node_type(level, btree_id), &buf)) { + printbuf_reset(&buf); + pr_buf(&buf, "invalid %s in %s entry offset %zi/%u:", + type, where, + (u64 *) k - entry->_data, + le16_to_cpu(entry->u64s)); + pr_newline(&buf); + pr_indent_push(&buf, 2); bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(k)); - mustfix_fsck_err(c, "invalid %s in %s entry offset %zi/%u: %s\n%s", - type, where, - (u64 *) k - entry->_data, - le16_to_cpu(entry->u64s), - invalid, buf.buf); - printbuf_exit(&buf); + pr_newline(&buf); + bch2_bkey_invalid(c, bkey_i_to_s_c(k), + __btree_node_type(level, btree_id), &buf); + + mustfix_fsck_err(c, "%s", buf.buf); le16_add_cpu(&entry->u64s, -((u16) k->k.u64s)); memmove(k, bkey_next(k), next - (void *) bkey_next(k)); journal_entry_null_range(vstruct_next(entry), next); + + printbuf_exit(&buf); return FSCK_DELETED_KEY; } @@ -272,6 +278,7 @@ static int journal_validate_key(struct bch_fs *c, const char *where, bch2_bkey_compat(level, btree_id, version, big_endian, write, NULL, bkey_to_packed(k)); fsck_err: + printbuf_exit(&buf); return ret; } |