bcachefs: Ensure __bch2_trans_commit() always calls bch2_trans_reset()
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 22 Jan 2021 00:30:35 +0000 (19:30 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:51 +0000 (17:08 -0400)
This was leading to a very strange bug in bch2_bucket_io_time_reset(),
where we'd retry without clearing out the list of updates.

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

index ffd8e0b..f64e7d3 100644 (file)
@@ -836,7 +836,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
        int ret = 0;
 
        if (!trans->nr_updates)
-               goto out_noupdates;
+               goto out_reset;
 
        if (trans->flags & BTREE_INSERT_GC_LOCK_HELD)
                lockdep_assert_held(&trans->c->gc_lock);
@@ -850,7 +850,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
            unlikely(!percpu_ref_tryget(&trans->c->writes))) {
                ret = bch2_trans_commit_get_rw_cold(trans);
                if (ret)
-                       return ret;
+                       goto out_reset;
        }
 
 #ifdef CONFIG_BCACHEFS_DEBUG
@@ -962,7 +962,7 @@ out:
 
        if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
                percpu_ref_put(&trans->c->writes);
-out_noupdates:
+out_reset:
        bch2_trans_reset(trans, !ret ? TRANS_RESET_NOTRAVERSE : 0);
 
        return ret;