• Filipe Manana's avatar
    btrfs: more efficient chunk map iteration when device replace finishes · 68a505bb
    Filipe Manana authored
    When iterating the chunk maps when a device replace finishes we are doing
    a full rbtree search for each chunk map, which is not the most efficient
    thing to do, wasting CPU time. As we are holding a write lock on the tree
    during the whole iteration, we can simply start from the first node in the
    tree and then move to the next chunk map by doing a rb_next() call - the
    only exception is when we need to reschedule, in which case we have to do
    a full rbtree search since we dropped the write lock and the tree may have
    changed (chunk maps may have been removed and the tree got rebalanced).
    So just do that.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    68a505bb
dev-replace.c 38.5 KB