]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Change __bch2_trans_commit() to run triggers then get RW
authorKent Overstreet <kent.overstreet@gmail.com>
Sat, 19 Feb 2022 07:40:45 +0000 (02:40 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:24 +0000 (17:09 -0400)
This is prep work for the next patch, which is going to change
__bch2_trans_commit() to use bch2_journal_key_insert() when very early
in the recovery process, so that we have a unified interface for doing
btree updates.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_update_leaf.c

index bde4bb2b7fcc6db52499a85c8b6094ddf3944746..9d41711c4e9b0a9c63ee63701c9946637524dc0c 100644 (file)
@@ -982,6 +982,17 @@ int __bch2_trans_commit(struct btree_trans *trans)
        if (trans->flags & BTREE_INSERT_GC_LOCK_HELD)
                lockdep_assert_held(&c->gc_lock);
 
+       ret = bch2_trans_commit_run_triggers(trans);
+       if (ret)
+               goto out_reset;
+
+       if (!(trans->flags & BTREE_INSERT_NOCHECK_RW) &&
+           unlikely(!percpu_ref_tryget(&c->writes))) {
+               ret = bch2_trans_commit_get_rw_cold(trans);
+               if (ret)
+                       goto out_reset;
+       }
+
        memset(&trans->journal_preres, 0, sizeof(trans->journal_preres));
 
        trans->journal_u64s             = trans->extra_journal_entry_u64s;
@@ -992,17 +1003,6 @@ int __bch2_trans_commit(struct btree_trans *trans)
        if (trans->journal_transaction_names)
                trans->journal_u64s += JSET_ENTRY_LOG_U64s;
 
-       if (!(trans->flags & BTREE_INSERT_NOCHECK_RW) &&
-           unlikely(!percpu_ref_tryget(&c->writes))) {
-               ret = bch2_trans_commit_get_rw_cold(trans);
-               if (ret)
-                       goto out_reset;
-       }
-
-       ret = bch2_trans_commit_run_triggers(trans);
-       if (ret)
-               goto out;
-
        trans_for_each_update(trans, i) {
                BUG_ON(!i->path->should_be_locked);