]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/btree_iter.c
Update bcachefs sources to f638850417 bcachefs: bch2_trans_log_msg()
[bcachefs-tools-debian] / libbcachefs / btree_iter.c
index 56c493c95d3a5158d79b445c47e0f8c8b0de017b..25d254ee9eaca15545a9456546d722e131ec68ea 100644 (file)
@@ -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)