summaryrefslogtreecommitdiff
path: root/libbcachefs/btree_iter.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/btree_iter.c')
-rw-r--r--libbcachefs/btree_iter.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libbcachefs/btree_iter.c b/libbcachefs/btree_iter.c
index 56c493c9..25d254ee 100644
--- a/libbcachefs/btree_iter.c
+++ b/libbcachefs/btree_iter.c
@@ -1686,6 +1686,7 @@ bch2_btree_path_make_mut(struct btree_trans *trans,
btree_trans_verify_sorted(trans);
}
+ path->should_be_locked = false;
return path;
}
@@ -1705,8 +1706,7 @@ bch2_btree_path_set_pos(struct btree_trans *trans,
path = bch2_btree_path_make_mut(trans, path, intent, ip);
- path->pos = new_pos;
- path->should_be_locked = false;
+ path->pos = new_pos;
bch2_btree_path_check_sort(trans, path, cmp);
@@ -1720,6 +1720,7 @@ bch2_btree_path_set_pos(struct btree_trans *trans,
l = btree_path_up_until_good_node(trans, path, cmp);
if (btree_path_node(path, l)) {
+ BUG_ON(!btree_node_locked(path, l));
/*
* We might have to skip over many keys, or just a few: try
* advancing the node iterator, and if we have to skip over too
@@ -1923,6 +1924,7 @@ struct btree_path *bch2_path_get(struct btree_trans *trans,
BUG_ON(trans->restarted);
btree_trans_verify_sorted(trans);
+ bch2_trans_verify_locks(trans);
trans_for_each_path_inorder(trans, path, i) {
if (__btree_path_cmp(path,
@@ -2114,6 +2116,7 @@ struct btree *bch2_btree_iter_next_node(struct btree_iter *iter)
btree_node_unlock(path, path->level);
path->l[path->level].b = BTREE_ITER_NO_NODE_UP;
path->level++;
+ btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
return NULL;
}
@@ -2121,6 +2124,7 @@ struct btree *bch2_btree_iter_next_node(struct btree_iter *iter)
__bch2_btree_path_unlock(path);
path->l[path->level].b = BTREE_ITER_NO_NODE_GET_LOCKS;
path->l[path->level + 1].b = BTREE_ITER_NO_NODE_GET_LOCKS;
+ btree_path_set_dirty(path, BTREE_ITER_NEED_TRAVERSE);
trace_trans_restart_relock_next_node(trans->fn, _THIS_IP_,
path->btree_id, &path->pos);
btree_trans_restart(trans);
@@ -3055,8 +3059,7 @@ void bch2_trans_begin(struct btree_trans *trans)
trans->mem_top = 0;
trans->hooks = NULL;
- trans->extra_journal_entries = NULL;
- trans->extra_journal_entry_u64s = 0;
+ trans->extra_journal_entries.nr = 0;
if (trans->fs_usage_deltas) {
trans->fs_usage_deltas->used = 0;
@@ -3189,6 +3192,8 @@ void bch2_trans_exit(struct btree_trans *trans)
bch2_journal_preres_put(&c->journal, &trans->journal_preres);
+ kfree(trans->extra_journal_entries.data);
+
if (trans->fs_usage_deltas) {
if (trans->fs_usage_deltas->size + sizeof(trans->fs_usage_deltas) ==
REPLICAS_DELTA_LIST_MAX)