bcachefs: Handle errors in bch2_trans_mark_update()
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 18 Apr 2021 21:26:34 +0000 (17:26 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:01 +0000 (17:09 -0400)
It's not actually the case that iterators are always checked here -
__bch2_trans_commit() checks for that after running triggers.

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

index 84a5606..ab60bf2 100644 (file)
@@ -293,8 +293,10 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
 {
        int ret;
 
+       down_read(&c->gc_lock);
        ret = bch2_btree_and_journal_walk(c, journal_keys, BTREE_ID_alloc,
                                          NULL, bch2_alloc_read_fn);
+       up_read(&c->gc_lock);
        if (ret) {
                bch_err(c, "error reading alloc info: %i", ret);
                return ret;
index 3f68a30..b51f311 100644 (file)
@@ -1836,10 +1836,11 @@ int bch2_trans_mark_update(struct btree_trans *trans,
                return 0;
 
        if (!btree_node_type_is_extents(iter->btree_id)) {
-               /* iterators should be uptodate, shouldn't get errors here: */
                if (btree_iter_type(iter) != BTREE_ITER_CACHED) {
                        old = bch2_btree_iter_peek_slot(iter);
-                       BUG_ON(bkey_err(old));
+                       ret = bkey_err(old);
+                       if (ret)
+                               return ret;
                } else {
                        struct bkey_cached *ck = (void *) iter->l[0].b;