• Kent Overstreet's avatar
    bcachefs: Fix race leading to btree node write getting stuck · bf3efff5
    Kent Overstreet authored
    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: default avatarKent Overstreet <kent.overstreet@gmail.com>
    bf3efff5
btree_cache.c 27 KB