return NULL;
}
-static inline void __bch2_path_free(struct btree_trans *trans, struct btree_path *path)
+static inline void __bch2_path_free(struct btree_trans *trans, btree_path_idx_t path)
{
- __bch2_btree_path_unlock(trans, path);
- btree_path_list_remove(trans, path);
- __clear_bit(path->idx, trans->paths_allocated);
+ __bch2_btree_path_unlock(trans, trans->paths + path);
+ btree_path_list_remove(trans, trans->paths + path);
+ __clear_bit(path, trans->paths_allocated);
}
-void bch2_path_put(struct btree_trans *trans, struct btree_path *path, bool intent)
+void bch2_path_put(struct btree_trans *trans, btree_path_idx_t path_idx, bool intent)
{
- struct btree_path *dup;
+ struct btree_path *path = trans->paths + path_idx, *dup;
- EBUG_ON(trans->paths + path->idx != path);
- EBUG_ON(!path->ref);
+ EBUG_ON(path->idx != path_idx);
if (!__btree_path_put(path, intent))
return;
dup->should_be_locked |= path->should_be_locked;
}
- __bch2_path_free(trans, path);
+ __bch2_path_free(trans, path_idx);
}
-static void bch2_path_put_nokeep(struct btree_trans *trans, struct btree_path *path,
+static void bch2_path_put_nokeep(struct btree_trans *trans, btree_path_idx_t path,
bool intent)
{
- EBUG_ON(trans->paths + path->idx != path);
- EBUG_ON(!path->ref);
+ EBUG_ON(trans->paths[path].idx != path);
- if (!__btree_path_put(path, intent))
+ if (!__btree_path_put(trans->paths + path, intent))
return;
__bch2_path_free(trans, path);
EBUG_ON((iter->flags & BTREE_ITER_FILTER_SNAPSHOTS) && bkey_eq(end, POS_MAX));
if (iter->update_path) {
- bch2_path_put_nokeep(trans, iter->update_path,
+ bch2_path_put_nokeep(trans, iter->update_path->idx,
iter->flags & BTREE_ITER_INTENT);
iter->update_path = NULL;
}
if (iter->update_path &&
!bkey_eq(iter->update_path->pos, k.k->p)) {
- bch2_path_put_nokeep(trans, iter->update_path,
+ bch2_path_put_nokeep(trans, iter->update_path->idx,
iter->flags & BTREE_ITER_INTENT);
iter->update_path = NULL;
}
* that candidate
*/
if (saved_path && !bkey_eq(k.k->p, saved_k.p)) {
- bch2_path_put_nokeep(trans, iter->path,
+ bch2_path_put_nokeep(trans, iter->path->idx,
iter->flags & BTREE_ITER_INTENT);
iter->path = saved_path;
saved_path = NULL;
iter->snapshot,
k.k->p.snapshot)) {
if (saved_path)
- bch2_path_put_nokeep(trans, saved_path,
+ bch2_path_put_nokeep(trans, saved_path->idx,
iter->flags & BTREE_ITER_INTENT);
saved_path = btree_path_clone(trans, iter->path,
iter->flags & BTREE_ITER_INTENT);
btree_path_set_should_be_locked(iter->path);
out_no_locked:
if (saved_path)
- bch2_path_put_nokeep(trans, saved_path, iter->flags & BTREE_ITER_INTENT);
+ bch2_path_put_nokeep(trans, saved_path->idx, iter->flags & BTREE_ITER_INTENT);
bch2_btree_iter_verify_entry_exit(iter);
bch2_btree_iter_verify(iter);
void bch2_trans_iter_exit(struct btree_trans *trans, struct btree_iter *iter)
{
if (iter->update_path)
- bch2_path_put_nokeep(trans, iter->update_path,
+ bch2_path_put_nokeep(trans, iter->update_path->idx,
iter->flags & BTREE_ITER_INTENT);
if (iter->path)
- bch2_path_put(trans, iter->path,
+ bch2_path_put(trans, iter->path->idx,
iter->flags & BTREE_ITER_INTENT);
if (iter->key_cache_path)
- bch2_path_put(trans, iter->key_cache_path,
+ bch2_path_put(trans, iter->key_cache_path->idx,
iter->flags & BTREE_ITER_INTENT);
iter->path = NULL;
iter->update_path = NULL;
* iterators if we do that
*/
if (!path->ref && !path->preserve)
- __bch2_path_free(trans, path);
+ __bch2_path_free(trans, path->idx);
else
path->preserve = false;
}
btree_node_write_if_need(c, b, SIX_LOCK_intent);
btree_node_unlock(trans, path, b->c.level);
- bch2_path_put(trans, path, true);
+ bch2_path_put(trans, path->idx, true);
}
bch2_journal_pin_drop(&c->journal, &as->journal);
out:
if (path2) {
__bch2_btree_path_unlock(trans, path2);
- bch2_path_put(trans, path2, true);
+ bch2_path_put(trans, path2->idx, true);
}
if (path1) {
__bch2_btree_path_unlock(trans, path1);
- bch2_path_put(trans, path1, true);
+ bch2_path_put(trans, path1->idx, true);
}
bch2_trans_verify_locks(trans);
out:
err:
if (new_path)
- bch2_path_put(trans, new_path, true);
- bch2_path_put(trans, sib_path, true);
+ bch2_path_put(trans, new_path->idx, true);
+ bch2_path_put(trans, sib_path->idx, true);
bch2_trans_verify_locks(trans);
return ret;
err_free_update:
bch2_btree_update_done(as, trans);
out:
if (new_path)
- bch2_path_put(trans, new_path, true);
+ bch2_path_put(trans, new_path->idx, true);
bch2_trans_downgrade(trans);
return ret;
err: