mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
bcachefs; bch2_path_put() -> btree_path_idx_t
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
255ebbbf75
commit
74e600c19a
@ -1305,19 +1305,18 @@ static struct btree_path *have_node_at_pos(struct btree_trans *trans, struct btr
|
|||||||
return NULL;
|
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);
|
__bch2_btree_path_unlock(trans, trans->paths + path);
|
||||||
btree_path_list_remove(trans, path);
|
btree_path_list_remove(trans, trans->paths + path);
|
||||||
__clear_bit(path->idx, trans->paths_allocated);
|
__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->idx != path_idx);
|
||||||
EBUG_ON(!path->ref);
|
|
||||||
|
|
||||||
if (!__btree_path_put(path, intent))
|
if (!__btree_path_put(path, intent))
|
||||||
return;
|
return;
|
||||||
@ -1339,16 +1338,15 @@ void bch2_path_put(struct btree_trans *trans, struct btree_path *path, bool inte
|
|||||||
dup->should_be_locked |= path->should_be_locked;
|
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)
|
bool intent)
|
||||||
{
|
{
|
||||||
EBUG_ON(trans->paths + path->idx != path);
|
EBUG_ON(trans->paths[path].idx != path);
|
||||||
EBUG_ON(!path->ref);
|
|
||||||
|
|
||||||
if (!__btree_path_put(path, intent))
|
if (!__btree_path_put(trans->paths + path, intent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
__bch2_path_free(trans, path);
|
__bch2_path_free(trans, path);
|
||||||
@ -2066,7 +2064,7 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
|
|||||||
EBUG_ON((iter->flags & BTREE_ITER_FILTER_SNAPSHOTS) && bkey_eq(end, POS_MAX));
|
EBUG_ON((iter->flags & BTREE_ITER_FILTER_SNAPSHOTS) && bkey_eq(end, POS_MAX));
|
||||||
|
|
||||||
if (iter->update_path) {
|
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->flags & BTREE_ITER_INTENT);
|
||||||
iter->update_path = NULL;
|
iter->update_path = NULL;
|
||||||
}
|
}
|
||||||
@ -2095,7 +2093,7 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
|
|||||||
|
|
||||||
if (iter->update_path &&
|
if (iter->update_path &&
|
||||||
!bkey_eq(iter->update_path->pos, k.k->p)) {
|
!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->flags & BTREE_ITER_INTENT);
|
||||||
iter->update_path = NULL;
|
iter->update_path = NULL;
|
||||||
}
|
}
|
||||||
@ -2278,7 +2276,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
|
|||||||
* that candidate
|
* that candidate
|
||||||
*/
|
*/
|
||||||
if (saved_path && !bkey_eq(k.k->p, saved_k.p)) {
|
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->flags & BTREE_ITER_INTENT);
|
||||||
iter->path = saved_path;
|
iter->path = saved_path;
|
||||||
saved_path = NULL;
|
saved_path = NULL;
|
||||||
@ -2291,7 +2289,7 @@ struct bkey_s_c bch2_btree_iter_peek_prev(struct btree_iter *iter)
|
|||||||
iter->snapshot,
|
iter->snapshot,
|
||||||
k.k->p.snapshot)) {
|
k.k->p.snapshot)) {
|
||||||
if (saved_path)
|
if (saved_path)
|
||||||
bch2_path_put_nokeep(trans, saved_path,
|
bch2_path_put_nokeep(trans, saved_path->idx,
|
||||||
iter->flags & BTREE_ITER_INTENT);
|
iter->flags & BTREE_ITER_INTENT);
|
||||||
saved_path = btree_path_clone(trans, iter->path,
|
saved_path = btree_path_clone(trans, iter->path,
|
||||||
iter->flags & BTREE_ITER_INTENT);
|
iter->flags & BTREE_ITER_INTENT);
|
||||||
@ -2335,7 +2333,7 @@ got_key:
|
|||||||
btree_path_set_should_be_locked(iter->path);
|
btree_path_set_should_be_locked(iter->path);
|
||||||
out_no_locked:
|
out_no_locked:
|
||||||
if (saved_path)
|
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_entry_exit(iter);
|
||||||
bch2_btree_iter_verify(iter);
|
bch2_btree_iter_verify(iter);
|
||||||
@ -2639,13 +2637,13 @@ static inline void btree_path_list_add(struct btree_trans *trans,
|
|||||||
void bch2_trans_iter_exit(struct btree_trans *trans, struct btree_iter *iter)
|
void bch2_trans_iter_exit(struct btree_trans *trans, struct btree_iter *iter)
|
||||||
{
|
{
|
||||||
if (iter->update_path)
|
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->flags & BTREE_ITER_INTENT);
|
||||||
if (iter->path)
|
if (iter->path)
|
||||||
bch2_path_put(trans, iter->path,
|
bch2_path_put(trans, iter->path->idx,
|
||||||
iter->flags & BTREE_ITER_INTENT);
|
iter->flags & BTREE_ITER_INTENT);
|
||||||
if (iter->key_cache_path)
|
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->flags & BTREE_ITER_INTENT);
|
||||||
iter->path = NULL;
|
iter->path = NULL;
|
||||||
iter->update_path = NULL;
|
iter->update_path = NULL;
|
||||||
@ -2814,7 +2812,7 @@ u32 bch2_trans_begin(struct btree_trans *trans)
|
|||||||
* iterators if we do that
|
* iterators if we do that
|
||||||
*/
|
*/
|
||||||
if (!path->ref && !path->preserve)
|
if (!path->ref && !path->preserve)
|
||||||
__bch2_path_free(trans, path);
|
__bch2_path_free(trans, path->idx);
|
||||||
else
|
else
|
||||||
path->preserve = false;
|
path->preserve = false;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ void bch2_btree_node_iter_fix(struct btree_trans *trans, struct btree_path *,
|
|||||||
|
|
||||||
int bch2_btree_path_relock_intent(struct btree_trans *, struct btree_path *);
|
int bch2_btree_path_relock_intent(struct btree_trans *, struct btree_path *);
|
||||||
|
|
||||||
void bch2_path_put(struct btree_trans *, struct btree_path *, bool);
|
void bch2_path_put(struct btree_trans *, btree_path_idx_t, bool);
|
||||||
|
|
||||||
int bch2_trans_relock(struct btree_trans *);
|
int bch2_trans_relock(struct btree_trans *);
|
||||||
int bch2_trans_relock_notrace(struct btree_trans *);
|
int bch2_trans_relock_notrace(struct btree_trans *);
|
||||||
@ -360,7 +360,7 @@ static inline void __bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpo
|
|||||||
static inline void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
|
static inline void bch2_btree_iter_set_pos(struct btree_iter *iter, struct bpos new_pos)
|
||||||
{
|
{
|
||||||
if (unlikely(iter->update_path))
|
if (unlikely(iter->update_path))
|
||||||
bch2_path_put(iter->trans, iter->update_path,
|
bch2_path_put(iter->trans, iter->update_path->idx,
|
||||||
iter->flags & BTREE_ITER_INTENT);
|
iter->flags & BTREE_ITER_INTENT);
|
||||||
iter->update_path = NULL;
|
iter->update_path = NULL;
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ static noinline int flush_new_cached_update(struct btree_trans *trans,
|
|||||||
btree_path_set_should_be_locked(btree_path);
|
btree_path_set_should_be_locked(btree_path);
|
||||||
ret = bch2_trans_update_by_path(trans, btree_path, i->k, flags, ip);
|
ret = bch2_trans_update_by_path(trans, btree_path, i->k, flags, ip);
|
||||||
out:
|
out:
|
||||||
bch2_path_put(trans, btree_path, true);
|
bch2_path_put(trans, btree_path->idx, true);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ bch2_trans_update_by_path(struct btree_trans *trans, struct btree_path *path,
|
|||||||
if (!cmp && i < trans->updates + trans->nr_updates) {
|
if (!cmp && i < trans->updates + trans->nr_updates) {
|
||||||
EBUG_ON(i->insert_trigger_run || i->overwrite_trigger_run);
|
EBUG_ON(i->insert_trigger_run || i->overwrite_trigger_run);
|
||||||
|
|
||||||
bch2_path_put(trans, i->path, true);
|
bch2_path_put(trans, i->path->idx, true);
|
||||||
i->flags = n.flags;
|
i->flags = n.flags;
|
||||||
i->cached = n.cached;
|
i->cached = n.cached;
|
||||||
i->k = n.k;
|
i->k = n.k;
|
||||||
|
@ -194,7 +194,7 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
|
|||||||
static inline void bch2_trans_reset_updates(struct btree_trans *trans)
|
static inline void bch2_trans_reset_updates(struct btree_trans *trans)
|
||||||
{
|
{
|
||||||
trans_for_each_update(trans, i)
|
trans_for_each_update(trans, i)
|
||||||
bch2_path_put(trans, i->path, true);
|
bch2_path_put(trans, i->path->idx, true);
|
||||||
|
|
||||||
trans->extra_journal_res = 0;
|
trans->extra_journal_res = 0;
|
||||||
trans->nr_updates = 0;
|
trans->nr_updates = 0;
|
||||||
|
@ -720,7 +720,7 @@ err:
|
|||||||
|
|
||||||
btree_node_write_if_need(c, b, SIX_LOCK_intent);
|
btree_node_write_if_need(c, b, SIX_LOCK_intent);
|
||||||
btree_node_unlock(trans, path, b->c.level);
|
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);
|
bch2_journal_pin_drop(&c->journal, &as->journal);
|
||||||
@ -1615,11 +1615,11 @@ static int btree_split(struct btree_update *as, struct btree_trans *trans,
|
|||||||
out:
|
out:
|
||||||
if (path2) {
|
if (path2) {
|
||||||
__bch2_btree_path_unlock(trans, path2);
|
__bch2_btree_path_unlock(trans, path2);
|
||||||
bch2_path_put(trans, path2, true);
|
bch2_path_put(trans, path2->idx, true);
|
||||||
}
|
}
|
||||||
if (path1) {
|
if (path1) {
|
||||||
__bch2_btree_path_unlock(trans, 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);
|
bch2_trans_verify_locks(trans);
|
||||||
@ -1926,8 +1926,8 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
|
|||||||
out:
|
out:
|
||||||
err:
|
err:
|
||||||
if (new_path)
|
if (new_path)
|
||||||
bch2_path_put(trans, new_path, true);
|
bch2_path_put(trans, new_path->idx, true);
|
||||||
bch2_path_put(trans, sib_path, true);
|
bch2_path_put(trans, sib_path->idx, true);
|
||||||
bch2_trans_verify_locks(trans);
|
bch2_trans_verify_locks(trans);
|
||||||
return ret;
|
return ret;
|
||||||
err_free_update:
|
err_free_update:
|
||||||
@ -1992,7 +1992,7 @@ int bch2_btree_node_rewrite(struct btree_trans *trans,
|
|||||||
bch2_btree_update_done(as, trans);
|
bch2_btree_update_done(as, trans);
|
||||||
out:
|
out:
|
||||||
if (new_path)
|
if (new_path)
|
||||||
bch2_path_put(trans, new_path, true);
|
bch2_path_put(trans, new_path->idx, true);
|
||||||
bch2_trans_downgrade(trans);
|
bch2_trans_downgrade(trans);
|
||||||
return ret;
|
return ret;
|
||||||
err:
|
err:
|
||||||
|
Loading…
Reference in New Issue
Block a user