Commit a88171c9 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Clean up interior update paths

Btree node merging now happens prior to transaction commit, not after,
so we don't need to pay attention to BTREE_INSERT_NOUNLOCK.

Also, foreground_maybe_merge shouldn't be calling
bch2_btree_iter_traverse_all() - this is becoming private to the btree
iterator code and should only be called by bch2_trans_begin().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 700c25b3
......@@ -1335,7 +1335,7 @@ static int __btree_iter_traverse_all(struct btree_trans *trans, int ret,
return ret;
}
int bch2_btree_iter_traverse_all(struct btree_trans *trans)
static int bch2_btree_iter_traverse_all(struct btree_trans *trans)
{
return __btree_iter_traverse_all(trans, 0, _RET_IP_);
}
......
......@@ -148,8 +148,6 @@ void bch2_btree_iter_reinit_node(struct btree_iter *, struct btree *);
int __must_check bch2_btree_iter_traverse(struct btree_iter *);
int bch2_btree_iter_traverse_all(struct btree_trans *);
struct btree *bch2_btree_iter_peek_node(struct btree_iter *);
struct btree *bch2_btree_iter_next_node(struct btree_iter *);
......
......@@ -960,9 +960,6 @@ bch2_btree_update_start(struct btree_iter *iter, unsigned level,
if (flags & BTREE_INSERT_GC_LOCK_HELD)
lockdep_assert_held(&c->gc_lock);
else if (!down_read_trylock(&c->gc_lock)) {
if (flags & BTREE_INSERT_NOUNLOCK)
return ERR_PTR(-EINTR);
bch2_trans_unlock(trans);
down_read(&c->gc_lock);
if (!bch2_trans_relock(trans)) {
......@@ -1005,16 +1002,6 @@ bch2_btree_update_start(struct btree_iter *iter, unsigned level,
BTREE_UPDATE_JOURNAL_RES,
journal_flags|JOURNAL_RES_GET_NONBLOCK);
if (ret == -EAGAIN) {
/*
* this would be cleaner if bch2_journal_preres_get() took a
* closure argument
*/
if (flags & BTREE_INSERT_NOUNLOCK) {
trace_trans_restart_journal_preres_get(trans->ip, _RET_IP_);
ret = -EINTR;
goto err;
}
bch2_trans_unlock(trans);
if (flags & BTREE_INSERT_JOURNAL_RECLAIM) {
......@@ -1043,8 +1030,7 @@ bch2_btree_update_start(struct btree_iter *iter, unsigned level,
if (ret)
goto err;
ret = bch2_btree_reserve_get(as, nr_nodes, flags,
!(flags & BTREE_INSERT_NOUNLOCK) ? &cl : NULL);
ret = bch2_btree_reserve_get(as, nr_nodes, flags, &cl);
if (ret)
goto err;
......@@ -1057,8 +1043,6 @@ bch2_btree_update_start(struct btree_iter *iter, unsigned level,
bch2_btree_update_free(as);
if (ret == -EAGAIN) {
BUG_ON(flags & BTREE_INSERT_NOUNLOCK);
bch2_trans_unlock(trans);
closure_sync(&cl);
ret = -EINTR;
......@@ -1593,12 +1577,12 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
size_t sib_u64s;
int ret = 0, ret2 = 0;
BUG_ON(!btree_node_locked(iter, level));
retry:
ret = bch2_btree_iter_traverse(iter);
if (ret)
goto err;
return ret;
BUG_ON(!iter->should_be_locked);
BUG_ON(!btree_node_locked(iter, level));
b = iter->l[level].b;
......@@ -1751,13 +1735,6 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
if (ret == -EINTR && bch2_trans_relock(trans))
goto retry;
if (ret == -EINTR && !(flags & BTREE_INSERT_NOUNLOCK)) {
ret2 = ret;
ret = bch2_btree_iter_traverse_all(trans);
if (!ret)
goto retry;
}
goto out;
}
......
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