bcachefs: Fix a locking bug
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 12 Feb 2019 00:04:40 +0000 (19:04 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:15 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/btree_update_leaf.c

index c44e0417af87c3f5aefcb9512f589c6fe4b65a50..34c1de63e43b837bac9c3b47f15caaa49ec43e4a 100644 (file)
@@ -883,6 +883,7 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca)
 
                ret = __bch2_alloc_write_key(c, ca, b, &iter,
                                must_flush ? &journal_seq : NULL,
+                               BTREE_INSERT_GC_LOCK_HELD|
                                !fifo_empty(&ca->free_inc) ? BTREE_INSERT_NOWAIT : 0);
        }
 
index e052a3debadb4961f7744c157ab1dac93cb53ad7..d1a2ac48ed29b43ae8a922780e963ed0e1458f95 100644 (file)
@@ -624,6 +624,9 @@ int __bch2_btree_insert_at(struct btree_insert *trans)
        /* for the sake of sanity: */
        BUG_ON(trans->nr > 1 && !(trans->flags & BTREE_INSERT_ATOMIC));
 
+       if (trans->flags & BTREE_INSERT_GC_LOCK_HELD)
+               lockdep_assert_held(&c->gc_lock);
+
        bubble_sort(trans->entries, trans->nr, btree_trans_cmp);
 
        trans_for_each_entry(trans, i)