• Kent Overstreet's avatar
    bcachefs: Improved topology repair checks · 79032b07
    Kent Overstreet authored
    Consolidate bch2_gc_check_topology() and btree_node_interior_verify(),
    and replace them with an improved version,
    bch2_btree_node_check_topology().
    
    This checks that children of an interior node correctly span the full
    range of the parent node with no overlaps.
    
    Also, ensure that topology repairs at runtime are always a fatal error;
    in particular, this adds a check in btree_iter_down() - if we don't find
    a key while walking down the btree that's indicative of a topology error
    and should be flagged as such, not a null ptr deref.
    
    Some checks in btree_update_interior.c remaining BUG_ONS(), because we
    already checked the node for topology errors when starting the update,
    and the assertions indicate that we _just_ corrupted the btree node -
    i.e. the problem can't be that existing on disk corruption, they
    indicate an actual algorithmic bug.
    
    In the future, we'll be annotating the fsck errors list with which
    recovery pass corrects them; the open coded "run explicit recovery pass
    or fatal error" in bch2_btree_node_check_topology() will in the future
    be done for every fsck_err() call.
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    79032b07
btree_gc.c 48.1 KB