diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-27 09:56:33 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:26 -0400 |
commit | bf3efff5e4fc2dcd6e6c15578d3f08c301a13229 (patch) | |
tree | cca40f2591a81ba52e14350a663266b83c78e43f /fs/bcachefs/btree_io.h | |
parent | 6f5f747c318be4adf3824ee7716a7886da35f9a3 (diff) |
bcachefs: Fix race leading to btree node write getting stuck
Checking btree_node_may_write() isn't atomic with the other btree flags,
dirty and need_write in particular. There was a rare race where we'd
unblock a node from writing while __btree_node_flush() was setting
need_write, and no thread would notice that the node was now both able
to write and needed to be written.
Fix this by adding btree node flags for will_make_reachable and
write_blocked that can be checked in the cmpxchg loop in
__bch2_btree_node_write.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_io.h')
-rw-r--r-- | fs/bcachefs/btree_io.h | 6 |
1 files changed, 0 insertions, 6 deletions
diff --git a/fs/bcachefs/btree_io.h b/fs/bcachefs/btree_io.h index 7ed88089f6f9..d818d87661e8 100644 --- a/fs/bcachefs/btree_io.h +++ b/fs/bcachefs/btree_io.h @@ -62,12 +62,6 @@ void __bch2_btree_node_wait_on_write(struct btree *); void bch2_btree_node_wait_on_read(struct btree *); void bch2_btree_node_wait_on_write(struct btree *); -static inline bool btree_node_may_write(struct btree *b) -{ - return list_empty_careful(&b->write_blocked) && - (!b->written || !b->will_make_reachable); -} - enum compact_mode { COMPACT_LAZY, COMPACT_ALL, |