]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bcachefs: Fix a locking bug in the do_discard_fast() path
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 17 Jun 2024 13:09:52 +0000 (09:09 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 19 Jun 2024 22:27:23 +0000 (18:27 -0400)
We can't discard a bucket while it's still open; this needs the
bucket_is_open_safe() version, which takes the open_buckets lock.

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

index c4b6601f5b7482bb55931b66e0f66a26dc18a62f..d2241f2b40feda1a0caee9a40378d3a36e107a6d 100644 (file)
@@ -882,7 +882,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
                        closure_wake_up(&c->freelist_wait);
 
                if (statechange(a->data_type == BCH_DATA_need_discard) &&
-                   !bch2_bucket_is_open(c, new.k->p.inode, new.k->p.offset) &&
+                   !bch2_bucket_is_open_safe(c, new.k->p.inode, new.k->p.offset) &&
                    bucket_flushed(new_a))
                        bch2_discard_one_bucket_fast(c, new.k->p);