]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Slim down inlined part of bch2_btree_path_upgrade()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 10 May 2025 17:24:25 +0000 (13:24 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:53 +0000 (20:14 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_locking.c
fs/bcachefs/btree_locking.h

index baa505a9a706416cb0cb3dcd5ed985f8c96fa6d4..448613be90ba4f03f5f171b6cf8faa1d4cd8bed6 100644 (file)
@@ -618,22 +618,22 @@ bool bch2_btree_path_upgrade_noupgrade_sibs(struct btree_trans *trans,
                               unsigned new_locks_want,
                               struct get_locks_fail *f)
 {
-       EBUG_ON(path->locks_want >= new_locks_want);
-
-       path->locks_want = new_locks_want;
+       path->locks_want = max_t(unsigned, path->locks_want, new_locks_want);
 
        bool ret = btree_path_get_locks(trans, path, true, f);
        bch2_trans_verify_locks(trans);
        return ret;
 }
 
-bool __bch2_btree_path_upgrade(struct btree_trans *trans,
-                              struct btree_path *path,
-                              unsigned new_locks_want,
-                              struct get_locks_fail *f)
+int __bch2_btree_path_upgrade(struct btree_trans *trans,
+                             struct btree_path *path,
+                             unsigned new_locks_want)
 {
-       bool ret = bch2_btree_path_upgrade_noupgrade_sibs(trans, path, new_locks_want, f);
-       if (ret)
+       struct get_locks_fail f = {};
+       unsigned old_locks_want = path->locks_want;
+       int ret = 0;
+
+       if (bch2_btree_path_upgrade_noupgrade_sibs(trans, path, new_locks_want, &f))
                goto out;
 
        /*
@@ -668,6 +668,10 @@ bool __bch2_btree_path_upgrade(struct btree_trans *trans,
                                btree_path_get_locks(trans, linked, true, NULL);
                        }
        }
+
+       trace_and_count(trans->c, trans_restart_upgrade, trans, _THIS_IP_, path,
+                       old_locks_want, new_locks_want, &f);
+       ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_upgrade);
 out:
        bch2_trans_verify_locks(trans);
        return ret;
index 66b27c0853a5ce43f79ee4bef8c17f6a3e462845..59000d0dabeacdd03da696e05a7eb31305941ec1 100644 (file)
@@ -380,27 +380,18 @@ bool bch2_btree_path_upgrade_noupgrade_sibs(struct btree_trans *,
                               struct btree_path *, unsigned,
                               struct get_locks_fail *);
 
-bool __bch2_btree_path_upgrade(struct btree_trans *,
-                              struct btree_path *, unsigned,
-                              struct get_locks_fail *);
+int __bch2_btree_path_upgrade(struct btree_trans *,
+                             struct btree_path *, unsigned);
 
 static inline int bch2_btree_path_upgrade(struct btree_trans *trans,
                                          struct btree_path *path,
                                          unsigned new_locks_want)
 {
-       struct get_locks_fail f = {};
-       unsigned old_locks_want = path->locks_want;
-
        new_locks_want = min(new_locks_want, BTREE_MAX_DEPTH);
 
-       if (path->locks_want < new_locks_want
-           ? __bch2_btree_path_upgrade(trans, path, new_locks_want, &f)
-           : path->nodes_locked)
-               return 0;
-
-       trace_and_count(trans->c, trans_restart_upgrade, trans, _THIS_IP_, path,
-                       old_locks_want, new_locks_want, &f);
-       return btree_trans_restart(trans, BCH_ERR_transaction_restart_upgrade);
+       return likely(path->locks_want >= new_locks_want && path->nodes_locked)
+               ? 0
+               : __bch2_btree_path_upgrade(trans, path, new_locks_want);
 }
 
 /* misc: */