• Qu Wenruo's avatar
    btrfs: autodefrag: only scan one inode once · 26fbac25
    Qu Wenruo authored
    Although we have btrfs_requeue_inode_defrag(), for autodefrag we are
    still just exhausting all inode_defrag items in the tree.
    
    This means, it doesn't make much difference to requeue an inode_defrag,
    other than scan the inode from the beginning till its end.
    
    Change the behaviour to always scan from offset 0 of an inode, and till
    the end.
    
    By this we get the following benefit:
    
    - Straight-forward code
    
    - No more re-queue related check
    
    - Fewer members in inode_defrag
    
    We still keep the same btrfs_get_fs_root() and btrfs_iget() check for
    each loop, and added extra should_auto_defrag() check per-loop.
    
    Note: the patch needs to be backported and is intentionally written
    to minimize the diff size, code will be cleaned up later.
    
    CC: stable@vger.kernel.org # 5.16
    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>
    26fbac25
file.c 103 KB