bcachefs: Kill retry loop in btree merge path
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 5 Sep 2021 04:22:32 +0000 (00:22 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:11 +0000 (17:09 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_update_interior.c
fs/bcachefs/btree_update_interior.h

index f31db131071568d92dcd118024e804002698e1c0..73a79563487dd5a7a5b2d9927399fe9b5e150235 100644 (file)
@@ -1572,12 +1572,7 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
        struct btree *b, *m, *n, *prev, *next, *parent;
        struct bpos sib_pos;
        size_t sib_u64s;
-       int ret = 0, ret2 = 0;
-
-retry:
-       ret = bch2_btree_path_traverse(trans, path, false);
-       if (ret)
-               return ret;
+       int ret = 0;
 
        BUG_ON(!path->should_be_locked);
        BUG_ON(!btree_node_locked(path, level));
@@ -1587,7 +1582,7 @@ retry:
        if ((sib == btree_prev_sib && !bpos_cmp(b->data->min_key, POS_MIN)) ||
            (sib == btree_next_sib && !bpos_cmp(b->data->max_key, SPOS_MAX))) {
                b->sib_u64s[sib] = U16_MAX;
-               goto out;
+               return 0;
        }
 
        sib_pos = sib == btree_prev_sib
@@ -1715,29 +1710,10 @@ retry:
 
        bch2_btree_update_done(as);
 out:
-       bch2_trans_verify_locks(trans);
-       if (sib_path)
-               bch2_path_put(trans, sib_path, true);
-
-       /*
-        * Don't downgrade locks here: we're called after successful insert,
-        * and the caller will downgrade locks after a successful insert
-        * anyways (in case e.g. a split was required first)
-        *
-        * And we're also called when inserting into interior nodes in the
-        * split path, and downgrading to read locks in there is potentially
-        * confusing:
-        */
-       return ret ?: ret2;
 err:
-       if (sib_path)
-               bch2_path_put(trans, sib_path, true);
-       sib_path = NULL;
-
-       if (ret == -EINTR && bch2_trans_relock(trans))
-               goto retry;
-
-       goto out;
+       bch2_path_put(trans, sib_path, true);
+       bch2_trans_verify_locks(trans);
+       return ret;
 }
 
 /**
index c06cfcc66db7d15a6e1cde1c51e5c5a29ac25266..8e03bd987d6dc52bcc74fafe98c830fc5054d9d1 100644 (file)
@@ -129,11 +129,7 @@ static inline int bch2_foreground_maybe_merge_sibling(struct btree_trans *trans,
 {
        struct btree *b;
 
-       if (path->uptodate >= BTREE_ITER_NEED_TRAVERSE)
-               return 0;
-
-       if (!bch2_btree_node_relock(trans, path, level))
-               return 0;
+       EBUG_ON(!btree_node_locked(path, level));
 
        b = path->l[level].b;
        if (b->sib_u64s[sib] > trans->c->btree_foreground_merge_threshold)