mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
bcachefs: Add more debug checks
tracking down a bug where we see a btree node pointer in the wrong node Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
e8bd002b23
commit
1c74cec10c
2 changed files with 19 additions and 2 deletions
|
@ -1442,8 +1442,10 @@ static int validate_bset_for_write(struct bch_fs *c, struct btree *b,
|
||||||
|
|
||||||
ret = validate_bset(c, b, i, sectors, WRITE, false) ?:
|
ret = validate_bset(c, b, i, sectors, WRITE, false) ?:
|
||||||
validate_bset_keys(c, b, i, &whiteout_u64s, WRITE, false);
|
validate_bset_keys(c, b, i, &whiteout_u64s, WRITE, false);
|
||||||
if (ret)
|
if (ret) {
|
||||||
bch2_inconsistent_error(c);
|
bch2_inconsistent_error(c);
|
||||||
|
dump_stack();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "btree_iter.h"
|
#include "btree_iter.h"
|
||||||
#include "btree_locking.h"
|
#include "btree_locking.h"
|
||||||
#include "buckets.h"
|
#include "buckets.h"
|
||||||
|
#include "error.h"
|
||||||
#include "extents.h"
|
#include "extents.h"
|
||||||
#include "journal.h"
|
#include "journal.h"
|
||||||
#include "journal_reclaim.h"
|
#include "journal_reclaim.h"
|
||||||
|
@ -1021,7 +1022,19 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b
|
||||||
struct bkey_i *insert,
|
struct bkey_i *insert,
|
||||||
struct btree_node_iter *node_iter)
|
struct btree_node_iter *node_iter)
|
||||||
{
|
{
|
||||||
|
struct bch_fs *c = as->c;
|
||||||
struct bkey_packed *k;
|
struct bkey_packed *k;
|
||||||
|
const char *invalid;
|
||||||
|
|
||||||
|
invalid = bch2_bkey_invalid(c, bkey_i_to_s_c(insert), btree_node_type(b)) ?:
|
||||||
|
bch2_bkey_in_btree_node(b, bkey_i_to_s_c(insert));
|
||||||
|
if (invalid) {
|
||||||
|
char buf[160];
|
||||||
|
|
||||||
|
bch2_bkey_val_to_text(&PBUF(buf), c, bkey_i_to_s_c(insert));
|
||||||
|
bch2_fs_inconsistent(c, "inserting invalid bkey %s: %s", buf, invalid);
|
||||||
|
dump_stack();
|
||||||
|
}
|
||||||
|
|
||||||
BUG_ON(as->journal_u64s + jset_u64s(insert->k.u64s) >
|
BUG_ON(as->journal_u64s + jset_u64s(insert->k.u64s) >
|
||||||
ARRAY_SIZE(as->journal_entries));
|
ARRAY_SIZE(as->journal_entries));
|
||||||
|
@ -1037,7 +1050,7 @@ static void bch2_insert_fixup_btree_ptr(struct btree_update *as, struct btree *b
|
||||||
bch2_btree_node_iter_advance(node_iter, b);
|
bch2_btree_node_iter_advance(node_iter, b);
|
||||||
|
|
||||||
bch2_btree_bset_insert_key(iter, b, node_iter, insert);
|
bch2_btree_bset_insert_key(iter, b, node_iter, insert);
|
||||||
set_btree_node_dirty(as->c, b);
|
set_btree_node_dirty(c, b);
|
||||||
set_btree_node_need_write(b);
|
set_btree_node_need_write(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,6 +1379,8 @@ void bch2_btree_insert_node(struct btree_update *as, struct btree *b,
|
||||||
goto split;
|
goto split;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btree_node_interior_verify(c, b);
|
||||||
|
|
||||||
bch2_btree_insert_keys_interior(as, b, iter, keys);
|
bch2_btree_insert_keys_interior(as, b, iter, keys);
|
||||||
|
|
||||||
live_u64s_added = (int) b->nr.live_u64s - old_live_u64s;
|
live_u64s_added = (int) b->nr.live_u64s - old_live_u64s;
|
||||||
|
|
Loading…
Reference in a new issue