bcachefs: Fix deadlock in journal write path
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 20 Apr 2024 01:54:32 +0000 (21:54 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 21 Apr 2024 03:00:59 +0000 (23:00 -0400)
commit85ab365f7cdf2b2a713823a93e7e5e94f0529627
tree45f417ba5f0d0e9e7e299d16bf3a469726b429d4
parentadfe9357c39e251ffe22ceaa1edb4b7662ed76e6
bcachefs: Fix deadlock in journal write path

bch2_journal_write() was incorrectly waiting on earlier journal writes
synchronously; this usually worked because most of the time we'd be
running in the context of a thread that did a journal_buf_put(), but
sometimes we'd be running out of the same workqueue that completes those
prior journal writes.

Additionally, this makes sure to punt to a workqueue before submitting
preflushes - we really don't want to be calling submit_bio() in the main
transaction commit path.

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