bcachefs: Issue a transaction restart after commit in repair
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 28 Nov 2024 03:09:29 +0000 (22:09 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:20 +0000 (01:36 -0500)
transaction commits invalidate pointers to btree values, and they also
downgrade intent locks.

This breaks the interior btree update path, which takes intent locks and
then calls into the allocator.

This isn't an ideal solution: we can't unconditionally issue a restart
after a transaction commit, because that would break other codepaths.

Reported-by: syzbot+78d82470c16a49702682@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/errcode.h

index 8846daa..79af226 100644 (file)
@@ -1384,7 +1384,7 @@ delete:
        ret =   bch2_btree_bit_mod_iter(trans, iter, false) ?:
                bch2_trans_commit(trans, NULL, NULL,
                        BCH_TRANS_COMMIT_no_enospc) ?:
-               1;
+               -BCH_ERR_transaction_restart_commit;
        goto out;
 }
 
index a12050e..a0cfc0f 100644 (file)
        x(BCH_ERR_transaction_restart,  transaction_restart_split_race)         \
        x(BCH_ERR_transaction_restart,  transaction_restart_write_buffer_flush) \
        x(BCH_ERR_transaction_restart,  transaction_restart_nested)             \
+       x(BCH_ERR_transaction_restart,  transaction_restart_commit)             \
        x(0,                            no_btree_node)                          \
        x(BCH_ERR_no_btree_node,        no_btree_node_relock)                   \
        x(BCH_ERR_no_btree_node,        no_btree_node_upgrade)                  \