bcachefs: Fix a write buffer flush deadlock
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 10 Jul 2023 15:17:56 +0000 (11:17 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:06 +0000 (17:10 -0400)
commit01e691e830edae9a145eeb70f8983223d606e2ca
tree278d45c4b81de206eb65084fda747c7d7a40230d
parentba8eeae8eee0aae03eb6be0372519b72057d312c
bcachefs: Fix a write buffer flush deadlock

We're not supposed to block if BTREE_INSERT_JOURNAL_RECLAIM && watermark
!= BCH_WATERMARK_reclaim.

This should really be a separate BTREE_INSERT_NONBLOCK flag - add some
comments to that effect, it's not important for this patch.

btree write buffer flush depends on this behaviour though - the first
loop tries to flush sequentially, which doesn't free up space in the
journal optimally. If that can't proceed we bail out and flush in
journal order - that won't work if we're blocked instead of returning an
error.

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