• Filipe Manana's avatar
    Btrfs: allow clear_extent_dirty() to receive a cached extent state record · e9a7415a
    Filipe Manana authored
    [ Upstream commit 0e6ec385 ]
    
    We can have a lot freed extents during the life span of transaction, so
    the red black tree that keeps track of the ranges of each freed extent
    (fs_info->freed_extents[]) can get quite big. When finishing a
    transaction commit we find each range, process it (discard the extents,
    unpin them) and then remove it from the red black tree.
    
    We can use an extent state record as a cache when searching for a range,
    so that when we clean the range we can use the cached extent state we
    passed to the search function instead of iterating the red black tree
    again. Doing things as fast as possible when finishing a transaction (in
    state TRANS_STATE_UNBLOCKED) is convenient as it reduces the time we
    block another task that wants to commit the next transaction.
    
    So change clear_extent_dirty() to allow an optional extent state record to
    be passed as an argument, which will be passed down to __clear_extent_bit.
    Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    e9a7415a
extent_io.h 18.4 KB