Commit 0329b150 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Trace where btree iterators are allocated

This will help with iterator overflow bugs.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 283eda57
...@@ -1912,13 +1912,14 @@ static struct btree_iter *btree_trans_iter_alloc(struct btree_trans *trans) ...@@ -1912,13 +1912,14 @@ static struct btree_iter *btree_trans_iter_alloc(struct btree_trans *trans)
struct btree_iter *iter; struct btree_iter *iter;
trans_for_each_iter(trans, iter) { trans_for_each_iter(trans, iter) {
pr_err("iter: btree %s pos %llu:%llu%s%s%s", pr_err("iter: btree %s pos %llu:%llu%s%s%s %pf",
bch2_btree_ids[iter->btree_id], bch2_btree_ids[iter->btree_id],
iter->pos.inode, iter->pos.inode,
iter->pos.offset, iter->pos.offset,
(trans->iters_live & (1ULL << iter->idx)) ? " live" : "", (trans->iters_live & (1ULL << iter->idx)) ? " live" : "",
(trans->iters_touched & (1ULL << iter->idx)) ? " touched" : "", (trans->iters_touched & (1ULL << iter->idx)) ? " touched" : "",
iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT ? " keep" : ""); iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT ? " keep" : "",
(void *) iter->ip_allocated);
} }
panic("trans iter oveflow\n"); panic("trans iter oveflow\n");
...@@ -2025,7 +2026,7 @@ static struct btree_iter *__btree_trans_get_iter(struct btree_trans *trans, ...@@ -2025,7 +2026,7 @@ static struct btree_iter *__btree_trans_get_iter(struct btree_trans *trans,
return iter; return iter;
} }
struct btree_iter *bch2_trans_get_iter(struct btree_trans *trans, struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans,
enum btree_id btree_id, enum btree_id btree_id,
struct bpos pos, unsigned flags) struct bpos pos, unsigned flags)
{ {
...@@ -2064,7 +2065,7 @@ struct btree_iter *bch2_trans_get_node_iter(struct btree_trans *trans, ...@@ -2064,7 +2065,7 @@ struct btree_iter *bch2_trans_get_node_iter(struct btree_trans *trans,
return iter; return iter;
} }
struct btree_iter *bch2_trans_copy_iter(struct btree_trans *trans, struct btree_iter *__bch2_trans_copy_iter(struct btree_trans *trans,
struct btree_iter *src) struct btree_iter *src)
{ {
struct btree_iter *iter; struct btree_iter *iter;
......
...@@ -257,10 +257,35 @@ int bch2_trans_iter_free(struct btree_trans *, struct btree_iter *); ...@@ -257,10 +257,35 @@ int bch2_trans_iter_free(struct btree_trans *, struct btree_iter *);
void bch2_trans_unlink_iters(struct btree_trans *); void bch2_trans_unlink_iters(struct btree_trans *);
struct btree_iter *bch2_trans_get_iter(struct btree_trans *, enum btree_id, struct btree_iter *__bch2_trans_get_iter(struct btree_trans *, enum btree_id,
struct bpos, unsigned); struct bpos, unsigned);
struct btree_iter *bch2_trans_copy_iter(struct btree_trans *,
static inline struct btree_iter *
bch2_trans_get_iter(struct btree_trans *trans, enum btree_id btree_id,
struct bpos pos, unsigned flags)
{
struct btree_iter *iter =
__bch2_trans_get_iter(trans, btree_id, pos, flags);
if (!IS_ERR(iter))
iter->ip_allocated = _THIS_IP_;
return iter;
}
struct btree_iter *__bch2_trans_copy_iter(struct btree_trans *,
struct btree_iter *); struct btree_iter *);
static inline struct btree_iter *
bch2_trans_copy_iter(struct btree_trans *trans, struct btree_iter *src)
{
struct btree_iter *iter =
__bch2_trans_copy_iter(trans, src);
if (!IS_ERR(iter))
iter->ip_allocated = _THIS_IP_;
return iter;
}
struct btree_iter *bch2_trans_get_node_iter(struct btree_trans *, struct btree_iter *bch2_trans_get_node_iter(struct btree_trans *,
enum btree_id, struct bpos, enum btree_id, struct bpos,
unsigned, unsigned, unsigned); unsigned, unsigned, unsigned);
......
...@@ -256,6 +256,7 @@ struct btree_iter { ...@@ -256,6 +256,7 @@ struct btree_iter {
* bch2_btree_iter_next_slot() can correctly advance pos. * bch2_btree_iter_next_slot() can correctly advance pos.
*/ */
struct bkey k; struct bkey k;
unsigned long ip_allocated;
}; };
static inline enum btree_iter_type btree_iter_type(struct btree_iter *iter) static inline enum btree_iter_type btree_iter_type(struct btree_iter *iter)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment