• Filipe Manana's avatar
    Btrfs: lookup for block group only if needed when freeing a tree block · 6219872d
    Filipe Manana authored
    Very often our extent buffer's header generation doesn't match the current
    transaction's id or it is also referenced by other trees (snapshots), so
    we don't need the corresponding block group cache object. Therefore only
    search for it if we are going to use it, so we avoid an unnecessary search
    in the block groups rbtree (and acquiring and releasing its spinlock).
    
    Freeing a tree block is performed when COWing or deleting a node/leaf,
    which implies we are holding the node/leaf's parent node lock, therefore
    reducing the amount of time spent when freeing a tree block helps reducing
    the amount of time we are holding the parent node's lock.
    
    For example, for a run of xfstests/generic/083, the block group cache
    object was needed only 682 times for a total of 226691 calls to free
    a tree block.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
    6219872d
extent-tree.c 260 KB