Commit 8d956c2f authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: btree_iter_set_dontneed()

This is a bit clearer than using bch2_btree_iter_free().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent abcecb49
...@@ -1972,7 +1972,7 @@ int bch2_trans_iter_free(struct btree_trans *trans, ...@@ -1972,7 +1972,7 @@ int bch2_trans_iter_free(struct btree_trans *trans,
if (IS_ERR_OR_NULL(iter)) if (IS_ERR_OR_NULL(iter))
return 0; return 0;
trans->iters_touched &= ~(1ULL << iter->idx); set_btree_iter_dontneed(trans, iter);
return bch2_trans_iter_put(trans, iter); return bch2_trans_iter_put(trans, iter);
} }
...@@ -2133,7 +2133,7 @@ struct btree_iter *__bch2_trans_copy_iter(struct btree_trans *trans, ...@@ -2133,7 +2133,7 @@ struct btree_iter *__bch2_trans_copy_iter(struct btree_trans *trans,
* We don't need to preserve this iter since it's cheap to copy it * We don't need to preserve this iter since it's cheap to copy it
* again - this will cause trans_iter_put() to free it right away: * again - this will cause trans_iter_put() to free it right away:
*/ */
trans->iters_touched &= ~(1ULL << iter->idx); set_btree_iter_dontneed(trans, iter);
return iter; return iter;
} }
......
...@@ -300,6 +300,11 @@ static inline bool btree_iter_keep(struct btree_trans *trans, struct btree_iter ...@@ -300,6 +300,11 @@ static inline bool btree_iter_keep(struct btree_trans *trans, struct btree_iter
(iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT); (iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT);
} }
static inline void set_btree_iter_dontneed(struct btree_trans *trans, struct btree_iter *iter)
{
trans->iters_touched &= ~(1ULL << iter->idx);
}
#define TRANS_RESET_NOTRAVERSE (1 << 0) #define TRANS_RESET_NOTRAVERSE (1 << 0)
void bch2_trans_reset(struct btree_trans *, unsigned); void bch2_trans_reset(struct btree_trans *, unsigned);
......
...@@ -172,23 +172,21 @@ static int btree_key_cache_fill(struct btree_trans *trans, ...@@ -172,23 +172,21 @@ static int btree_key_cache_fill(struct btree_trans *trans,
ck->key.pos, BTREE_ITER_SLOTS); ck->key.pos, BTREE_ITER_SLOTS);
k = bch2_btree_iter_peek_slot(iter); k = bch2_btree_iter_peek_slot(iter);
ret = bkey_err(k); ret = bkey_err(k);
if (ret) { if (ret)
bch2_trans_iter_put(trans, iter); goto err;
return ret;
}
if (!bch2_btree_node_relock(ck_iter, 0)) { if (!bch2_btree_node_relock(ck_iter, 0)) {
bch2_trans_iter_put(trans, iter);
trace_transaction_restart_ip(trans->ip, _THIS_IP_); trace_transaction_restart_ip(trans->ip, _THIS_IP_);
return -EINTR; ret = -EINTR;
goto err;
} }
if (k.k->u64s > ck->u64s) { if (k.k->u64s > ck->u64s) {
new_u64s = roundup_pow_of_two(k.k->u64s); new_u64s = roundup_pow_of_two(k.k->u64s);
new_k = kmalloc(new_u64s * sizeof(u64), GFP_NOFS); new_k = kmalloc(new_u64s * sizeof(u64), GFP_NOFS);
if (!new_k) { if (!new_k) {
bch2_trans_iter_put(trans, iter); ret = -ENOMEM;
return -ENOMEM; goto err;
} }
} }
...@@ -204,9 +202,10 @@ static int btree_key_cache_fill(struct btree_trans *trans, ...@@ -204,9 +202,10 @@ static int btree_key_cache_fill(struct btree_trans *trans,
bch2_btree_node_unlock_write(ck_iter->l[0].b, ck_iter); bch2_btree_node_unlock_write(ck_iter->l[0].b, ck_iter);
/* We're not likely to need this iterator again: */ /* We're not likely to need this iterator again: */
bch2_trans_iter_free(trans, iter); set_btree_iter_dontneed(trans, iter);
err:
return 0; bch2_trans_iter_put(trans, iter);
return ret;
} }
static int bkey_cached_check_fn(struct six_lock *lock, void *p) static int bkey_cached_check_fn(struct six_lock *lock, void *p)
......
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