• Filipe Manana's avatar
    btrfs: avoid useless rbtree iterations when attempting to merge extent map · 1a9fb16c
    Filipe Manana authored
    When trying to merge an extent map that was just inserted or unpinned, we
    will try to merge it with any adjacent extent map that is suitable.
    
    However we will only check if our extent map is mergeable after searching
    for the previous and next extent maps in the rbtree, meaning that we are
    doing unnecessary calls to rb_prev() and rb_next() in case our extent map
    is not mergeable (it's compressed, in the list of modifed extents, being
    logged or pinned), wasting CPU time chasing rbtree pointers and pulling
    in unnecessary cache lines.
    
    So change the logic to check first if an extent map is mergeable before
    searching for the next and previous extent maps in the rbtree.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    1a9fb16c
extent_map.c 27.8 KB