bcachefs: Fix bch2_btree_update_start() to return -BCH_ERR_journal_reclaim_would_deadlock
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 27 Aug 2022 16:37:05 +0000 (12:37 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:39 +0000 (17:09 -0400)
On failure to get a journal pre-reservation because we're called from
journal reclaim we're not supposed to return a transaction restart error
- this fixes a livelock.

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

index fc768195be5480837b6335fa242a0a0c37263ed9..dd9405c631f5f3297791dcc73e1a9e1680cca928 100644 (file)
@@ -1049,6 +1049,11 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
        if (ret) {
                bch2_trans_unlock(trans);
 
+               if (flags & BTREE_INSERT_JOURNAL_RECLAIM) {
+                       ret = -BCH_ERR_journal_reclaim_would_deadlock;
+                       goto err;
+               }
+
                ret = bch2_journal_preres_get(&c->journal, &as->journal_preres,
                                              BTREE_UPDATE_JOURNAL_RES,
                                              journal_flags);