mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
bcachefs: Debug code improvements
.key_debugcheck no longer needs to take a pointer to the btree node Also, try to make sure wherever we're inserting or modifying keys in the btree. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
4cac0bf2c2
commit
a9d1f91018
@ -145,7 +145,7 @@ void bch2_bkey_debugcheck(struct bch_fs *c, struct btree *b, struct bkey_s_c k)
|
||||
}
|
||||
|
||||
if (ops->key_debugcheck)
|
||||
ops->key_debugcheck(c, b, k);
|
||||
ops->key_debugcheck(c, k);
|
||||
}
|
||||
|
||||
void bch2_bpos_to_text(struct printbuf *out, struct bpos pos)
|
||||
|
@ -26,8 +26,7 @@ struct bkey_ops {
|
||||
/* Returns reason for being invalid if invalid, else NULL: */
|
||||
const char * (*key_invalid)(const struct bch_fs *,
|
||||
struct bkey_s_c);
|
||||
void (*key_debugcheck)(struct bch_fs *, struct btree *,
|
||||
struct bkey_s_c);
|
||||
void (*key_debugcheck)(struct bch_fs *, struct bkey_s_c);
|
||||
void (*val_to_text)(struct printbuf *, struct bch_fs *,
|
||||
struct bkey_s_c);
|
||||
void (*swab)(const struct bkey_format *, struct bkey_packed *);
|
||||
|
@ -671,8 +671,7 @@ const char *bch2_btree_ptr_invalid(const struct bch_fs *c, struct bkey_s_c k)
|
||||
return bch2_bkey_ptrs_invalid(c, k);
|
||||
}
|
||||
|
||||
void bch2_btree_ptr_debugcheck(struct bch_fs *c, struct btree *b,
|
||||
struct bkey_s_c k)
|
||||
void bch2_btree_ptr_debugcheck(struct bch_fs *c, struct bkey_s_c k)
|
||||
{
|
||||
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
|
||||
const struct bch_extent_ptr *ptr;
|
||||
@ -895,6 +894,9 @@ static void extent_bset_insert(struct bch_fs *c, struct btree_iter *iter,
|
||||
EBUG_ON(bkey_deleted(&insert->k) || !insert->k.size);
|
||||
verify_extent_nonoverlapping(c, l->b, &l->iter, insert);
|
||||
|
||||
if (debug_check_bkeys(c))
|
||||
bch2_bkey_debugcheck(c, l->b, bkey_i_to_s_c(insert));
|
||||
|
||||
node_iter = l->iter;
|
||||
k = bch2_btree_node_iter_prev_filter(&node_iter, l->b, KEY_TYPE_discard);
|
||||
if (k && !bkey_written(l->b, k) &&
|
||||
@ -1362,10 +1364,6 @@ void bch2_insert_fixup_extent(struct btree_trans *trans,
|
||||
if (s.deleting)
|
||||
tmp.k.k.type = KEY_TYPE_discard;
|
||||
|
||||
if (debug_check_bkeys(c))
|
||||
bch2_bkey_debugcheck(c, iter->l[0].b,
|
||||
bkey_i_to_s_c(&tmp.k));
|
||||
|
||||
EBUG_ON(bkey_deleted(&tmp.k.k) || !tmp.k.k.size);
|
||||
|
||||
extent_bset_insert(c, iter, &tmp.k);
|
||||
@ -1390,8 +1388,7 @@ const char *bch2_extent_invalid(const struct bch_fs *c, struct bkey_s_c k)
|
||||
return bch2_bkey_ptrs_invalid(c, k);
|
||||
}
|
||||
|
||||
void bch2_extent_debugcheck(struct bch_fs *c, struct btree *b,
|
||||
struct bkey_s_c k)
|
||||
void bch2_extent_debugcheck(struct bch_fs *c, struct bkey_s_c k)
|
||||
{
|
||||
struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
|
||||
const union bch_extent_entry *entry;
|
||||
@ -1765,6 +1762,12 @@ static bool bch2_extent_merge_inline(struct bch_fs *c,
|
||||
if (ret == BCH_MERGE_NOMERGE)
|
||||
return false;
|
||||
|
||||
if (debug_check_bkeys(c))
|
||||
bch2_bkey_debugcheck(c, b, bkey_i_to_s_c(&li.k));
|
||||
if (debug_check_bkeys(c) &&
|
||||
ret == BCH_MERGE_PARTIAL)
|
||||
bch2_bkey_debugcheck(c, b, bkey_i_to_s_c(&ri.k));
|
||||
|
||||
/*
|
||||
* check if we overlap with deleted extents - would break the sort
|
||||
* order:
|
||||
|
@ -389,8 +389,7 @@ const char *bch2_bkey_ptrs_invalid(const struct bch_fs *, struct bkey_s_c);
|
||||
/* bch_btree_ptr: */
|
||||
|
||||
const char *bch2_btree_ptr_invalid(const struct bch_fs *, struct bkey_s_c);
|
||||
void bch2_btree_ptr_debugcheck(struct bch_fs *, struct btree *,
|
||||
struct bkey_s_c);
|
||||
void bch2_btree_ptr_debugcheck(struct bch_fs *, struct bkey_s_c);
|
||||
void bch2_btree_ptr_to_text(struct printbuf *, struct bch_fs *,
|
||||
struct bkey_s_c);
|
||||
void bch2_ptr_swab(const struct bkey_format *, struct bkey_packed *);
|
||||
@ -405,7 +404,7 @@ void bch2_ptr_swab(const struct bkey_format *, struct bkey_packed *);
|
||||
/* bch_extent: */
|
||||
|
||||
const char *bch2_extent_invalid(const struct bch_fs *, struct bkey_s_c);
|
||||
void bch2_extent_debugcheck(struct bch_fs *, struct btree *, struct bkey_s_c);
|
||||
void bch2_extent_debugcheck(struct bch_fs *, struct bkey_s_c);
|
||||
void bch2_extent_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
|
||||
bool bch2_extent_normalize(struct bch_fs *, struct bkey_s);
|
||||
enum merge_result bch2_extent_merge(struct bch_fs *,
|
||||
|
Loading…
Reference in New Issue
Block a user