• Kent Overstreet's avatar
    bcache: Add btree_insert_node() · 26c949f8
    Kent Overstreet authored
    The flow of control in the old btree insertion code was rather -
    backwards; we'd recurse down the btree (in btree_insert_recurse()), and
    then if we needed to split the keys to be inserted into the parent node
    would be effectively returned up to btree_insert_recurse(), which would
    notice there was more work to do and finish the insertion.
    
    The main problem with this was that the full logic for btree insertion
    could only be used by calling btree_insert_recurse; if you'd gotten to a
    btree leaf some other way and had a key to insert, if it turned out that
    node needed to be split you were SOL.
    
    This inverts the flow of control so btree_insert_node() does _full_
    btree insertion, including splitting - and takes a (leaf) btree node to
    insert into as a parameter.
    
    This means we can now _correctly_ handle cache misses - for cache
    misses, we need to insert a fake "check" key into the btree when we
    discover we have a cache miss - while we still have the btree locked.
    Previously, if the btree node was full inserting a cache miss would just
    fail.
    Signed-off-by: default avatarKent Overstreet <kmo@daterainc.com>
    26c949f8
bset.h 13.6 KB