From: Kent Overstreet Date: Mon, 17 Jun 2024 13:09:52 +0000 (-0400) Subject: bcachefs: Fix a locking bug in the do_discard_fast() path X-Git-Tag: v6.10-rc5~12^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3727ca56049d893859b68f70e50092250de79f28;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Fix a locking bug in the do_discard_fast() path 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 --- diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index c4b6601f5b748..d2241f2b40fed 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -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);