• David Sterba's avatar
    btrfs: clear defragmented inodes using postorder in btrfs_cleanup_defrag_inodes() · 27694091
    David Sterba authored
    btrfs_cleanup_defrag_inodes() is not called frequently, only in remount
    or unmount, but the way it frees the inodes in fs_info->defrag_inodes
    is inefficient. Each time it needs to locate first node, remove it,
    potentially rebalance tree until it's done. This allows to do a
    conditional reschedule.
    
    For cleanups the rbtree_postorder_for_each_entry_safe() iterator is
    convenient but we can't reschedule and restart iteration because some of
    the tree nodes would be already freed.
    
    The cleanup operation is kmem_cache_free() which will likely take the
    fast path for most objects so rescheduling should not be necessary.
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    27694091
defrag.c 39.9 KB