• Kent Overstreet's avatar
    bcachefs: Fix two more deadlocks · bc970cec
    Kent Overstreet authored
    Deadlock on shutdown:
    
    btree_update_nodes_written() unblocks btree nodes from being written;
    after doing so, it has to check if they were marked as needing to be
    written and if so kick off those writes - if that doesn't happen, we'll
    never release journal pins and shutdown will get stuck when flushing the
    journal.
    
    There was an error path where this didn't happen, because in the error
    path we don't actually want those btree nodes write to happen; however,
    we still have to kick off the write path so the journal pins get
    released. The btree write path checks if we're in a journal error state
    and doesn't do the actual write if we are.
    
    Also - there was another deadlock because btree_update_nodes_written()
    was taking the btree update off of the unwritten_list too soon - before
    getting a journal reservation, which could fail and have to be retried.
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    bc970cec
btree_update_interior.c 57.2 KB