• Qu Wenruo's avatar
    btrfs: defrag: introduce helper to defrag a range · e9eec721
    Qu Wenruo authored
    A new helper, defrag_one_range(), is introduced to defrag one range.
    
    This function will mostly prepare the needed pages and extent status for
    defrag_one_locked_target().
    
    As we can only have a consistent view of extent map with page and extent
    bits locked, we need to re-check the range passed in to get a real
    target list for defrag_one_locked_target().
    
    Since defrag_collect_targets() will call defrag_lookup_extent() and lock
    extent range, we also need to teach those two functions to skip extent
    lock.  Thus new parameter, @locked, is introduced to skip extent lock if
    the caller has already locked the range.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    e9eec721
ioctl.c 132 KB